Title: [229369] trunk/LayoutTests
Revision
229369
Author
cdu...@apple.com
Date
2018-03-07 10:38:51 -0800 (Wed, 07 Mar 2018)

Log Message

http/tests/dom/window-open-about-webkit-org-and-access-document.html is failing with async policy delegates
https://bugs.webkit.org/show_bug.cgi?id=183394

Reviewed by Alex Christensen.

http/tests/dom/window-open-about-webkit-org-and-access-document.html is failing with async policy delegates.
The issue is that the test calls window.open() with a cross-origin URL and then right away tries to access
newWindow.document, expecting it to throw. However, there is no guarantee that the cross origin URL has
started loading at this point. In particular, when the navigation policy decision is made asynchronously,
the URL is initially "about:blank" and it is OK to access the newWindow's document at this point.

We would normally rely on the window's load event before doing the check. However, this would not work
here since the window is cross origin. As a result, I am using a setInterval() in order to wait for the
cross-origin URL to load and for newWindow.document to start throwing.

* http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates-expected.txt: Added.
* http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates.html: Added.
* http/tests/dom/window-open-about-webkit-org-and-access-document-expected.txt:
* http/tests/dom/window-open-about-webkit-org-and-access-document.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (229368 => 229369)


--- trunk/LayoutTests/ChangeLog	2018-03-07 18:27:55 UTC (rev 229368)
+++ trunk/LayoutTests/ChangeLog	2018-03-07 18:38:51 UTC (rev 229369)
@@ -1,3 +1,25 @@
+2018-03-07  Chris Dumez  <cdu...@apple.com>
+
+        http/tests/dom/window-open-about-webkit-org-and-access-document.html is failing with async policy delegates
+        https://bugs.webkit.org/show_bug.cgi?id=183394
+
+        Reviewed by Alex Christensen.
+
+        http/tests/dom/window-open-about-webkit-org-and-access-document.html is failing with async policy delegates.
+        The issue is that the test calls window.open() with a cross-origin URL and then right away tries to access
+        newWindow.document, expecting it to throw. However, there is no guarantee that the cross origin URL has
+        started loading at this point. In particular, when the navigation policy decision is made asynchronously,
+        the URL is initially "about:blank" and it is OK to access the newWindow's document at this point.
+
+        We would normally rely on the window's load event before doing the check. However, this would not work
+        here since the window is cross origin. As a result, I am using a setInterval() in order to wait for the
+        cross-origin URL to load and for newWindow.document to start throwing.
+
+        * http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates-expected.txt: Added.
+        * http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates.html: Added.
+        * http/tests/dom/window-open-about-webkit-org-and-access-document-expected.txt:
+        * http/tests/dom/window-open-about-webkit-org-and-access-document.html:
+
 2018-03-07  Yusuke Suzuki  <utatane....@gmail.com>
 
         HTML `pattern` attribute should set `u` flag for regular expressions

Added: trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates-expected.txt (0 => 229369)


--- trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates-expected.txt	2018-03-07 18:38:51 UTC (rev 229369)
@@ -0,0 +1,10 @@
+Tests opening a new about://webkit.org window and accessing its document
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS e.name is "SecurityError"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates.html (0 => 229369)


--- trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document-async-delegates.html	2018-03-07 18:38:51 UTC (rev 229369)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <script src=""
+    <script>
+        description("Tests opening a new about://webkit.org window and accessing its document");
+        jsTestIsAsync = true;
+
+        var newWindow;
+
+        if (window.testRunner) {
+            testRunner.setCanOpenWindows();
+            testRunner.setPopupBlockingEnabled(false);
+            if (testRunner.setShouldDecideNavigationPolicyAfterDelay)
+                testRunner.setShouldDecideNavigationPolicyAfterDelay(true);
+        }
+
+        function finish()
+        {
+            clearInterval(handle);
+            finishJSTest();
+        }
+
+        function checkCannotAccessDocument()
+        {
+            try {
+                newWindow.document;
+                if (newWindow.document.URL != "about:blank") {
+                    testFailed("Managed to access the document at URL " + newWindow.document.URL);
+                    finish();
+                }
+            } catch (_e) {
+                e = _e;
+                shouldBeEqualToString("e.name", "SecurityError");
+                finish();
+            }
+        }
+
+        _onload_ = function () {
+            newWindow = window.open("about://webkit.org");
+            handle = setInterval(checkCannotAccessDocument, 5);
+
+        }
+    </script>
+</body>
+</html>

Modified: trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document-expected.txt (229368 => 229369)


--- trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document-expected.txt	2018-03-07 18:27:55 UTC (rev 229368)
+++ trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document-expected.txt	2018-03-07 18:38:51 UTC (rev 229369)
@@ -1,5 +1,10 @@
-CONSOLE MESSAGE: line 29: SecurityError: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "null".  The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "about". Protocols must match.
+Tests opening a new about://webkit.org window and accessing its document
 
-PASS newWindow.document threw exception SecurityError: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "null".  The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "about". Protocols must match.
-.
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
+
+PASS e.name is "SecurityError"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document.html (229368 => 229369)


--- trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document.html	2018-03-07 18:27:55 UTC (rev 229368)
+++ trunk/LayoutTests/http/tests/dom/window-open-about-webkit-org-and-access-document.html	2018-03-07 18:38:51 UTC (rev 229369)
@@ -1,38 +1,44 @@
 <!DOCTYPE html>
-<html lang="en">
-<head>
-    <title>Tests opening a new about://webkit.org window and accessing its document</title>
-    <script src=""
+<html>
+<body>
+    <script src=""
     <script>
+        description("Tests opening a new about://webkit.org window and accessing its document");
+        jsTestIsAsync = true;
+
         var newWindow;
 
         if (window.testRunner) {
             testRunner.setCanOpenWindows();
-            testRunner.waitUntilDone();
             testRunner.setPopupBlockingEnabled(false);
         }
 
-        function checkNewWindowDocumentIsUndefined () {
-            shouldThrowErrorName("newWindow.document", "SecurityError");
-            if (window.testRunner)
-                testRunner.notifyDone();
+        function finish()
+        {
+            clearInterval(handle);
+            finishJSTest();
         }
 
-        function run() {
-            newWindow = window.open("about://webkit.org");
+        function checkCannotAccessDocument()
+        {
             try {
-                newWindow.document.write("<scri" + "pt>console.log('Injected script running.')</sc" + "ript>");
-                testFailed("Was able to write to the new window's document.");
-                if (window.testRunner)
-                    testRunner.notifyDone();
-            } catch (e) {
-                console.log(e);
-                setTimeout(checkNewWindowDocumentIsUndefined, 500);
+                newWindow.document;
+                if (newWindow.document.URL != "about:blank") {
+                    testFailed("Managed to access the document at URL " + newWindow.document.URL);
+                    finish();
+                }
+            } catch (_e) {
+                e = _e;
+                shouldBeEqualToString("e.name", "SecurityError");
+                finish();
             }
         }
+
+        _onload_ = function () {
+            newWindow = window.open("about://webkit.org");
+            handle = setInterval(checkCannotAccessDocument, 5);
+
+        }
     </script>
-</head>
-<body _onload_="run()">
-<div id="console"></div>
 </body>
 </html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to