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

Changeset 228309 in webkit


Ignore:
Timestamp:
Feb 8, 2018, 8:16:52 PM (9 years ago)
Author:
Chris Dumez
Message:

There should be a way to disable [OverrideBuiltins] behavior in a given DOMWrapperWorld
https://bugs.webkit.org/show_bug.cgi?id=182524
<rdar://problem/9057327>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Add new flag on DOMWrapperWorld indicating if the [OverrideBuiltins] behavior should
be enabled in this world or not. The behavior is enabled by default for Web-compatibility.
This flag is queried in accessVisibleNamedProperty() when doing the named property
lookup.

Covered by new API test.

  • bindings/js/DOMWrapperWorld.h:

(WebCore::DOMWrapperWorld::disableOverrideBuiltinsBehavior):
(WebCore::DOMWrapperWorld::shouldDisableOverrideBuiltinsBehavior const):

  • bindings/js/JSDOMAbstractOperations.h:

(WebCore::accessVisibleNamedProperty):

Source/WebKit:

Add C API on WKBundleScriptWorld and Cocoa API on WKWebProcessPlugInScriptWorld to
disable the [OverrideBuiltins] behavior on a given script world.

The [OverrideBuiltins] behavior [1] is legacy behavior that is needed for Web compatibility
but allowing the client to disable this behavior in a given world makes development easier
and running injected script on uncontrolled content a lot more reliable.

[1] https://heycam.github.io/webidl/#OverrideBuiltins

  • WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInScriptWorld.h:
  • WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInScriptWorld.mm:

(-[WKWebProcessPlugInScriptWorld disableOverrideBuiltinsBehavior]):

  • WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp:

(WKBundleScriptWorldDisableOverrideBuiltinsBehavior):

  • WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h:
  • WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp:

(WebKit::InjectedBundleScriptWorld::disableOverrideBuiltinsBehavior):

  • WebProcess/InjectedBundle/InjectedBundleScriptWorld.h:

Tools:

Add API test coverage.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKit/InjectedBundleDisableOverrideBuiltinsBehavior.cpp: Added.

(TestWebKitAPI::runJavaScriptAlert):
(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/WebKit/InjectedBundleDisableOverrideBuiltinsBehavior_Bundle.cpp: Added.

(TestWebKitAPI::InjectedBundleDisableOverrideBuiltinsBehaviorTest::InjectedBundleDisableOverrideBuiltinsBehaviorTest):
(TestWebKitAPI::InjectedBundleDisableOverrideBuiltinsBehaviorTest::initialize):

  • TestWebKitAPI/Tests/WebKit/override-builtins-test.html: Added.
Location:
trunk
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r228308 r228309  
     12018-02-08  Chris Dumez  <cdumez@apple.com>
     2
     3        There should be a way to disable [OverrideBuiltins] behavior in a given DOMWrapperWorld
     4        https://bugs.webkit.org/show_bug.cgi?id=182524
     5        <rdar://problem/9057327>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Add new flag on DOMWrapperWorld indicating if the [OverrideBuiltins] behavior should
     10        be enabled in this world or not. The behavior is enabled by default for Web-compatibility.
     11        This flag is queried in accessVisibleNamedProperty() when doing the named property
     12        lookup.
     13
     14        Covered by new API test.
     15
     16        * bindings/js/DOMWrapperWorld.h:
     17        (WebCore::DOMWrapperWorld::disableOverrideBuiltinsBehavior):
     18        (WebCore::DOMWrapperWorld::shouldDisableOverrideBuiltinsBehavior const):
     19        * bindings/js/JSDOMAbstractOperations.h:
     20        (WebCore::accessVisibleNamedProperty):
     21
    1222018-02-08  Per Arne Vollan  <pvollan@apple.com>
    223
  • trunk/Source/WebCore/bindings/js/DOMWrapperWorld.h

    r228260 r228309  
    4848    bool shadowRootIsAlwaysOpen() const { return m_shadowRootIsAlwaysOpen; }
    4949
     50    void disableOverrideBuiltinsBehavior() { m_shouldDisableOverrideBuiltinsBehavior = true; }
     51    bool shouldDisableOverrideBuiltinsBehavior() const { return m_shouldDisableOverrideBuiltinsBehavior; }
     52
    5053    DOMObjectWrapperMap& wrappers() { return m_wrappers; }
    5154
     
    6467    bool m_isNormal;
    6568    bool m_shadowRootIsAlwaysOpen { false };
     69    bool m_shouldDisableOverrideBuiltinsBehavior { false };
    6670};
    6771
  • trunk/Source/WebCore/bindings/js/JSDOMAbstractOperations.h

    r223746 r228309  
    105105
    106106    // 3. If O implements an interface that has the [OverrideBuiltins] extended attribute, then return true.
    107     if (overrideBuiltins == OverrideBuiltins::Yes)
     107    if (overrideBuiltins == OverrideBuiltins::Yes && !worldForDOMObject(thisObject).shouldDisableOverrideBuiltinsBehavior())
    108108        return result;
    109109
  • trunk/Source/WebKit/ChangeLog

    r228307 r228309  
     12018-02-08  Chris Dumez  <cdumez@apple.com>
     2
     3        There should be a way to disable [OverrideBuiltins] behavior in a given DOMWrapperWorld
     4        https://bugs.webkit.org/show_bug.cgi?id=182524
     5        <rdar://problem/9057327>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Add C API on WKBundleScriptWorld and Cocoa API on WKWebProcessPlugInScriptWorld to
     10        disable the [OverrideBuiltins] behavior on a given script world.
     11
     12        The [OverrideBuiltins] behavior [1] is legacy behavior that is needed for Web compatibility
     13        but allowing the client to disable this behavior in a given world makes development easier
     14        and running injected script on uncontrolled content a lot more reliable.
     15
     16        [1] https://heycam.github.io/webidl/#OverrideBuiltins
     17
     18        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInScriptWorld.h:
     19        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInScriptWorld.mm:
     20        (-[WKWebProcessPlugInScriptWorld disableOverrideBuiltinsBehavior]):
     21        * WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp:
     22        (WKBundleScriptWorldDisableOverrideBuiltinsBehavior):
     23        * WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h:
     24        * WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp:
     25        (WebKit::InjectedBundleScriptWorld::disableOverrideBuiltinsBehavior):
     26        * WebProcess/InjectedBundle/InjectedBundleScriptWorld.h:
     27
    1282018-02-08  Ross Kirsling  <ross.kirsling@sony.com>
    229
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInScriptWorld.h

    r205559 r228309  
    4040- (void)clearWrappers;
    4141- (void)makeAllShadowRootsOpen WK_API_AVAILABLE(macosx(10.12), ios(10.0));
     42- (void)disableOverrideBuiltinsBehavior WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    4243
    4344@end
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInScriptWorld.mm

    r216810 r228309  
    6262}
    6363
     64- (void)disableOverrideBuiltinsBehavior
     65{
     66    _world->disableOverrideBuiltinsBehavior();
     67}
     68
    6469- (NSString *)name
    6570{
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp

    r216810 r228309  
    5959}
    6060
     61void WKBundleScriptWorldDisableOverrideBuiltinsBehavior(WKBundleScriptWorldRef scriptWorldRef)
     62{
     63    toImpl(scriptWorldRef)->disableOverrideBuiltinsBehavior();
     64}
     65
    6166WKStringRef WKBundleScriptWorldCopyName(WKBundleScriptWorldRef scriptWorldRef)
    6267{
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h

    r197172 r228309  
    3939WK_EXPORT void WKBundleScriptWorldClearWrappers(WKBundleScriptWorldRef scriptWorld);
    4040WK_EXPORT void WKBundleScriptWorldMakeAllShadowRootsOpen(WKBundleScriptWorldRef scriptWorld);
     41WK_EXPORT void WKBundleScriptWorldDisableOverrideBuiltinsBehavior(WKBundleScriptWorldRef scriptWorld);
    4142WK_EXPORT WKStringRef WKBundleScriptWorldCopyName(WKBundleScriptWorldRef scriptWorld);
    4243
  • trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp

    r216810 r228309  
    113113}
    114114
     115void InjectedBundleScriptWorld::disableOverrideBuiltinsBehavior()
     116{
     117    m_world->disableOverrideBuiltinsBehavior();
     118}
     119
    115120} // namespace WebKit
  • trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h

    r216810 r228309  
    5252    void clearWrappers();
    5353    void makeAllShadowRootsOpen();
     54    void disableOverrideBuiltinsBehavior();
    5455
    5556    const String& name() const { return m_name; }
  • trunk/Tools/ChangeLog

    r228304 r228309  
     12018-02-08  Chris Dumez  <cdumez@apple.com>
     2
     3        There should be a way to disable [OverrideBuiltins] behavior in a given DOMWrapperWorld
     4        https://bugs.webkit.org/show_bug.cgi?id=182524
     5        <rdar://problem/9057327>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/WebKit/InjectedBundleDisableOverrideBuiltinsBehavior.cpp: Added.
     13        (TestWebKitAPI::runJavaScriptAlert):
     14        (TestWebKitAPI::TEST):
     15        * TestWebKitAPI/Tests/WebKit/InjectedBundleDisableOverrideBuiltinsBehavior_Bundle.cpp: Added.
     16        (TestWebKitAPI::InjectedBundleDisableOverrideBuiltinsBehaviorTest::InjectedBundleDisableOverrideBuiltinsBehaviorTest):
     17        (TestWebKitAPI::InjectedBundleDisableOverrideBuiltinsBehaviorTest::initialize):
     18        * TestWebKitAPI/Tests/WebKit/override-builtins-test.html: Added.
     19
    1202018-02-08  Michael Catanzaro  <mcatanzaro@igalia.com>
    221
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r228253 r228309  
    535535                7CEFA9661AC0B9E200B910FD /* _WKUserContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */; };
    536536                7CFBCAE51743238F00B2BFCF /* WillLoad_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */; };
     537                83148B06202AC6A400BADE99 /* InjectedBundleDisableOverrideBuiltinsBehavior.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83148B05202AC68200BADE99 /* InjectedBundleDisableOverrideBuiltinsBehavior.cpp */; };
     538                83148B07202AC6AD00BADE99 /* InjectedBundleDisableOverrideBuiltinsBehavior_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83148B04202AC68200BADE99 /* InjectedBundleDisableOverrideBuiltinsBehavior_Bundle.cpp */; };
     539                83148B09202AC78D00BADE99 /* override-builtins-test.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 83148B08202AC76800BADE99 /* override-builtins-test.html */; };
    537540                8349D3C21DB96DDE004A9F65 /* ContextMenuDownload.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8349D3C11DB96DDA004A9F65 /* ContextMenuDownload.mm */; };
    538541                8349D3C41DB9728E004A9F65 /* link-with-download-attribute.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 8349D3C31DB9724F004A9F65 /* link-with-download-attribute.html */; };
     
    10211024                                7CCB99231D3B4A46003922F6 /* open-multiple-external-url.html in Copy Resources */,
    10221025                                290A9BB91735F63800D71BBC /* OpenNewWindow.html in Copy Resources */,
     1026                                83148B09202AC78D00BADE99 /* override-builtins-test.html in Copy Resources */,
    10231027                                CEBCA1391E3A807A00C73293 /* page-with-csp-iframe.html in Copy Resources */,
    10241028                                CEBCA1381E3A807A00C73293 /* page-with-csp.html in Copy Resources */,
     
    15231527                7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad_Bundle.cpp; sourceTree = "<group>"; };
    15241528                81B50192140F232300D9EB58 /* StringBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilder.cpp; sourceTree = "<group>"; };
     1529                83148B04202AC68200BADE99 /* InjectedBundleDisableOverrideBuiltinsBehavior_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleDisableOverrideBuiltinsBehavior_Bundle.cpp; sourceTree = "<group>"; };
     1530                83148B05202AC68200BADE99 /* InjectedBundleDisableOverrideBuiltinsBehavior.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleDisableOverrideBuiltinsBehavior.cpp; sourceTree = "<group>"; };
     1531                83148B08202AC76800BADE99 /* override-builtins-test.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "override-builtins-test.html"; sourceTree = "<group>"; };
    15251532                8349D3C11DB96DDA004A9F65 /* ContextMenuDownload.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuDownload.mm; sourceTree = "<group>"; };
    15261533                8349D3C31DB9724F004A9F65 /* link-with-download-attribute.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "link-with-download-attribute.html"; sourceTree = "<group>"; };
     
    25862593                                BC575AAC126E83B9006F0F12 /* InjectedBundleBasic.cpp */,
    25872594                                BC575AAF126E83C8006F0F12 /* InjectedBundleBasic_Bundle.cpp */,
     2595                                83148B05202AC68200BADE99 /* InjectedBundleDisableOverrideBuiltinsBehavior.cpp */,
     2596                                83148B04202AC68200BADE99 /* InjectedBundleDisableOverrideBuiltinsBehavior_Bundle.cpp */,
    25882597                                378E64711632646D00B6C676 /* InjectedBundleFrameHitTest.cpp */,
    25892598                                378E64751632655D00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp */,
     
    28112820                                C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */,
    28122821                                CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */,
     2822                                83148B08202AC76800BADE99 /* override-builtins-test.html */,
    28132823                                0EBBCC651FFF9DCE00FA42AB /* pop-up-check.html */,
    28142824                                F6FDDDD514241C48004F1729 /* push-state.html */,
     
    34773487                                7A95BDE11E9BEC5F00865498 /* InjectedBundleAppleEvent.cpp in Sources */,
    34783488                                7CCE7EFB1A411AE600447C4C /* InjectedBundleBasic.cpp in Sources */,
     3489                                83148B06202AC6A400BADE99 /* InjectedBundleDisableOverrideBuiltinsBehavior.cpp in Sources */,
    34793490                                7CCE7EFC1A411AE600447C4C /* InjectedBundleFrameHitTest.cpp in Sources */,
    34803491                                7CCE7EFD1A411AE600447C4C /* InjectedBundleInitializationUserDataCallbackWins.cpp in Sources */,
     
    37573768                                BC575AA2126E7660006F0F12 /* InjectedBundleController.cpp in Sources */,
    37583769                                1AEDE22613E5E7E700E62FE8 /* InjectedBundleControllerMac.mm in Sources */,
     3770                                83148B07202AC6AD00BADE99 /* InjectedBundleDisableOverrideBuiltinsBehavior_Bundle.cpp in Sources */,
    37593771                                378E64771632655E00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp in Sources */,
    37603772                                F660AA1515A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.