⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 273794 in webkit


Ignore:
Timestamp:
Mar 2, 2021, 7:08:47 PM (6 years ago)
Author:
Alan Coon
Message:

Cherry-pick r273438. rdar://problem/74953033

Regression(r268700) postMessage changes prototype of basic types
​https://bugs.webkit.org/show_bug.cgi?id=222228
<rdar://problem/74612853>

Reviewed by Geoffrey Garen.

Source/WebCore:

r268700 updated ScriptExecutionContext::globalObject() to call:
WebCore::globalObject(mainThreadNormalWorld(), downcast<Document>(*this).page())
instead of
frame ? frame->script().globalObject(mainThreadNormalWorld()) : nullptr

This was not right for subframes because globalObject() gets the globalObject from
the page's main frame instead of the document's frame.

This patch gets rid of the error-prone WebCore::globalObject() taking in a Page*
and replaces it with one taking in a Frame* to avoid such issues in the future.

Test: fast/dom/Window/postMessage-Object-prototype.html

  • bindings/js/ScriptState.cpp: (WebCore::globalObject):
  • bindings/js/ScriptState.h:
  • dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::globalObject):
  • inspector/InspectorFrontendHost.cpp: (WebCore::InspectorFrontendHost::addSelfToGlobalObjectInWorld): (WebCore::InspectorFrontendHost::showContextMenu):

LayoutTests:

Add layout test coverage.

  • fast/dom/Window/postMessage-Object-prototype-expected.txt: Added.
  • fast/dom/Window/postMessage-Object-prototype.html: Added.
  • fast/dom/Window/resources/postMessage-Object-prototype-frame.html: Added.

git-svn-id: ​https://svn.webkit.org/repository/webkit/trunk@273438 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-612.1.5-branch
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612.1.5-branch/LayoutTests/ChangeLog

    r273792 r273794  
     12021-03-02  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r273438. rdar://problem/74953033
     4
     5    Regression(r268700) postMessage changes prototype of basic types
     6    https://bugs.webkit.org/show_bug.cgi?id=222228
     7    <rdar://problem/74612853>
     8   
     9    Reviewed by Geoffrey Garen.
     10   
     11    Source/WebCore:
     12   
     13    r268700 updated ScriptExecutionContext::globalObject() to call:
     14    `WebCore::globalObject(mainThreadNormalWorld(), downcast<Document>(*this).page())`
     15    instead of
     16    `frame ? frame->script().globalObject(mainThreadNormalWorld()) : nullptr`
     17   
     18    This was not right for subframes because globalObject() gets the globalObject from
     19    the page's main frame instead of the document's frame.
     20   
     21    This patch gets rid of the error-prone WebCore::globalObject() taking in a Page*
     22    and replaces it with one taking in a Frame* to avoid such issues in the future.
     23   
     24    Test: fast/dom/Window/postMessage-Object-prototype.html
     25   
     26    * bindings/js/ScriptState.cpp:
     27    (WebCore::globalObject):
     28    * bindings/js/ScriptState.h:
     29    * dom/ScriptExecutionContext.cpp:
     30    (WebCore::ScriptExecutionContext::globalObject):
     31    * inspector/InspectorFrontendHost.cpp:
     32    (WebCore::InspectorFrontendHost::addSelfToGlobalObjectInWorld):
     33    (WebCore::InspectorFrontendHost::showContextMenu):
     34   
     35    LayoutTests:
     36   
     37    Add layout test coverage.
     38   
     39    * fast/dom/Window/postMessage-Object-prototype-expected.txt: Added.
     40    * fast/dom/Window/postMessage-Object-prototype.html: Added.
     41    * fast/dom/Window/resources/postMessage-Object-prototype-frame.html: Added.
     42   
     43   
     44    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273438 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     45
     46    2021-02-24  Chris Dumez  <cdumez@apple.com>
     47
     48            Regression(r268700) postMessage changes prototype of basic types
     49            https://bugs.webkit.org/show_bug.cgi?id=222228
     50            <rdar://problem/74612853>
     51
     52            Reviewed by Geoffrey Garen.
     53
     54            Add layout test coverage.
     55
     56            * fast/dom/Window/postMessage-Object-prototype-expected.txt: Added.
     57            * fast/dom/Window/postMessage-Object-prototype.html: Added.
     58            * fast/dom/Window/resources/postMessage-Object-prototype-frame.html: Added.
     59
    1602021-03-02  Alan Coon  <alancoon@apple.com>
    261
  • branches/safari-612.1.5-branch/Source/WebCore/ChangeLog

    r273793 r273794  
     12021-03-02  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r273438. rdar://problem/74953033
     4
     5    Regression(r268700) postMessage changes prototype of basic types
     6    https://bugs.webkit.org/show_bug.cgi?id=222228
     7    <rdar://problem/74612853>
     8   
     9    Reviewed by Geoffrey Garen.
     10   
     11    Source/WebCore:
     12   
     13    r268700 updated ScriptExecutionContext::globalObject() to call:
     14    `WebCore::globalObject(mainThreadNormalWorld(), downcast<Document>(*this).page())`
     15    instead of
     16    `frame ? frame->script().globalObject(mainThreadNormalWorld()) : nullptr`
     17   
     18    This was not right for subframes because globalObject() gets the globalObject from
     19    the page's main frame instead of the document's frame.
     20   
     21    This patch gets rid of the error-prone WebCore::globalObject() taking in a Page*
     22    and replaces it with one taking in a Frame* to avoid such issues in the future.
     23   
     24    Test: fast/dom/Window/postMessage-Object-prototype.html
     25   
     26    * bindings/js/ScriptState.cpp:
     27    (WebCore::globalObject):
     28    * bindings/js/ScriptState.h:
     29    * dom/ScriptExecutionContext.cpp:
     30    (WebCore::ScriptExecutionContext::globalObject):
     31    * inspector/InspectorFrontendHost.cpp:
     32    (WebCore::InspectorFrontendHost::addSelfToGlobalObjectInWorld):
     33    (WebCore::InspectorFrontendHost::showContextMenu):
     34   
     35    LayoutTests:
     36   
     37    Add layout test coverage.
     38   
     39    * fast/dom/Window/postMessage-Object-prototype-expected.txt: Added.
     40    * fast/dom/Window/postMessage-Object-prototype.html: Added.
     41    * fast/dom/Window/resources/postMessage-Object-prototype-frame.html: Added.
     42   
     43   
     44    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273438 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     45
     46    2021-02-24  Chris Dumez  <cdumez@apple.com>
     47
     48            Regression(r268700) postMessage changes prototype of basic types
     49            https://bugs.webkit.org/show_bug.cgi?id=222228
     50            <rdar://problem/74612853>
     51
     52            Reviewed by Geoffrey Garen.
     53
     54            r268700 updated ScriptExecutionContext::globalObject() to call:
     55            `WebCore::globalObject(mainThreadNormalWorld(), downcast<Document>(*this).page())`
     56            instead of
     57            `frame ? frame->script().globalObject(mainThreadNormalWorld()) : nullptr`
     58
     59            This was not right for subframes because globalObject() gets the globalObject from
     60            the page's main frame instead of the document's frame.
     61
     62            This patch gets rid of the error-prone WebCore::globalObject() taking in a Page*
     63            and replaces it with one taking in a Frame* to avoid such issues in the future.
     64
     65            Test: fast/dom/Window/postMessage-Object-prototype.html
     66
     67            * bindings/js/ScriptState.cpp:
     68            (WebCore::globalObject):
     69            * bindings/js/ScriptState.h:
     70            * dom/ScriptExecutionContext.cpp:
     71            (WebCore::ScriptExecutionContext::globalObject):
     72            * inspector/InspectorFrontendHost.cpp:
     73            (WebCore::InspectorFrontendHost::addSelfToGlobalObjectInWorld):
     74            (WebCore::InspectorFrontendHost::showContextMenu):
     75
    1762021-03-02  Alan Coon  <alancoon@apple.com>
    277
  • branches/safari-612.1.5-branch/Source/WebCore/bindings/js/ScriptState.cpp

    r268775 r273794  
    9393}
    9494
    95 JSC::JSGlobalObject* globalObject(DOMWrapperWorld& world, Page* page)
     95JSC::JSGlobalObject* globalObject(DOMWrapperWorld& world, Frame* frame)
    9696{
    97     return page ? page->mainFrame().script().globalObject(world) : nullptr;
     97    return frame ? frame->script().globalObject(world) : nullptr;
    9898}
    9999
  • branches/safari-612.1.5-branch/Source/WebCore/bindings/js/ScriptState.h

    r268700 r273794  
    4343class Frame;
    4444class Node;
    45 class Page;
    4645class ScriptExecutionContext;
    4746class WorkerOrWorkletGlobalScope;
    … …  
    5453
    5554JSC::JSGlobalObject* globalObject(DOMWrapperWorld&, Node*);
    56 WEBCORE_EXPORT JSC::JSGlobalObject* globalObject(DOMWrapperWorld&, Page*);
     55WEBCORE_EXPORT JSC::JSGlobalObject* globalObject(DOMWrapperWorld&, Frame*);
    5756JSC::JSGlobalObject* globalObject(WorkerOrWorkletGlobalScope&);
    5857
  • branches/safari-612.1.5-branch/Source/WebCore/dom/ScriptExecutionContext.cpp

    r268868 r273794  
    513513{
    514514    if (is<Document>(*this))
    515         return WebCore::globalObject(mainThreadNormalWorld(), downcast<Document>(*this).page());
     515        return WebCore::globalObject(mainThreadNormalWorld(), downcast<Document>(*this).frame());
    516516
    517517    if (is<WorkerOrWorkletGlobalScope>(*this))
  • branches/safari-612.1.5-branch/Source/WebCore/inspector/InspectorFrontendHost.cpp

    r273077 r273794  
    159159void InspectorFrontendHost::addSelfToGlobalObjectInWorld(DOMWrapperWorld& world)
    160160{
    161     auto& lexicalGlobalObject = *globalObject(world, m_frontendPage);
     161    auto& lexicalGlobalObject = *globalObject(world, m_frontendPage ? &m_frontendPage->mainFrame() : nullptr);
    162162    auto& vm = lexicalGlobalObject.vm();
    163163    JSC::JSLockHolder lock(vm);
    … …  
    504504    ASSERT(m_frontendPage);
    505505
    506     auto& lexicalGlobalObject = *globalObject(debuggerWorld(), m_frontendPage);
     506    auto& lexicalGlobalObject = *globalObject(debuggerWorld(), &m_frontendPage->mainFrame());
    507507    auto& vm = lexicalGlobalObject.vm();
    508508    auto value = lexicalGlobalObject.get(&lexicalGlobalObject, JSC::Identifier::fromString(vm, "InspectorFrontendAPI"));
Note: See TracChangeset for help on using the changeset viewer.