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

Changeset 273817 in webkit


Ignore:
Timestamp:
Mar 3, 2021, 8:55:05 AM (6 years ago)
Author:
youenn@apple.com
Message:

WebKitLegacy needs to keep JSDOMWindow even though it is used while its origin is not set
​https://bugs.webkit.org/show_bug.cgi?id=222589
<rdar://problem/74258258>

Reviewed by Geoffrey Garen.

Source/WebCore:

Use the new flag to allow reuse of JSDOMWindow objects even though they are created at a time where its SecurityOrigin is not set yet.
This allows keeping WebKitLegacy existing functionality.

Covered by API test.

  • bindings/js/JSWindowProxy.cpp:

(WebCore::JSWindowProxy::setWindow):

Source/WTF:

  • Scripts/Preferences/WebPreferencesInternal.yaml:

Introduce a flag, on for WebKit and off for WebKitLegacy.

Tools:

  • TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r273773 r273817  
     12021-03-03  Youenn Fablet  <youenn@apple.com>
     2
     3        WebKitLegacy needs to keep JSDOMWindow even though it is used while its origin is not set
     4        https://bugs.webkit.org/show_bug.cgi?id=222589
     5        <rdar://problem/74258258>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        * Scripts/Preferences/WebPreferencesInternal.yaml:
     10        Introduce a flag, on for WebKit and off for WebKitLegacy.
     11
    1122021-03-02  Simon Fraser  <simon.fraser@apple.com>
    213
  • trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml

    r273773 r273817  
    886886      default: true
    887887
     888WindowObjectAlwaysInitializedWithSecurityOriginEnabled:
     889  type: bool
     890  humanReadableName: "Ensure Window object is initialized with a security origin"
     891  humanReadableDescription: "Ensure Window object is initialized with a security origin"
     892  defaultValue:
     893    WebKitLegacy:
     894      default: false
     895    WebKit:
     896      default: true
     897    WebCore:
     898      default: true
     899
    888900ZoomOnDoubleTapWhenRoot:
    889901  type: bool
  • trunk/Source/WebCore/ChangeLog

    r273815 r273817  
     12021-03-03  Youenn Fablet  <youenn@apple.com>
     2
     3        WebKitLegacy needs to keep JSDOMWindow even though it is used while its origin is not set
     4        https://bugs.webkit.org/show_bug.cgi?id=222589
     5        <rdar://problem/74258258>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        Use the new flag to allow reuse of JSDOMWindow objects even though they are created at a time where its SecurityOrigin is not set yet.
     10        This allows keeping WebKitLegacy existing functionality.
     11
     12        Covered by API test.
     13
     14        * bindings/js/JSWindowProxy.cpp:
     15        (WebCore::JSWindowProxy::setWindow):
     16
    1172021-03-03  Zalan Bujtas  <zalan@apple.com>
    218
  • trunk/Source/WebCore/bindings/js/JSWindowProxy.cpp

    r271642 r273817  
    107107        auto& windowStructure = *JSDOMWindow::createStructure(vm, nullptr, prototype);
    108108        window = JSDOMWindow::create(vm, &windowStructure, localWindow, this);
    109         if (!localWindow.document()->haveInitializedSecurityOrigin())
     109        if (!localWindow.document()->haveInitializedSecurityOrigin() && localWindow.document()->settings().windowObjectAlwaysInitializedWithSecurityOriginEnabled())
    110110            localWindow.setAsWrappedWithoutInitializedSecurityOrigin();
    111111    }
  • trunk/Tools/ChangeLog

    r273814 r273817  
     12021-03-03  Youenn Fablet  <youenn@apple.com>
     2
     3        WebKitLegacy needs to keep JSDOMWindow even though it is used while its origin is not set
     4        https://bugs.webkit.org/show_bug.cgi?id=222589
     5        <rdar://problem/74258258>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        * TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm:
     10        (TestWebKitAPI::TEST):
     11
    1122021-03-03  Don Olmstead  <don.olmstead@sony.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/mac/JSWrapperForNodeInWebFrame.mm

    r236032 r273817  
    2727#import "PlatformUtilities.h"
    2828#import <WebKit/WebFramePrivate.h>
     29#import <WebKit/WebPreferencesPrivate.h>
    2930#import <WebKit/WebScriptWorld.h>
    3031#import <JavaScriptCore/JSContextRef.h>
    … …  
    9697}
    9798
     99TEST(WebKitLegacy, JSDOMWindowWrapperBeforeOriginInitialization)
     100{
     101    auto webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
     102    auto frameLoadDelegate = adoptNS([[JSWrapperForNodeFrameLoadDelegate alloc] init]);
     103
     104    webView.get().frameLoadDelegate = frameLoadDelegate.get();
     105    auto *mainFrame = webView.get().mainFrame;
     106    [mainFrame loadHTMLString:@"<div id=\"target\"</div>" baseURL:[NSURL URLWithString:@"http://localhost"]];
     107
     108    auto *normalWorld = [WebScriptWorld standardWorld];
     109    auto normalCtx = [mainFrame _globalContextForScriptWorld:normalWorld];
     110
     111    [mainFrame _stringByEvaluatingJavaScriptFromString:@"window.caches = 1" withGlobalObject:JSContextGetGlobalObject(normalCtx) inScriptWorld:normalWorld];
     112
     113    auto result = [mainFrame _stringByEvaluatingJavaScriptFromString:@"window.caches" withGlobalObject:JSContextGetGlobalObject(normalCtx) inScriptWorld:normalWorld];
     114    EXPECT_WK_STREQ(result, @"1");
     115
     116    Util::run(&didFinishLoad);
     117
     118    result = [mainFrame _stringByEvaluatingJavaScriptFromString:@"window.caches" withGlobalObject:JSContextGetGlobalObject(normalCtx) inScriptWorld:normalWorld];
     119    EXPECT_WK_STREQ(result, @"1");
     120}
     121
    98122} // namespace TestWebKitAPI
Note: See TracChangeset for help on using the changeset viewer.