Changeset 270273 in webkit


Ignore:
Timestamp:
Nov 30, 2020 3:43:42 PM (20 months ago)
Author:
Chris Dumez
Message:

sessionStorage should not be cloned when a window is opened with rel=noopener
https://bugs.webkit.org/show_bug.cgi?id=218804
<rdar://problem/71286606>

Reviewed by Alex Christensen.

Source/WebCore:

sessionStorage should not be cloned when a window is opened with rel=noopener, as per:

Both Firefox and Chrome have already implemented this behavior.

  • loader/EmptyFrameLoaderClient.h:
  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):

  • loader/FrameLoaderClient.h:
  • page/Chrome.cpp:

(WebCore::Chrome::createWindow const):

Source/WebKit:

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::dispatchCreatePage):

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

Source/WebKitLegacy/mac:

  • WebCoreSupport/WebFrameLoaderClient.h:
  • WebCoreSupport/WebFrameLoaderClient.mm:

(WebFrameLoaderClient::dispatchCreatePage):

Source/WebKitLegacy/win:

  • WebCoreSupport/WebFrameLoaderClient.cpp:

(WebFrameLoaderClient::dispatchCreatePage):

  • WebCoreSupport/WebFrameLoaderClient.h:

Tools:

Add API test coverage.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKitCocoa/SessionStorage.mm: Added.

(-[SessionStorageUIDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
(-[SessionStorageUIDelegate webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:]):
(createAndInitializeTestWebView):
(checkSessionStorageInNewWindow):
(TEST):

  • TestWebKitAPI/Tests/WebKitCocoa/confirm.html: Added.
Location:
trunk
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r270269 r270273  
     12020-11-30  Chris Dumez  <cdumez@apple.com>
     2
     3        sessionStorage should not be cloned when a window is opened with rel=noopener
     4        https://bugs.webkit.org/show_bug.cgi?id=218804
     5        <rdar://problem/71286606>
     6
     7        Reviewed by Alex Christensen.
     8
     9        sessionStorage should not be cloned when a window is opened with rel=noopener, as per:
     10        - https://html.spec.whatwg.org/multipage/browsers.html#copy-session-storage
     11
     12        Both Firefox and Chrome have already implemented this behavior.
     13
     14        * loader/EmptyFrameLoaderClient.h:
     15        * loader/FrameLoader.cpp:
     16        (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
     17        * loader/FrameLoaderClient.h:
     18        * page/Chrome.cpp:
     19        (WebCore::Chrome::createWindow const):
     20
    1212020-11-30  Alex Christensen  <achristensen@webkit.org>
    222
  • trunk/Source/WebCore/loader/EmptyFrameLoaderClient.h

    r269612 r270273  
    9696    void dispatchDidReachVisuallyNonEmptyState() final { }
    9797
    98     Frame* dispatchCreatePage(const NavigationAction&) final { return nullptr; }
     98    Frame* dispatchCreatePage(const NavigationAction&, NewFrameOpenerPolicy) final { return nullptr; }
    9999    void dispatchShow() final { }
    100100
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r269983 r270273  
    35243524
    35253525    Ref<Frame> frame(m_frame);
    3526     RefPtr<Frame> mainFrame = m_client->dispatchCreatePage(action);
     3526    RefPtr<Frame> mainFrame = m_client->dispatchCreatePage(action, openerPolicy);
    35273527    if (!mainFrame)
    35283528        return;
  • trunk/Source/WebCore/loader/FrameLoaderClient.h

    r269612 r270273  
    188188    virtual void dispatchDidReachVisuallyNonEmptyState() { }
    189189
    190     virtual Frame* dispatchCreatePage(const NavigationAction&) = 0;
     190    virtual Frame* dispatchCreatePage(const NavigationAction&, NewFrameOpenerPolicy) = 0;
    191191    virtual void dispatchShow() = 0;
    192192
  • trunk/Source/WebCore/page/Chrome.cpp

    r269710 r270273  
    194194        return nullptr;
    195195
    196     if (auto* oldSessionStorage = m_page.sessionStorage(false))
    197         newPage->setSessionStorage(oldSessionStorage->copy(*newPage));
     196    if (!features.noopener && !features.noreferrer) {
     197        if (auto* oldSessionStorage = m_page.sessionStorage(false))
     198            newPage->setSessionStorage(oldSessionStorage->copy(*newPage));
     199    }
    198200
    199201    return newPage;
  • trunk/Source/WebKit/ChangeLog

    r270256 r270273  
     12020-11-30  Chris Dumez  <cdumez@apple.com>
     2
     3        sessionStorage should not be cloned when a window is opened with rel=noopener
     4        https://bugs.webkit.org/show_bug.cgi?id=218804
     5        <rdar://problem/71286606>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     10        (WebKit::WebFrameLoaderClient::dispatchCreatePage):
     11        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
     12
    1132020-11-30  Youenn Fablet  <youenn@apple.com>
    214
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r269712 r270273  
    785785}
    786786
    787 Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction& navigationAction)
     787Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction& navigationAction, NewFrameOpenerPolicy newFrameOpenerPolicy)
    788788{
    789789    WebPage* webPage = m_frame->page();
     
    792792
    793793    // Just call through to the chrome client.
    794     Page* newPage = webPage->corePage()->chrome().createWindow(*m_frame->coreFrame(), { }, navigationAction);
     794    WindowFeatures windowFeatures;
     795    windowFeatures.noopener = newFrameOpenerPolicy == NewFrameOpenerPolicy::Suppress;
     796    Page* newPage = webPage->corePage()->chrome().createWindow(*m_frame->coreFrame(), windowFeatures, navigationAction);
    795797    if (!newPage)
    796798        return nullptr;
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h

    r269612 r270273  
    127127    void dispatchDidLayout() final;
    128128
    129     WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&) final;
     129    WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&, WebCore::NewFrameOpenerPolicy) final;
    130130    void dispatchShow() final;
    131131   
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r270152 r270273  
     12020-11-30  Chris Dumez  <cdumez@apple.com>
     2
     3        sessionStorage should not be cloned when a window is opened with rel=noopener
     4        https://bugs.webkit.org/show_bug.cgi?id=218804
     5        <rdar://problem/71286606>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * WebCoreSupport/WebFrameLoaderClient.h:
     10        * WebCoreSupport/WebFrameLoaderClient.mm:
     11        (WebFrameLoaderClient::dispatchCreatePage):
     12
    1132020-11-21  Simon Fraser  <simon.fraser@apple.com>
    214
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h

    r269612 r270273  
    123123    void dispatchDidReachLayoutMilestone(OptionSet<WebCore::LayoutMilestone>) final;
    124124
    125     WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&) final;
     125    WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&, WebCore::NewFrameOpenerPolicy) final;
    126126    void dispatchShow() final;
    127127
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r269612 r270273  
    834834}
    835835
    836 WebCore::Frame* WebFrameLoaderClient::dispatchCreatePage(const WebCore::NavigationAction&)
     836WebCore::Frame* WebFrameLoaderClient::dispatchCreatePage(const WebCore::NavigationAction&, WebCore::NewFrameOpenerPolicy)
    837837{
    838838    WebView *currentWebView = getWebView(m_webFrame.get());
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r270071 r270273  
     12020-11-30  Chris Dumez  <cdumez@apple.com>
     2
     3        sessionStorage should not be cloned when a window is opened with rel=noopener
     4        https://bugs.webkit.org/show_bug.cgi?id=218804
     5        <rdar://problem/71286606>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * WebCoreSupport/WebFrameLoaderClient.cpp:
     10        (WebFrameLoaderClient::dispatchCreatePage):
     11        * WebCoreSupport/WebFrameLoaderClient.h:
     12
    1132020-11-19  Fujii Hironori  <Hironori.Fujii@sony.com>
    214
  • trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp

    r269612 r270273  
    497497}
    498498
    499 Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction& navigationAction)
     499Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction& navigationAction, NewFrameOpenerPolicy)
    500500{
    501501    WebView* webView = m_webFrame->webView();
  • trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h

    r269612 r270273  
    112112    bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length) override;
    113113
    114     WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&) override;
     114    WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&, WebCore::NewFrameOpenerPolicy) override;
    115115    void dispatchShow() override;
    116116
  • trunk/Tools/ChangeLog

    r270268 r270273  
     12020-11-30  Chris Dumez  <cdumez@apple.com>
     2
     3        sessionStorage should not be cloned when a window is opened with rel=noopener
     4        https://bugs.webkit.org/show_bug.cgi?id=218804
     5        <rdar://problem/71286606>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/WebKitCocoa/SessionStorage.mm: Added.
     13        (-[SessionStorageUIDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
     14        (-[SessionStorageUIDelegate webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:]):
     15        (createAndInitializeTestWebView):
     16        (checkSessionStorageInNewWindow):
     17        (TEST):
     18        * TestWebKitAPI/Tests/WebKitCocoa/confirm.html: Added.
     19
    1202020-11-30  Jonathan Bedard  <jbedard@apple.com>
    221
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r270002 r270273  
    260260                468F2F942368DAF100F4B864 /* window-open-then-document-open.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 468F2F932368DAA700F4B864 /* window-open-then-document-open.html */; };
    261261                46918EFC2237283C00468DFE /* DeviceOrientation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46918EFB2237283500468DFE /* DeviceOrientation.mm */; };
     262                46A46A1A2575645600A1B118 /* SessionStorage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A46A192575645600A1B118 /* SessionStorage.mm */; };
    262263                46A911592108E6780078D40D /* CustomUserAgent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A911582108E66B0078D40D /* CustomUserAgent.mm */; };
    263264                46AE5A3720F9066D00E0873E /* SimpleServiceWorkerRegistrations-4.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4656A75720F9054F0002E21F /* SimpleServiceWorkerRegistrations-4.sqlite3 */; };
     265                46C1EA9825758820005E409E /* alert.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 46C1EA9725758805005E409E /* alert.html */; };
    264266                46C3AEB323D0E529001B0680 /* beforeunload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 46C3AEB223D0E50F001B0680 /* beforeunload.html */; };
    265267                46C519DA1D355AB200DAA51A /* LocalStorageNullEntries.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46C519D81D355A7300DAA51A /* LocalStorageNullEntries.mm */; };
     
    12951297                                725C3EF322058A5B007C36FC /* AdditionalSupportedImageTypes.html in Copy Resources */,
    12961298                                1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */,
     1299                                46C1EA9825758820005E409E /* alert.html in Copy Resources */,
    12971300                                1A63479F183D72A4005B1707 /* all-content-in-one-iframe.html in Copy Resources */,
    12981301                                C25CCA0D1E5141840026CB8A /* AllAhem.svg in Copy Resources */,
     
    19911994                468F2F932368DAA700F4B864 /* window-open-then-document-open.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "window-open-then-document-open.html"; sourceTree = "<group>"; };
    19921995                46918EFB2237283500468DFE /* DeviceOrientation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceOrientation.mm; sourceTree = "<group>"; };
     1996                46A46A192575645600A1B118 /* SessionStorage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SessionStorage.mm; sourceTree = "<group>"; };
    19931997                46A911582108E66B0078D40D /* CustomUserAgent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CustomUserAgent.mm; sourceTree = "<group>"; };
     1998                46C1EA9725758805005E409E /* alert.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = alert.html; sourceTree = "<group>"; };
    19941999                46C3AEB223D0E50F001B0680 /* beforeunload.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = beforeunload.html; sourceTree = "<group>"; };
    19952000                46C519D81D355A7300DAA51A /* LocalStorageNullEntries.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageNullEntries.mm; sourceTree = "<group>"; };
     
    33863391                                51EB12931FDF050500A5A1BD /* ServiceWorkerBasic.mm */,
    33873392                                5C683471235ACC7C0041E6B1 /* ServiceWorkerTCPServer.h */,
     3393                                46A46A192575645600A1B118 /* SessionStorage.mm */,
    33883394                                5CCB10DF2134579D00AC5AF0 /* ShouldGoToBackForwardListItem.mm */,
    33893395                                37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */,
     
    37183724                                55A817FD218101DF0004A39A /* 400x400-green.png */,
    37193725                                F4CFCDD9249FC9D900527482 /* Ahem.ttf */,
     3726                                46C1EA9725758805005E409E /* alert.html */,
    37203727                                C25CCA0C1E5140E50026CB8A /* AllAhem.svg */,
    37213728                                F4A9202E1FEE34C800F59590 /* apple-data-url.html */,
     
    54545461                                5769C50B1D9B0002000847FB /* SerializedCryptoKeyWrap.mm in Sources */,
    54555462                                51EB12941FDF052500A5A1BD /* ServiceWorkerBasic.mm in Sources */,
     5463                                46A46A1A2575645600A1B118 /* SessionStorage.mm in Sources */,
    54565464                                7CCE7ECB1A411A7E00447C4C /* SetAndUpdateCacheModel.mm in Sources */,
    54575465                                7CCE7ECC1A411A7E00447C4C /* SetDocumentURI.mm in Sources */,
  • trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.h

    r266654 r270273  
    2828@interface TestUIDelegate : NSObject <WKUIDelegate>
    2929
     30@property (nonatomic, copy) WKWebView* (^createWebViewWithConfiguration)(WKWebViewConfiguration *, WKNavigationAction *, WKWindowFeatures *);
    3031@property (nonatomic, copy) void (^runJavaScriptAlertPanelWithMessage)(WKWebView *, NSString *, WKFrameInfo *, void (^)(void));
    3132#if PLATFORM(MAC)
  • trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.mm

    r266654 r270273  
    3232
    3333@implementation TestUIDelegate
     34
     35- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
     36{
     37    if (_createWebViewWithConfiguration)
     38        return _createWebViewWithConfiguration(configuration, navigationAction, windowFeatures);
     39    return nil;
     40}
    3441
    3542- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
Note: See TracChangeset for help on using the changeset viewer.