Title: [284758] trunk
Revision
284758
Author
[email protected]
Date
2021-10-24 09:01:14 -0700 (Sun, 24 Oct 2021)

Log Message

document.open() and friends use incorrect document as a source for reseted document's URL
https://bugs.webkit.org/show_bug.cgi?id=230131

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-same-origin-domain.sub-expected.txt:
* web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/url-entry-document-incumbent-frame.html: Added.
* web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window-expected.txt: Added.
* web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.html: Added.
* web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.js: Added.

Source/WebCore:

With this patch, Document's open() / write() / writeln() methods receive entry global
object's document [1] as an argument, which is used to perform same-origin security check
and to set the URL of reseted document from. Aligns WebKit with Blink and Gecko.

Instead of maintaining consistency with FirstWindow, EntryDocument is named to match
the spec and because it's not always the "first" (topmost) document, but rather a document
of closest <script> or inline event handler.

ResponsibleDocument is removed because it's now unused and, in terms of implementation,
a poor man's IncumbentWindow. Also, the spec describes different concept by that name [2].

[1] https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#opening-the-input-stream:entry-global-object
[2] https://html.spec.whatwg.org/multipage/webappapis.html#responsible-document

Tests: http/tests/security/aboutBlank/security-context-grandchildren-lexical.html
       http/tests/security/aboutBlank/security-context-grandchildren-write-lexical.html
       http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical.html
       imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.html

* bindings/js/JSDOMWindowBase.cpp:
(WebCore::responsibleDocument): Deleted.
* bindings/js/JSDOMWindowBase.h:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallWith):
* bindings/scripts/IDLAttributes.json:
* dom/Document+HTML.idl:
* dom/Document.cpp:
(WebCore::Document::open):
(WebCore::Document::write):
(WebCore::Document::writeln):
* dom/Document.h:

LayoutTests:

* http/tests/security/aboutBlank/security-context-grandchildren-lexical.html:
* http/tests/security/aboutBlank/security-context-grandchildren-write-lexical.html:
* http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical.html:
Tweak _javascript_: URLs to evaluate as `undefined` so the tests could be run in Firefox.

* http/tests/security/aboutBlank/security-context-grandchildren-lexical-expected.txt:
* http/tests/security/aboutBlank/security-context-grandchildren-write-lexical-expected.txt:
* http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical-expected.txt:
Align expectations with Blink and Gecko.

* http/tests/security/resources/parent-document-open.html: Added.
* http/tests/security/xss-DENIED-xsl-document-securityOrigin.xml:
The test relied on behavior that wasn't spec-compliant, causing timeouts once document.open() is fixed.
This patch preserves the test semantics of calling document.open() with iframe's global object.
Similar Blink bug: crbug.com/579493.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (284757 => 284758)


--- trunk/LayoutTests/ChangeLog	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/LayoutTests/ChangeLog	2021-10-24 16:01:14 UTC (rev 284758)
@@ -1,3 +1,26 @@
+2021-10-24  Alexey Shvayka  <[email protected]>
+
+        document.open() and friends use incorrect document as a source for reseted document's URL
+        https://bugs.webkit.org/show_bug.cgi?id=230131
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/security/aboutBlank/security-context-grandchildren-lexical.html:
+        * http/tests/security/aboutBlank/security-context-grandchildren-write-lexical.html:
+        * http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical.html:
+        Tweak _javascript_: URLs to evaluate as `undefined` so the tests could be run in Firefox.
+
+        * http/tests/security/aboutBlank/security-context-grandchildren-lexical-expected.txt:
+        * http/tests/security/aboutBlank/security-context-grandchildren-write-lexical-expected.txt:
+        * http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical-expected.txt:
+        Align expectations with Blink and Gecko.
+
+        * http/tests/security/resources/parent-document-open.html: Added.
+        * http/tests/security/xss-DENIED-xsl-document-securityOrigin.xml:
+        The test relied on behavior that wasn't spec-compliant, causing timeouts once document.open() is fixed.
+        This patch preserves the test semantics of calling document.open() with iframe's global object.
+        Similar Blink bug: crbug.com/579493.
+
 2021-10-23  Rob Buis  <[email protected]>
 
         Null check in traverseNodesForSerialization

Modified: trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-lexical-expected.txt (284757 => 284758)


--- trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-lexical-expected.txt	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-lexical-expected.txt	2021-10-24 16:01:14 UTC (rev 284758)
@@ -11,20 +11,20 @@
 document.cookie = cookie=resources; cookie=parent
 --- After document.open() ---
 * "about:blank"
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-lexical.html
+document.cookie = cookie=parent
 * ""
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-lexical.html
+document.cookie = cookie=parent
 --- After document.close() ---
 * "about:blank"
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-lexical.html
+document.cookie = cookie=parent
 * ""
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-lexical.html
+document.cookie = cookie=parent
 --- Test ends ---

Modified: trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-lexical.html (284757 => 284758)


--- trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-lexical.html	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-lexical.html	2021-10-24 16:01:14 UTC (rev 284758)
@@ -26,7 +26,7 @@
       "window.mywriteln = function(i, str) { frames[i].document.writeln(str); };" +
       "window.myclose = function(i) { frames[i].document.close(); };" +
       "parent.log('Helpers loaded!\\n');" +
-      "parent.setTimeout('continueTest()', 10);";
+      "parent.setTimeout('continueTest()', 10); undefined;";
 }
 
 function continueTest() {

Modified: trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-write-lexical-expected.txt (284757 => 284758)


--- trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-write-lexical-expected.txt	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-write-lexical-expected.txt	2021-10-24 16:01:14 UTC (rev 284758)
@@ -11,20 +11,20 @@
 document.cookie = cookie=resources; cookie=parent
 --- After document.open() ---
 * "about:blank"
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-write-lexical.html
+document.cookie = cookie=parent
 * ""
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-write-lexical.html
+document.cookie = cookie=parent
 --- After document.close() ---
 * "about:blank"
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-write-lexical.html
+document.cookie = cookie=parent
 * ""
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-write-lexical.html
+document.cookie = cookie=parent
 --- Test ends ---

Modified: trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-write-lexical.html (284757 => 284758)


--- trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-write-lexical.html	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-write-lexical.html	2021-10-24 16:01:14 UTC (rev 284758)
@@ -26,7 +26,7 @@
       "window.mywriteln = function(i, str) { frames[i].document.writeln(str); };" +
       "window.myclose = function(i) { frames[i].document.close(); };" +
       "parent.log('Helpers loaded!\\n');" +
-      "parent.setTimeout('continueTest()', 10);";
+      "parent.setTimeout('continueTest()', 10); undefined;";
 }
 
 function continueTest() {

Modified: trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical-expected.txt (284757 => 284758)


--- trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical-expected.txt	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical-expected.txt	2021-10-24 16:01:14 UTC (rev 284758)
@@ -11,20 +11,20 @@
 document.cookie = cookie=resources; cookie=parent
 --- After document.open() ---
 * "about:blank"
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-writeln-lexical.html
+document.cookie = cookie=parent
 * ""
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-writeln-lexical.html
+document.cookie = cookie=parent
 --- After document.close() ---
 * "about:blank"
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-writeln-lexical.html
+document.cookie = cookie=parent
 * ""
-document.URL = ""
-document.baseURI = http://127.0.0.1:8000/security/aboutBlank/resources/iframe-with-about-blank-children.html
-document.cookie = cookie=resources; cookie=parent
+document.URL = ""
+document.baseURI = http://127.0.0.1:8000/security/aboutBlank/security-context-grandchildren-writeln-lexical.html
+document.cookie = cookie=parent
 --- Test ends ---

Modified: trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical.html (284757 => 284758)


--- trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical.html	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/LayoutTests/http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical.html	2021-10-24 16:01:14 UTC (rev 284758)
@@ -26,7 +26,7 @@
       "window.mywriteln = function(i, str) { frames[i].document.writeln(str); };" +
       "window.myclose = function(i) { frames[i].document.close(); };" +
       "parent.log('Helpers loaded!\\n');" +
-      "parent.setTimeout('continueTest()', 10);";
+      "parent.setTimeout('continueTest()', 10); undefined;";
 }
 
 function continueTest() {

Added: trunk/LayoutTests/http/tests/security/resources/parent-document-open.html (0 => 284758)


--- trunk/LayoutTests/http/tests/security/resources/parent-document-open.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/parent-document-open.html	2021-10-24 16:01:14 UTC (rev 284758)
@@ -0,0 +1,3 @@
+<script>
+    parent.document.open();
+</script>

Modified: trunk/LayoutTests/http/tests/security/xss-DENIED-xsl-document-securityOrigin.xml (284757 => 284758)


--- trunk/LayoutTests/http/tests/security/xss-DENIED-xsl-document-securityOrigin.xml	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/LayoutTests/http/tests/security/xss-DENIED-xsl-document-securityOrigin.xml	2021-10-24 16:01:14 UTC (rev 284758)
@@ -17,11 +17,14 @@
         wnd = victim.contentWindow.open();
         victim.src = ""
         victim._onload_ = function() { wnd.eval("location = '" + location + "'"); }
-    } else if (location != "about:blank") {
+    } else if (!location.href.includes("parent-document-open.html")) {
         url = ""
-        blank = document.body.appendChild(document.createElement("iframe"));
-        blank.contentWindow.eval("parent.document.open()");
+        var parentDocOpen = document.createElement("iframe");
+        parentDocOpen.src = ""
+        document.body.append(parentDocOpen);
+        setTimeout(() => {
         location = "_javascript_:(\"\x3C?xml-stylesheet type='text/xsl' href=''?\x3E\x3Croot/\x3E\")";
+        }, 150);
     } else {
         try {
             victim = opener;

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (284757 => 284758)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-10-24 16:01:14 UTC (rev 284758)
@@ -1,3 +1,16 @@
+2021-10-24  Alexey Shvayka  <[email protected]>
+
+        document.open() and friends use incorrect document as a source for reseted document's URL
+        https://bugs.webkit.org/show_bug.cgi?id=230131
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-same-origin-domain.sub-expected.txt:
+        * web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/url-entry-document-incumbent-frame.html: Added.
+        * web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window-expected.txt: Added.
+        * web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.html: Added.
+        * web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.js: Added.
+
 2021-10-23  Cameron McCormack  <[email protected]>
 
         Tweak test tolerance

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-same-origin-domain.sub-expected.txt (284757 => 284758)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-same-origin-domain.sub-expected.txt	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-same-origin-domain.sub-expected.txt	2021-10-24 16:01:14 UTC (rev 284758)
@@ -1,8 +1,4 @@
 
-FAIL It should not be possible to open same origin-domain (but not same origin) documents. assert_throws_dom: Opening a same origin-domain (but not same origin) document doesn't throw. function "function open() {
-    [native code]
-}" did not throw
-FAIL It should not be possible to implicitly open same origin-domain (but not same origin) documents. assert_throws_dom: Implicitly opening a same origin-domain (but not same origin) document doesn't throw. function "function write() {
-    [native code]
-}" did not throw
+PASS It should not be possible to open same origin-domain (but not same origin) documents.
+PASS It should not be possible to implicitly open same origin-domain (but not same origin) documents.
 

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/url-entry-document-incumbent-frame.html (0 => 284758)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/url-entry-document-incumbent-frame.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/url-entry-document-incumbent-frame.html	2021-10-24 16:01:14 UTC (rev 284758)
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+window.callDocumentMethod = methodName => document[methodName]();
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window-expected.txt (0 => 284758)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window-expected.txt	2021-10-24 16:01:14 UTC (rev 284758)
@@ -0,0 +1,5 @@
+
+PASS document.open() changes document's URL to the entry global object's associate document's (sync call)
+PASS document.write() changes document's URL to the entry global object's associate document's (sync call)
+PASS document.writeln() changes document's URL to the entry global object's associate document's (sync call)
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.html (0 => 284758)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.html	2021-10-24 16:01:14 UTC (rev 284758)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.js (0 => 284758)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.js	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.js	2021-10-24 16:01:14 UTC (rev 284758)
@@ -0,0 +1,13 @@
+for (const methodName of ["open", "write", "writeln"]) {
+  async_test(t => {
+    const frame = document.body.appendChild(document.createElement("iframe"));
+    t.add_cleanup(() => { frame.remove(); });
+    const frameURL = new URL("resources/url-entry-document-incumbent-frame.html", document.URL).href;
+    frame._onload_ = t.step_func_done(() => {
+      assert_equals(frame.contentDocument.URL, frameURL);
+      frame.contentWindow.callDocumentMethod(methodName);
+      assert_equals(frame.contentDocument.URL, document.URL);
+    });
+    frame.src = ""
+  }, `document.${methodName}() changes document's URL to the entry global object's associate document's (sync call)`);
+}

Modified: trunk/Source/WebCore/ChangeLog (284757 => 284758)


--- trunk/Source/WebCore/ChangeLog	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/Source/WebCore/ChangeLog	2021-10-24 16:01:14 UTC (rev 284758)
@@ -1,3 +1,42 @@
+2021-10-24  Alexey Shvayka  <[email protected]>
+
+        document.open() and friends use incorrect document as a source for reseted document's URL
+        https://bugs.webkit.org/show_bug.cgi?id=230131
+
+        Reviewed by Chris Dumez.
+
+        With this patch, Document's open() / write() / writeln() methods receive entry global
+        object's document [1] as an argument, which is used to perform same-origin security check
+        and to set the URL of reseted document from. Aligns WebKit with Blink and Gecko.
+
+        Instead of maintaining consistency with FirstWindow, EntryDocument is named to match
+        the spec and because it's not always the "first" (topmost) document, but rather a document
+        of closest <script> or inline event handler.
+
+        ResponsibleDocument is removed because it's now unused and, in terms of implementation,
+        a poor man's IncumbentWindow. Also, the spec describes different concept by that name [2].
+
+        [1] https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#opening-the-input-stream:entry-global-object
+        [2] https://html.spec.whatwg.org/multipage/webappapis.html#responsible-document
+
+        Tests: http/tests/security/aboutBlank/security-context-grandchildren-lexical.html
+               http/tests/security/aboutBlank/security-context-grandchildren-write-lexical.html
+               http/tests/security/aboutBlank/security-context-grandchildren-writeln-lexical.html
+               imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-entry-document-sync-call.window.html
+
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::responsibleDocument): Deleted.
+        * bindings/js/JSDOMWindowBase.h:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateCallWith):
+        * bindings/scripts/IDLAttributes.json:
+        * dom/Document+HTML.idl:
+        * dom/Document.cpp:
+        (WebCore::Document::open):
+        (WebCore::Document::write):
+        (WebCore::Document::writeln):
+        * dom/Document.h:
+
 2021-10-24  Rob Buis  <[email protected]>
 
         [css-contain] Support contain:style for counters

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp (284757 => 284758)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp	2021-10-24 16:01:14 UTC (rev 284758)
@@ -337,16 +337,6 @@
     return asJSDOMWindow(&legacyActiveGlobalObjectForAccessor(fallbackGlobalObject, fallbackGlobalObject.vm().topCallFrame))->wrapped();
 }
 
-Document* responsibleDocument(VM& vm, CallFrame& callFrame)
-{
-    CallerFunctor functor;
-    callFrame.iterate(vm, functor);
-    auto* callerFrame = functor.callerFrame();
-    if (!callerFrame)
-        return nullptr;
-    return asJSDOMWindow(callerFrame->lexicalGlobalObject(vm))->wrapped().document();
-}
-
 void JSDOMWindowBase::fireFrameClearedWatchpointsForWindow(DOMWindow* window)
 {
     JSC::VM& vm = commonVM();

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h (284757 => 284758)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h	2021-10-24 16:01:14 UTC (rev 284758)
@@ -131,11 +131,4 @@
 DOMWindow& legacyActiveDOMWindowForAccessor(JSC::JSGlobalObject&, JSC::CallFrame&);
 DOMWindow& legacyActiveDOMWindowForAccessor(JSC::JSGlobalObject&);
 
-// FIXME: This should probably be removed in favor of one of the other DOMWindow accessors. It is intended
-//        to provide the document specfied as the 'responsible document' in the algorithm for document.open()
-//        (https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document-open-steps steps 4
-//        and 23 and https://html.spec.whatwg.org/multipage/webappapis.html#responsible-document). It is only
-//        used by JSDocument.
-Document* responsibleDocument(JSC::VM&, JSC::CallFrame&);
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (284757 => 284758)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2021-10-24 16:01:14 UTC (rev 284758)
@@ -5965,10 +5965,10 @@
         push(@$outputArray, $indent . "    return" . ($returnValue ? " " . $returnValue : "") . ";\n");
         push(@callWithArgs, "*incumbentDocument");
     }
-    if ($codeGenerator->ExtendedAttributeContains($callWith, "ResponsibleDocument")) {
+    if ($codeGenerator->ExtendedAttributeContains($callWith, "EntryDocument")) {
         AddToImplIncludes("DOMWindow.h");
         AddToImplIncludes("JSDOMWindowBase.h");
-        push(@callWithArgs, "responsibleDocument(${globalObject}->vm(), $callFrameReference)");
+        push(@callWithArgs, "firstDOMWindow(*$globalObject).document()");
     }
     if ($codeGenerator->ExtendedAttributeContains($callWith, "ActiveWindow")) {
         AddToImplIncludes("DOMWindow.h");

Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (284757 => 284758)


--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2021-10-24 16:01:14 UTC (rev 284758)
@@ -51,7 +51,7 @@
         },
         "CallWith": {
             "contextsAllowed": ["attribute", "operation"],
-            "values": ["Document", "ExecState", "ScriptExecutionContext", "GlobalObject", "ActiveWindow", "FirstWindow", "ResponsibleDocument", "World", "PropertyName"],
+            "values": ["Document", "ExecState", "ScriptExecutionContext", "GlobalObject", "ActiveWindow", "FirstWindow", "EntryDocument", "World", "PropertyName"],
             "supportsConjunction": true
         },
         "CheckSecurity": {

Modified: trunk/Source/WebCore/dom/Document+HTML.idl (284757 => 284758)


--- trunk/Source/WebCore/dom/Document+HTML.idl	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/Source/WebCore/dom/Document+HTML.idl	2021-10-24 16:01:14 UTC (rev 284758)
@@ -58,11 +58,11 @@
     // FIXME: The HTML spec says this should consult the "responsible document". We should ensure
     // that the caller document matches those semantics. It is possible we should replace it with
     // the existing 'incumbent document' concept.
-    [CEReactions, CallWith=ResponsibleDocument, ImplementedAs=openForBindings] Document open(optional DOMString unused1, optional DOMString unused2); // both arguments are ignored.
+    [CEReactions, CallWith=EntryDocument, ImplementedAs=openForBindings] Document open(optional DOMString unused1, optional DOMString unused2); // both arguments are ignored.
     [CallWith=ActiveWindow&FirstWindow, ImplementedAs=openForBindings] WindowProxy open(USVString url, DOMString name, DOMString features);
     [CEReactions, ImplementedAs=closeForBindings] undefined close();
-    [CEReactions, CallWith=ResponsibleDocument] undefined write(DOMString... text);
-    [CEReactions, CallWith=ResponsibleDocument] undefined writeln(DOMString... text);
+    [CEReactions, CallWith=EntryDocument] undefined write(DOMString... text);
+    [CEReactions, CallWith=EntryDocument] undefined writeln(DOMString... text);
 
     // user interaction
     [ImplementedAs=windowProxy] readonly attribute WindowProxy? defaultView;

Modified: trunk/Source/WebCore/dom/Document.cpp (284757 => 284758)


--- trunk/Source/WebCore/dom/Document.cpp	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/Source/WebCore/dom/Document.cpp	2021-10-24 16:01:14 UTC (rev 284758)
@@ -2917,12 +2917,12 @@
     return m_domWindow->open(activeWindow, firstWindow, url, name, features);
 }
 
-ExceptionOr<Document&> Document::openForBindings(Document* responsibleDocument, const String&, const String&)
+ExceptionOr<Document&> Document::openForBindings(Document* entryDocument, const String&, const String&)
 {
     if (!isHTMLDocument() || m_throwOnDynamicMarkupInsertionCount)
         return Exception { InvalidStateError };
 
-    auto result = open(responsibleDocument);
+    auto result = open(entryDocument);
     if (UNLIKELY(result.hasException()))
         return result.releaseException();
 
@@ -2929,9 +2929,9 @@
     return *this;
 }
 
-ExceptionOr<void> Document::open(Document* responsibleDocument)
+ExceptionOr<void> Document::open(Document* entryDocument)
 {
-    if (responsibleDocument && !responsibleDocument->securityOrigin().isSameOriginAs(securityOrigin()))
+    if (entryDocument && !entryDocument->securityOrigin().isSameOriginAs(securityOrigin()))
         return Exception { SecurityError };
 
     if (m_ignoreOpensDuringUnloadCount)
@@ -2960,16 +2960,16 @@
 
     removeAllEventListeners();
 
-    if (responsibleDocument && isFullyActive()) {
-        auto newURL = responsibleDocument->url();
-        if (responsibleDocument != this)
+    if (entryDocument && isFullyActive()) {
+        auto newURL = entryDocument->url();
+        if (entryDocument != this)
             newURL.removeFragmentIdentifier();
         setURL(newURL);
-        auto newCookieURL = responsibleDocument->cookieURL();
-        if (responsibleDocument != this)
+        auto newCookieURL = entryDocument->cookieURL();
+        if (entryDocument != this)
             newCookieURL.removeFragmentIdentifier();
         setCookieURL(newCookieURL);
-        setSecurityOriginPolicy(responsibleDocument->securityOriginPolicy());
+        setSecurityOriginPolicy(entryDocument->securityOriginPolicy());
     }
 
     implicitOpen();
@@ -3308,7 +3308,7 @@
     m_didEnqueueFirstContentfulPaint = true;
 }
 
-ExceptionOr<void> Document::write(Document* responsibleDocument, SegmentedString&& text)
+ExceptionOr<void> Document::write(Document* entryDocument, SegmentedString&& text)
 {
     if (m_activeParserWasAborted)
         return { };
@@ -3326,7 +3326,7 @@
         return { };
 
     if (!hasInsertionPoint) {
-        auto result = open(responsibleDocument);
+        auto result = open(entryDocument);
         if (UNLIKELY(result.hasException()))
             return result.releaseException();
     }
@@ -3336,7 +3336,7 @@
     return { };
 }
 
-ExceptionOr<void> Document::write(Document* responsibleDocument, Vector<String>&& strings)
+ExceptionOr<void> Document::write(Document* entryDocument, Vector<String>&& strings)
 {
     if (!isHTMLDocument() || m_throwOnDynamicMarkupInsertionCount)
         return Exception { InvalidStateError };
@@ -3345,10 +3345,10 @@
     for (auto& string : strings)
         text.append(WTFMove(string));
 
-    return write(responsibleDocument, WTFMove(text));
+    return write(entryDocument, WTFMove(text));
 }
 
-ExceptionOr<void> Document::writeln(Document* responsibleDocument, Vector<String>&& strings)
+ExceptionOr<void> Document::writeln(Document* entryDocument, Vector<String>&& strings)
 {
     if (!isHTMLDocument() || m_throwOnDynamicMarkupInsertionCount)
         return Exception { InvalidStateError };
@@ -3358,7 +3358,7 @@
         text.append(WTFMove(string));
 
     text.append("\n"_s);
-    return write(responsibleDocument, WTFMove(text));
+    return write(entryDocument, WTFMove(text));
 }
 
 Seconds Document::minimumDOMTimerInterval() const

Modified: trunk/Source/WebCore/dom/Document.h (284757 => 284758)


--- trunk/Source/WebCore/dom/Document.h	2021-10-24 15:32:25 UTC (rev 284757)
+++ trunk/Source/WebCore/dom/Document.h	2021-10-24 16:01:14 UTC (rev 284758)
@@ -668,10 +668,10 @@
     WEBCORE_EXPORT DocumentLoader* loader() const;
 
     WEBCORE_EXPORT ExceptionOr<RefPtr<WindowProxy>> openForBindings(DOMWindow& activeWindow, DOMWindow& firstDOMWindow, const String& url, const AtomString& name, const String& features);
-    WEBCORE_EXPORT ExceptionOr<Document&> openForBindings(Document* responsibleDocument, const String&, const String&);
+    WEBCORE_EXPORT ExceptionOr<Document&> openForBindings(Document* entryDocument, const String&, const String&);
 
     // FIXME: We should rename this at some point and give back the name 'open' to the HTML specified ones.
-    WEBCORE_EXPORT ExceptionOr<void> open(Document* responsibleDocument = nullptr);
+    WEBCORE_EXPORT ExceptionOr<void> open(Document* entryDocument = nullptr);
     void implicitOpen();
 
     WEBCORE_EXPORT ExceptionOr<void> closeForBindings();
@@ -687,9 +687,9 @@
 
     void cancelParsing();
 
-    ExceptionOr<void> write(Document* responsibleDocument, SegmentedString&&);
-    WEBCORE_EXPORT ExceptionOr<void> write(Document* responsibleDocument, Vector<String>&&);
-    WEBCORE_EXPORT ExceptionOr<void> writeln(Document* responsibleDocument, Vector<String>&&);
+    ExceptionOr<void> write(Document* entryDocument, SegmentedString&&);
+    WEBCORE_EXPORT ExceptionOr<void> write(Document* entryDocument, Vector<String>&&);
+    WEBCORE_EXPORT ExceptionOr<void> writeln(Document* entryDocument, Vector<String>&&);
 
     bool wellFormed() const { return m_wellFormed; }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to