WebKit Bugzilla
Attachment 338788 Details for
Bug 184996
: Add initial support for 'Cross-Origin-Options' HTTP response header
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP patch
184996_XDisownOpener_support_wip.patch (text/plain), 27.36 KB, created by
Chris Dumez
on 2018-04-25 13:48:30 PDT
(
hide
)
Description:
WIP patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2018-04-25 13:48:30 PDT
Size:
27.36 KB
patch
obsolete
>diff --git a/LayoutTests/http/tests/navigation/disown-opener-header-cross-origin-expected.txt b/LayoutTests/http/tests/navigation/disown-opener-header-cross-origin-expected.txt >new file mode 100644 >index 00000000000..0de87ff7140 >--- /dev/null >+++ b/LayoutTests/http/tests/navigation/disown-opener-header-cross-origin-expected.txt >@@ -0,0 +1,34 @@ >+Basic testing for X-Disown-Opener header in the cross origin case. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS w.location.href is "about:blank" >+PASS w.name threw exception SecurityError: The operation is insecure.. >+PASS w.document threw exception SecurityError: The operation is insecure.. >+PASS w.history threw exception SecurityError: The operation is insecure.. >+PASS w.locationbar threw exception SecurityError: The operation is insecure.. >+PASS w.status threw exception SecurityError: The operation is insecure.. >+PASS w.frameElement threw exception SecurityError: The operation is insecure.. >+PASS w.navigator threw exception SecurityError: The operation is insecure.. >+PASS w.alert threw exception SecurityError: The operation is insecure.. >+PASS w.localStorage threw exception SecurityError: The operation is insecure.. >+PASS w.sessionStorage threw exception SecurityError: The operation is insecure.. >+PASS w.event threw exception SecurityError: The operation is insecure.. >+PASS w.closed is true >+PASS w.length is 0 >+PASS w.frames is null >+PASS w.location is null >+PASS w.opener is null >+PASS w.parent is null >+PASS w.self is null >+PASS w.top is null >+PASS w.window is null >+PASS w.focus() did not throw exception. >+PASS w.blur() did not throw exception. >+PASS w.close() did not throw exception. >+PASS w.postMessage('', '*') did not throw exception. >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/http/tests/navigation/disown-opener-header-cross-origin.html b/LayoutTests/http/tests/navigation/disown-opener-header-cross-origin.html >new file mode 100644 >index 00000000000..a5b57e33795 >--- /dev/null >+++ b/LayoutTests/http/tests/navigation/disown-opener-header-cross-origin.html >@@ -0,0 +1,58 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ enableProcessSwapOnNavigation=true ] --> >+<html> >+<body> >+<script src="/js-test-resources/js-test.js"></script> >+<script> >+description("Basic testing for X-Disown-Opener header in the cross origin case."); >+jsTestIsAsync = true; >+ >+if (window.testRunner) >+ testRunner.setCanOpenWindows(true); >+ >+function wasWindowNavigatedCrossOrigin() >+{ >+ try { >+ w.name; >+ return false; >+ } catch (e) { >+ return true; >+ } >+} >+ >+function runTest() { >+ forbiddenProperties = ["name", "document", "history", "locationbar", "status", "frameElement", "navigator", "alert", "localStorage", "sessionStorage", "event"]; >+ for (forbiddenProperty of forbiddenProperties) >+ shouldThrowErrorName("w." + forbiddenProperty, "SecurityError"); >+ >+ // The window should look as if it is frameless (i.e. as if the tab was closed). >+ shouldBeTrue("w.closed"); >+ shouldBe("w.length", "0"); >+ shouldBeNull("w.frames"); >+ shouldBeNull("w.location"); >+ shouldBeNull("w.opener"); >+ shouldBeNull("w.parent"); >+ shouldBeNull("w.self"); >+ shouldBeNull("w.top"); >+ shouldBeNull("w.window"); >+ shouldNotThrow("w.focus()"); >+ shouldNotThrow("w.blur()"); >+ shouldNotThrow("w.close()"); >+ shouldNotThrow("w.postMessage('', '*')"); >+ >+ finishJSTest(); >+} >+ >+onload = function() { >+ w = window.open("http://localhost:8000/navigation/resources/disown-opener.php"); >+ shouldBeEqualToString("w.location.href", "about:blank"); >+ >+ handle = setInterval(function() { >+ if (wasWindowNavigatedCrossOrigin()) { >+ clearInterval(handle); >+ runTest(); >+ } >+ }, 5); >+} >+</script> >+</body> >+</html> >diff --git a/LayoutTests/http/tests/navigation/disown-opener-header-same-origin-expected.txt b/LayoutTests/http/tests/navigation/disown-opener-header-same-origin-expected.txt >new file mode 100644 >index 00000000000..a35ba863e78 >--- /dev/null >+++ b/LayoutTests/http/tests/navigation/disown-opener-header-same-origin-expected.txt >@@ -0,0 +1,34 @@ >+Basic testing for X-Disown-Opener header in the same origin case. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS w.location.href is "about:blank" >+PASS w.name threw exception SecurityError: The operation is insecure.. >+PASS w.document threw exception SecurityError: The operation is insecure.. >+PASS w.history threw exception SecurityError: The operation is insecure.. >+PASS w.locationbar threw exception SecurityError: The operation is insecure.. >+PASS w.status threw exception SecurityError: The operation is insecure.. >+PASS w.frameElement threw exception SecurityError: The operation is insecure.. >+PASS w.navigator threw exception SecurityError: The operation is insecure.. >+PASS w.alert threw exception SecurityError: The operation is insecure.. >+PASS w.localStorage threw exception SecurityError: The operation is insecure.. >+PASS w.sessionStorage threw exception SecurityError: The operation is insecure.. >+PASS w.event threw exception SecurityError: The operation is insecure.. >+PASS w.closed is true >+PASS w.length is 0 >+PASS w.frames is null >+PASS w.location is null >+PASS w.opener is null >+PASS w.parent is null >+PASS w.self is null >+PASS w.top is null >+PASS w.window is null >+PASS w.focus() did not throw exception. >+PASS w.blur() did not throw exception. >+PASS w.close() did not throw exception. >+PASS w.postMessage('', '*') did not throw exception. >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/http/tests/navigation/disown-opener-header-same-origin.html b/LayoutTests/http/tests/navigation/disown-opener-header-same-origin.html >new file mode 100644 >index 00000000000..1cdcc440383 >--- /dev/null >+++ b/LayoutTests/http/tests/navigation/disown-opener-header-same-origin.html >@@ -0,0 +1,58 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ enableProcessSwapOnNavigation=true ] --> >+<html> >+<body> >+<script src="/js-test-resources/js-test.js"></script> >+<script> >+description("Basic testing for X-Disown-Opener header in the same origin case."); >+jsTestIsAsync = true; >+ >+if (window.testRunner) >+ testRunner.setCanOpenWindows(true); >+ >+function wasWindowNavigatedCrossOrigin() >+{ >+ try { >+ w.name; >+ return false; >+ } catch (e) { >+ return true; >+ } >+} >+ >+function runTest() { >+ forbiddenProperties = ["name", "document", "history", "locationbar", "status", "frameElement", "navigator", "alert", "localStorage", "sessionStorage", "event"]; >+ for (forbiddenProperty of forbiddenProperties) >+ shouldThrowErrorName("w." + forbiddenProperty, "SecurityError"); >+ >+ // The window should look as if it is frameless (i.e. as if the tab was closed). >+ shouldBeTrue("w.closed"); >+ shouldBe("w.length", "0"); >+ shouldBeNull("w.frames"); >+ shouldBeNull("w.location"); >+ shouldBeNull("w.opener"); >+ shouldBeNull("w.parent"); >+ shouldBeNull("w.self"); >+ shouldBeNull("w.top"); >+ shouldBeNull("w.window"); >+ shouldNotThrow("w.focus()"); >+ shouldNotThrow("w.blur()"); >+ shouldNotThrow("w.close()"); >+ shouldNotThrow("w.postMessage('', '*')"); >+ >+ finishJSTest(); >+} >+ >+onload = function() { >+ w = window.open("resources/disown-opener.php"); >+ shouldBeEqualToString("w.location.href", "about:blank"); >+ >+ handle = setInterval(function() { >+ if (wasWindowNavigatedCrossOrigin()) { >+ clearInterval(handle); >+ runTest(); >+ } >+ }, 5); >+} >+</script> >+</body> >+</html> >diff --git a/LayoutTests/http/tests/navigation/process-swap-window-open.html b/LayoutTests/http/tests/navigation/process-swap-window-open.html >index bc40e450909..fd6bbd143ee 100644 >--- a/LayoutTests/http/tests/navigation/process-swap-window-open.html >+++ b/LayoutTests/http/tests/navigation/process-swap-window-open.html >@@ -1,4 +1,4 @@ >-<!DOCTYPE html><!-- webkit-test-runner [ enableProcessSwapOnNavigation=true ] --> >+<!DOCTYPE html><!-- webkit-test-runner [ enableProcessSwapOnWindowOpenWithOpener=true ] --> > <html> > <body> > <script src="/js-test-resources/js-test.js"></script> >diff --git a/LayoutTests/http/tests/navigation/resources/disown-opener.php b/LayoutTests/http/tests/navigation/resources/disown-opener.php >new file mode 100644 >index 00000000000..6d1eb046fce >--- /dev/null >+++ b/LayoutTests/http/tests/navigation/resources/disown-opener.php >@@ -0,0 +1,5 @@ >+<?php >+header("HTTP/1.1 200"); >+header("X-Disown-Opener: 1"); >+?> >+TEST >diff --git a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp >index 90214ce67ec..281ea4e7004 100644 >--- a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp >+++ b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp >@@ -100,15 +100,15 @@ bool jsDOMWindowGetOwnPropertySlotRestrictedAccess(JSDOMGlobalObject* thisObject > return true; > } > if (propertyName == builtinNames.closePublicName()) { >- slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionClose, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionClose, 0>); >+ slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsRemoteDOMWindowInstanceFunctionClose, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionClose, 0>); > return true; > } > if (propertyName == builtinNames.focusPublicName()) { >- slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionFocus, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionFocus, 0>); >+ slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsRemoteDOMWindowInstanceFunctionFocus, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionFocus, 0>); > return true; > } > if (propertyName == builtinNames.postMessagePublicName()) { >- slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionPostMessage, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionPostMessage, 2>); >+ slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsRemoteDOMWindowInstanceFunctionPostMessage, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionPostMessage, 2>); > return true; > } > >diff --git a/Source/WebCore/bindings/js/WindowProxy.cpp b/Source/WebCore/bindings/js/WindowProxy.cpp >index 8e8f51353ed..5d386c7524c 100644 >--- a/Source/WebCore/bindings/js/WindowProxy.cpp >+++ b/Source/WebCore/bindings/js/WindowProxy.cpp >@@ -53,6 +53,11 @@ WindowProxy::WindowProxy(AbstractFrame& frame) > } > > WindowProxy::~WindowProxy() >+{ >+ clearJSWindowProxies(); >+} >+ >+void WindowProxy::clearJSWindowProxies() > { > // It's likely that destroying windowProxies will create a lot of garbage. > if (!m_jsWindowProxies.isEmpty()) { >diff --git a/Source/WebCore/bindings/js/WindowProxy.h b/Source/WebCore/bindings/js/WindowProxy.h >index 77722983b0a..864d289b3cf 100644 >--- a/Source/WebCore/bindings/js/WindowProxy.h >+++ b/Source/WebCore/bindings/js/WindowProxy.h >@@ -80,6 +80,8 @@ public: > WEBCORE_EXPORT void ref(); > WEBCORE_EXPORT void deref(); > >+ void clearJSWindowProxies(); >+ > private: > JSWindowProxy& createJSWindowProxy(DOMWrapperWorld&); > WEBCORE_EXPORT JSWindowProxy& createJSWindowProxyWithInitializedScript(DOMWrapperWorld&); >diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp >index 340d092a4be..a151f0f176f 100644 >--- a/Source/WebCore/loader/DocumentLoader.cpp >+++ b/Source/WebCore/loader/DocumentLoader.cpp >@@ -66,6 +66,7 @@ > #include "Page.h" > #include "PolicyChecker.h" > #include "ProgressTracker.h" >+#include "RemoteDOMWindow.h" > #include "ResourceHandle.h" > #include "ResourceLoadObserver.h" > #include "SWClientConnection.h" >@@ -516,6 +517,15 @@ static inline bool areRegistrationsEqual(const std::optional<ServiceWorkerRegist > > void DocumentLoader::redirectReceived(CachedResource& resource, ResourceRequest&& request, const ResourceResponse& redirectResponse, CompletionHandler<void(ResourceRequest&&)>&& completionHandler) > { >+ if (!redirectResponse.httpHeaderField(HTTPHeaderName::XDisownOpener).isNull()) { >+ // Completely sever the link between the window and its opener by clearing the window's opener and updating existing JSWindowProxy objects to >+ // stop proxing to this window, and instead proxy to a dummy frameless Window. >+ m_frame->loader().setOpener(nullptr); >+ auto framelessWindow = RemoteDOMWindow::create(nullptr, GlobalWindowIdentifier { Process::identifier(), generateObjectIdentifier<WindowIdentifierType>() }); >+ m_frame->windowProxy().setDOMWindow(framelessWindow.ptr()); >+ m_frame->windowProxy().clearJSWindowProxies(); >+ } >+ > ASSERT_UNUSED(resource, &resource == m_mainResource); > #if ENABLE(SERVICE_WORKER) > bool isRedirectionFromServiceWorker = redirectResponse.source() == ResourceResponse::Source::ServiceWorker; >diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp >index 97cf0b68e11..a907f64c5d6 100644 >--- a/Source/WebCore/loader/FrameLoader.cpp >+++ b/Source/WebCore/loader/FrameLoader.cpp >@@ -1309,12 +1309,6 @@ void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& ref > > NavigationAction action { frameLoadRequest.requester(), request, frameLoadRequest.initiatedByMainFrame(), newLoadType, isFormSubmission, event, frameLoadRequest.shouldOpenExternalURLsPolicy(), frameLoadRequest.downloadAttribute() }; > action.setIsCrossOriginWindowOpenNavigation(frameLoadRequest.isCrossOriginWindowOpenNavigation()); >- if (auto* opener = this->opener()) { >- auto pageID = opener->loader().client().pageID(); >- auto frameID = opener->loader().client().frameID(); >- if (pageID && frameID) >- action.setOpener(std::make_pair(*pageID, *frameID)); >- } > > if (!targetFrame && !frameName.isEmpty()) { > action = action.copyWithShouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicyToApply(m_frame, frameLoadRequest)); >diff --git a/Source/WebCore/loader/PolicyChecker.cpp b/Source/WebCore/loader/PolicyChecker.cpp >index fc241949838..33c4973f8bd 100644 >--- a/Source/WebCore/loader/PolicyChecker.cpp >+++ b/Source/WebCore/loader/PolicyChecker.cpp >@@ -88,6 +88,13 @@ void PolicyChecker::checkNavigationPolicy(ResourceRequest&& request, bool didRec > action = NavigationAction { *m_frame.document(), request, InitiatedByMainFrame::Unknown, NavigationType::Other, loader->shouldOpenExternalURLsPolicyToPropagate() }; > loader->setTriggeringAction(action); > } >+ action.setOpener(std::nullopt); >+ if (auto* opener = m_frame.loader().opener()) { >+ auto pageID = opener->loader().client().pageID(); >+ auto frameID = opener->loader().client().frameID(); >+ if (pageID && frameID) >+ action.setOpener(std::make_pair(*pageID, *frameID)); >+ } > > // Don't ask more than once for the same request or if we are loading an empty URL. > // This avoids confusion on the part of the client. >diff --git a/Source/WebCore/page/RemoteDOMWindow.cpp b/Source/WebCore/page/RemoteDOMWindow.cpp >index 825348d3548..995debb594e 100644 >--- a/Source/WebCore/page/RemoteDOMWindow.cpp >+++ b/Source/WebCore/page/RemoteDOMWindow.cpp >@@ -32,11 +32,12 @@ > > namespace WebCore { > >-RemoteDOMWindow::RemoteDOMWindow(Ref<RemoteFrame>&& frame, GlobalWindowIdentifier&& identifier) >+RemoteDOMWindow::RemoteDOMWindow(RefPtr<RemoteFrame>&& frame, GlobalWindowIdentifier&& identifier) > : AbstractDOMWindow(WTFMove(identifier)) > , m_frame(WTFMove(frame)) > { >- m_frame->setWindow(this); >+ if (m_frame) >+ m_frame->setWindow(this); > } > > RemoteDOMWindow::~RemoteDOMWindow() >@@ -121,6 +122,9 @@ ExceptionOr<void> RemoteDOMWindow::postMessage(JSC::ExecState&, DOMWindow& incum > UNUSED_PARAM(message); > UNUSED_PARAM(targetOrigin); > >+ if (!m_frame) >+ return { }; >+ > // FIXME: Implemented this. > return Exception { NotSupportedError }; > } >diff --git a/Source/WebCore/page/RemoteDOMWindow.h b/Source/WebCore/page/RemoteDOMWindow.h >index bd0c052ba47..0005dc15a5f 100644 >--- a/Source/WebCore/page/RemoteDOMWindow.h >+++ b/Source/WebCore/page/RemoteDOMWindow.h >@@ -44,7 +44,7 @@ class Location; > > class RemoteDOMWindow final : public AbstractDOMWindow { > public: >- static Ref<RemoteDOMWindow> create(Ref<RemoteFrame>&& frame, GlobalWindowIdentifier&& identifier) >+ static Ref<RemoteDOMWindow> create(RefPtr<RemoteFrame>&& frame, GlobalWindowIdentifier&& identifier) > { > return adoptRef(*new RemoteDOMWindow(WTFMove(frame), WTFMove(identifier))); > } >@@ -68,7 +68,7 @@ public: > ExceptionOr<void> postMessage(JSC::ExecState&, DOMWindow& incumbentWindow, JSC::JSValue message, const String& targetOrigin, Vector<JSC::Strong<JSC::JSObject>>&&); > > private: >- WEBCORE_EXPORT RemoteDOMWindow(Ref<RemoteFrame>&&, GlobalWindowIdentifier&&); >+ WEBCORE_EXPORT RemoteDOMWindow(RefPtr<RemoteFrame>&&, GlobalWindowIdentifier&&); > > bool isRemoteDOMWindow() const final { return true; } > bool isLocalDOMWindow() const final { return false; } >diff --git a/Source/WebCore/platform/network/HTTPHeaderNames.in b/Source/WebCore/platform/network/HTTPHeaderNames.in >index 3e192856e9e..8e7a46654f5 100644 >--- a/Source/WebCore/platform/network/HTTPHeaderNames.in >+++ b/Source/WebCore/platform/network/HTTPHeaderNames.in >@@ -97,6 +97,7 @@ User-Agent > Vary > Via > X-Content-Type-Options >+X-Disown-Opener > X-DNS-Prefetch-Control > X-Frame-Options > X-SourceMap >diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp b/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp >index 07e8e71dc3e..f65675156ff 100644 >--- a/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp >@@ -101,6 +101,8 @@ void NetworkResourceLoadParameters::encode(IPC::Encoder& encoder) const > if (shouldEnableFromOriginResponseHeader) > encoder << frameAncestorOrigins; > >+ encoder << hasOpener; >+ > #if ENABLE(CONTENT_EXTENSIONS) > encoder << mainDocumentURL; > encoder << userContentControllerIdentifier; >@@ -215,6 +217,9 @@ bool NetworkResourceLoadParameters::decode(IPC::Decoder& decoder, NetworkResourc > return false; > } > >+ if (!decoder.decode(result.hasOpener)) >+ return false; >+ > #if ENABLE(CONTENT_EXTENSIONS) > if (!decoder.decode(result.mainDocumentURL)) > return false; >diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h b/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h >index 75a917e727d..cc6ba07abe0 100644 >--- a/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h >+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h >@@ -63,6 +63,7 @@ public: > WebCore::PreflightPolicy preflightPolicy { WebCore::PreflightPolicy::Consider }; > bool shouldEnableFromOriginResponseHeader { false }; > Vector<RefPtr<WebCore::SecurityOrigin>> frameAncestorOrigins; >+ bool hasOpener { false }; > > #if ENABLE(CONTENT_EXTENSIONS) > WebCore::URL mainDocumentURL; >diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp b/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >index c23eca442a8..f5e6b395847 100644 >--- a/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >@@ -430,6 +430,23 @@ auto NetworkResourceLoader::didReceiveResponse(ResourceResponse&& receivedRespon > } else > m_cacheEntryForValidation = nullptr; > } >+ >+ if (isMainResource() && !m_response.httpHeaderField(HTTPHeaderName::XDisownOpener).isNull() && m_parameters.hasOpener) { >+ ASSERT(!isSynchronous()); >+ >+ // Synthesize a redirect to cause another decidePolicyForNavigationAction and a potential process swap. >+ ResourceResponse synthesizedRedirect; >+ synthesizedRedirect.setURL(m_response.url()); >+ synthesizedRedirect.setHTTPHeaderField(HTTPHeaderName::Location, m_response.url()); >+ synthesizedRedirect.setHTTPStatusCode(302); >+ synthesizedRedirect.setHTTPHeaderField(HTTPHeaderName::CacheControl, ASCIILiteral("no-store")); >+ synthesizedRedirect.setHTTPHeaderField(HTTPHeaderName::XDisownOpener, emptyString()); >+ >+ m_shouldSendResponseOnContinueWillSendRequest = true; >+ send(Messages::WebResourceLoader::WillSendRequest(originalRequest(), synthesizedRedirect)); >+ return ShouldContinueDidReceiveResponse::No; >+ } >+ > bool shouldSendDidReceiveResponse = !m_cacheEntryForValidation; > > bool shouldWaitContinueDidReceiveResponse = isMainResource(); >@@ -630,6 +647,12 @@ void NetworkResourceLoader::continueWillSendRequest(ResourceRequest&& newRequest > { > RELEASE_LOG_IF_ALLOWED("continueWillSendRequest: (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ")", m_parameters.webPageID, m_parameters.webFrameID, m_parameters.identifier); > >+ if (m_shouldSendResponseOnContinueWillSendRequest) { >+ m_shouldSendResponseOnContinueWillSendRequest = false; >+ send(Messages::WebResourceLoader::DidReceiveResponse { m_response, true }); >+ return; >+ } >+ > if (m_networkLoadChecker) > m_networkLoadChecker->prepareRedirectedRequest(newRequest); > >@@ -750,6 +773,8 @@ void NetworkResourceLoader::didRetrieveCacheEntry(std::unique_ptr<NetworkCache:: > return; > } > >+ // FIXME: Add support for X-Disown-Opener. >+ > bool needsContinueDidReceiveResponseMessage = isMainResource(); > send(Messages::WebResourceLoader::DidReceiveResponse { response, needsContinueDidReceiveResponseMessage }); > >diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoader.h b/Source/WebKit/NetworkProcess/NetworkResourceLoader.h >index 8769708c0a2..0d2b024cbea 100644 >--- a/Source/WebKit/NetworkProcess/NetworkResourceLoader.h >+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoader.h >@@ -184,6 +184,7 @@ private: > bool m_isWaitingContinueWillSendRequestForCachedRedirect { false }; > std::unique_ptr<NetworkCache::Entry> m_cacheEntryWaitingForContinueDidReceiveResponse; > RefPtr<NetworkLoadChecker> m_networkLoadChecker; >+ bool m_shouldSendResponseOnContinueWillSendRequest { false }; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index 14de5c5cd2d..1dbda74161a 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -2480,6 +2480,9 @@ void WebPageProxy::continueNavigationInNewProcess(API::Navigation& navigation, R > if (!navigation.isCrossOriginWindowOpenNavigation() || !navigatedFrameIdentifierInPreviousProcess) > return; > >+ if (!this->process().processPool().configuration().processSwapsOnWindowOpenWithOpener()) >+ return; >+ > m_mainFrameWindowCreationHandler = [this, previousProcess = WTFMove(previousProcess), navigatedFrameIdentifierInPreviousProcess = *navigatedFrameIdentifierInPreviousProcess](const GlobalWindowIdentifier& windowIdentifier) { > ASSERT(m_mainFrame); > GlobalFrameIdentifier navigatedFrameIdentifierInNewProcess { pageID(), m_mainFrame->frameID() }; >diff --git a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp >index 59d676fc9a7..4d72ed1e958 100644 >--- a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp >+++ b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp >@@ -276,6 +276,9 @@ void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceL > loadParameters.options = resourceLoader.options(); > loadParameters.preflightPolicy = resourceLoader.options().preflightPolicy; > >+ if (request.requester() == ResourceRequest::Requester::Main) >+ loadParameters.hasOpener = resourceLoader.frame() ? !!resourceLoader.frame()->loader().opener() : false; >+ > auto* document = resourceLoader.frame() ? resourceLoader.frame()->document() : nullptr; > if (resourceLoader.options().cspResponseHeaders) > loadParameters.cspResponseHeaders = resourceLoader.options().cspResponseHeaders; >diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp >index 6965cdd3528..cd159d5eebe 100644 >--- a/Tools/WebKitTestRunner/TestController.cpp >+++ b/Tools/WebKitTestRunner/TestController.cpp >@@ -497,7 +497,10 @@ void TestController::createWebViewWithOptions(const TestOptions& options) > WKArrayAppendItem(overrideLanguages.get(), adoptWK(WKStringCreateWithUTF8CString(language.utf8().data())).get()); > WKContextConfigurationSetOverrideLanguages(contextConfiguration.get(), overrideLanguages.get()); > >- if (options.enableProcessSwapOnNavigation) { >+ if (options.enableProcessSwapOnNavigation) >+ WKContextConfigurationSetProcessSwapsOnNavigation(contextConfiguration.get(), true); >+ >+ if (options.enableProcessSwapOnWindowOpenWithOpener) { > WKContextConfigurationSetProcessSwapsOnNavigation(contextConfiguration.get(), true); > WKContextConfigurationSetProcessSwapsOnWindowOpenWithOpener(contextConfiguration.get(), true); > } >@@ -1103,6 +1106,8 @@ static void updateTestOptionsFromTestHeader(TestOptions& testOptions, const std: > testOptions.enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations = parseBooleanTestHeaderValue(value); > if (key == "enableProcessSwapOnNavigation") > testOptions.enableProcessSwapOnNavigation = parseBooleanTestHeaderValue(value); >+ if (key == "enableProcessSwapOnWindowOpenWithOpener") >+ testOptions.enableProcessSwapOnWindowOpenWithOpener = parseBooleanTestHeaderValue(value); > pairStart = pairEnd + 1; > } > } >diff --git a/Tools/WebKitTestRunner/TestOptions.h b/Tools/WebKitTestRunner/TestOptions.h >index bf89a071a2f..abab4722bf1 100644 >--- a/Tools/WebKitTestRunner/TestOptions.h >+++ b/Tools/WebKitTestRunner/TestOptions.h >@@ -57,6 +57,7 @@ struct TestOptions { > bool allowCrossOriginSubresourcesToAskForCredentials { false }; > bool enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations { false }; > bool enableProcessSwapOnNavigation { false }; >+ bool enableProcessSwapOnWindowOpenWithOpener { false }; > > float deviceScaleFactor { 1 }; > Vector<String> overrideLanguages; >@@ -88,7 +89,8 @@ struct TestOptions { > || applicationManifest != options.applicationManifest > || allowCrossOriginSubresourcesToAskForCredentials != options.allowCrossOriginSubresourcesToAskForCredentials > || enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations != options.enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations >- || enableProcessSwapOnNavigation != options.enableProcessSwapOnNavigation) >+ || enableProcessSwapOnNavigation != options.enableProcessSwapOnNavigation >+ || enableProcessSwapOnWindowOpenWithOpener != options.enableProcessSwapOnWindowOpenWithOpener) > return false; > > return true;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 184996
:
338788
|
338803
|
338811
|
338812
|
338820
|
338825
|
338840
|
339215
|
339223
|
339225
|
339226
|
339242
|
339897
|
339922
|
339923
|
339973
|
339978
|
339980
|
339995
|
339998
|
340000
|
340007
|
340010
|
340022
|
340031
|
340035
|
340039
|
340041
|
340042
|
340046
|
340047
|
340049