Title: [281802] trunk
- Revision
- 281802
- Author
- [email protected]
- Date
- 2021-08-31 07:45:35 -0700 (Tue, 31 Aug 2021)
Log Message
[COOP] html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write.html WPT test is failing
https://bugs.webkit.org/show_bug.cgi?id=229692
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
* web-platform-tests/html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write-expected.txt:
Rebaseline WPT test that is now passing.
* web-platform-tests/html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write.html:
Merge typo fix from https://github.com/web-platform-tests/wpt/commit/0adccdd2cd38e2217a11d3d6dd14260f32a8a0a6
Source/WebCore:
The test does the following:
1. An opener document with `COOP=same-origin-allow-popups` opens a new window that shows the initial empty document.
Note that the openee inherits `COOP=same-origin-allow-popups` from its opener.
2. The opener document then calls document.write() on the openee.
Note that, as per the HTML specification, this clears the 'is displaying initial empty document' flag.
3. The openee is navigated cross-origin to a destination without COOP.
Normally, `COOP=same-origin-allow-popups` would allow the popup to be navigated cross-origin as per the logic here [1]:
"""
If all of the following are true:
- isInitialAboutBlank,
- activeDocumentCOOPValue's value is "same-origin-allow-popups".
- responseCOOPValue is "unsafe-none",
then return false (meaning, no context group switch).
"""
However, because of the document.write() call at step 2, the isInitialAboutBlank flag is no longer true
and the check should fail, thus causing a browsing context group switch.
[1] https://html.spec.whatwg.org/multipage/origin.html#check-browsing-context-group-switch-coop-value
No new tests, rebaselined existing test.
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::maybeLoadEmpty):
Replace the bad check to committedFirstRealDocumentLoad (which stays true after calling document.write()
on the initial empty document) with a check to !isDisplayingInitialEmptyDocument, which matches the
specification text. isDisplayingInitialEmptyDocument correctly becomes false after calling document.write()
on the initial empty document.
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::crossOriginOpenerPolicy const):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::didBeginDocument):
Fix didBeginDocument() so that it doesn't overwrite the document's cross-origin-opener-policy when the
DocumentLoader does not know what the policy is. When opening a popup, Document::initSecurityContext()
will set the popup's cross-origin-opener-policy to the one of its opener. When didBeginDocument()
gets called later for the initial empty document, we don't want to overwrite the inherited policy
with a new default cross-origin-opener-policy of unsafe-none. The reason the DocumentLoader does not
have a policy for us is because this is the initial empty document and DocumentLoader's
doCrossOriginOpenerHandlingOfResponse() was thus never called with an actual network response.
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (281801 => 281802)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-08-31 14:19:28 UTC (rev 281801)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-08-31 14:45:35 UTC (rev 281802)
@@ -1,3 +1,16 @@
+2021-08-31 Chris Dumez <[email protected]>
+
+ [COOP] html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write.html WPT test is failing
+ https://bugs.webkit.org/show_bug.cgi?id=229692
+
+ Reviewed by Darin Adler.
+
+ * web-platform-tests/html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write-expected.txt:
+ Rebaseline WPT test that is now passing.
+
+ * web-platform-tests/html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write.html:
+ Merge typo fix from https://github.com/web-platform-tests/wpt/commit/0adccdd2cd38e2217a11d3d6dd14260f32a8a0a6
+
2021-08-31 Antti Koivisto <[email protected]>
[CSS Cascade Layers] Compute order correctly for late added sublayers
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write-expected.txt (281801 => 281802)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write-expected.txt 2021-08-31 14:19:28 UTC (rev 281801)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write-expected.txt 2021-08-31 14:45:35 UTC (rev 281802)
@@ -1,3 +1,3 @@
-FAIL coop-same-origin-allow-popups-document-write assert_equals: opener == null expected "true" but got "false"
+PASS coop-same-origin-allow-popups-document-write
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write.html (281801 => 281802)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write.html 2021-08-31 14:19:28 UTC (rev 281801)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write.html 2021-08-31 14:45:35 UTC (rev 281802)
@@ -52,7 +52,7 @@
// for the openee' document to load and the various fetch() with the
// dispatcher should be largely enough. However these aren't causal guarantee.
// So wait a bit to be sure:
- await new Promise(r => test.step_timeout(r, 1000));
+ await new Promise(r => t.step_timeout(r, 1000));
// Check the opener see the openee as 'closed' after the navigation.
send(opener_token, `
Modified: trunk/Source/WebCore/ChangeLog (281801 => 281802)
--- trunk/Source/WebCore/ChangeLog 2021-08-31 14:19:28 UTC (rev 281801)
+++ trunk/Source/WebCore/ChangeLog 2021-08-31 14:45:35 UTC (rev 281802)
@@ -1,3 +1,52 @@
+2021-08-31 Chris Dumez <[email protected]>
+
+ [COOP] html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write.html WPT test is failing
+ https://bugs.webkit.org/show_bug.cgi?id=229692
+
+ Reviewed by Darin Adler.
+
+ The test does the following:
+ 1. An opener document with `COOP=same-origin-allow-popups` opens a new window that shows the initial empty document.
+ Note that the openee inherits `COOP=same-origin-allow-popups` from its opener.
+ 2. The opener document then calls document.write() on the openee.
+ Note that, as per the HTML specification, this clears the 'is displaying initial empty document' flag.
+ 3. The openee is navigated cross-origin to a destination without COOP.
+
+ Normally, `COOP=same-origin-allow-popups` would allow the popup to be navigated cross-origin as per the logic here [1]:
+ """
+ If all of the following are true:
+ - isInitialAboutBlank,
+ - activeDocumentCOOPValue's value is "same-origin-allow-popups".
+ - responseCOOPValue is "unsafe-none",
+ then return false (meaning, no context group switch).
+ """
+
+ However, because of the document.write() call at step 2, the isInitialAboutBlank flag is no longer true
+ and the check should fail, thus causing a browsing context group switch.
+
+ [1] https://html.spec.whatwg.org/multipage/origin.html#check-browsing-context-group-switch-coop-value
+
+ No new tests, rebaselined existing test.
+
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::maybeLoadEmpty):
+ Replace the bad check to committedFirstRealDocumentLoad (which stays true after calling document.write()
+ on the initial empty document) with a check to !isDisplayingInitialEmptyDocument, which matches the
+ specification text. isDisplayingInitialEmptyDocument correctly becomes false after calling document.write()
+ on the initial empty document.
+
+ * loader/DocumentLoader.h:
+ (WebCore::DocumentLoader::crossOriginOpenerPolicy const):
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::didBeginDocument):
+ Fix didBeginDocument() so that it doesn't overwrite the document's cross-origin-opener-policy when the
+ DocumentLoader does not know what the policy is. When opening a popup, Document::initSecurityContext()
+ will set the popup's cross-origin-opener-policy to the one of its opener. When didBeginDocument()
+ gets called later for the initial empty document, we don't want to overwrite the inherited policy
+ with a new default cross-origin-opener-policy of unsafe-none. The reason the DocumentLoader does not
+ have a policy for us is because this is the initial empty document and DocumentLoader's
+ doCrossOriginOpenerHandlingOfResponse() was thus never called with an actual network response.
+
2021-08-31 Carlos Garcia Campos <[email protected]>
[SOUP] Assertion in startObservingCookieChanges()
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (281801 => 281802)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2021-08-31 14:19:28 UTC (rev 281801)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2021-08-31 14:45:35 UTC (rev 281802)
@@ -2011,7 +2011,7 @@
String mimeType = shouldLoadEmpty ? "text/html" : frameLoader()->client().generatedMIMETypeForURLScheme(m_request.url().protocol().toStringWithoutCopying());
m_response = ResourceResponse(m_request.url(), mimeType, 0, "UTF-8"_s);
- if (frameLoader()->stateMachine().committedFirstRealDocumentLoad()) {
+ if (!frameLoader()->stateMachine().isDisplayingInitialEmptyDocument()) {
doCrossOriginOpenerHandlingOfResponse(m_response);
// FIXME: Non-initial about:blank loads may cause a browsing context group switch. However, such load is synchronous and doesn't
Modified: trunk/Source/WebCore/loader/DocumentLoader.h (281801 => 281802)
--- trunk/Source/WebCore/loader/DocumentLoader.h 2021-08-31 14:19:28 UTC (rev 281801)
+++ trunk/Source/WebCore/loader/DocumentLoader.h 2021-08-31 14:45:35 UTC (rev 281802)
@@ -423,7 +423,7 @@
bool lastNavigationWasAppInitiated() const { return m_lastNavigationWasAppInitiated; }
void setLastNavigationWasAppInitiated(bool lastNavigationWasAppInitiated) { m_lastNavigationWasAppInitiated = lastNavigationWasAppInitiated; }
- CrossOriginOpenerPolicy crossOriginOpenerPolicy() const { return m_currentCoopEnforcementResult ? m_currentCoopEnforcementResult->crossOriginOpenerPolicy : CrossOriginOpenerPolicy { }; }
+ std::optional<CrossOriginOpenerPolicy> crossOriginOpenerPolicy() const { return m_currentCoopEnforcementResult ? std::make_optional(m_currentCoopEnforcementResult->crossOriginOpenerPolicy) : std::nullopt; }
bool isContinuingLoadAfterResponsePolicyCheck() const { return m_isContinuingLoadAfterResponsePolicyCheck; }
void setIsContinuingLoadAfterResponsePolicyCheck(bool isContinuingLoadAfterResponsePolicyCheck) { m_isContinuingLoadAfterResponsePolicyCheck = isContinuingLoadAfterResponsePolicyCheck; }
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (281801 => 281802)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2021-08-31 14:19:28 UTC (rev 281801)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2021-08-31 14:45:35 UTC (rev 281802)
@@ -768,8 +768,10 @@
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#initialise-the-document-object (Step 7)
- if (m_frame.isMainFrame())
- m_frame.document()->setCrossOriginOpenerPolicy(m_documentLoader->crossOriginOpenerPolicy());
+ if (m_frame.isMainFrame()) {
+ if (auto crossOriginOpenerPolicy = m_documentLoader->crossOriginOpenerPolicy())
+ m_frame.document()->setCrossOriginOpenerPolicy(WTFMove(*crossOriginOpenerPolicy));
+ }
}
history().restoreDocumentState();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes