Title: [229539] trunk/LayoutTests
Revision
229539
Author
cdu...@apple.com
Date
2018-03-12 10:50:53 -0700 (Mon, 12 Mar 2018)

Log Message

http/tests/security/frame-loading-via-document-write-async-delegates.html fails with async delegates
https://bugs.webkit.org/show_bug.cgi?id=183460

Reviewed by Alex Christensen.

The test has 3 frames which all initially load "about:blank". Then using document.write(), it inserts
HTML in each frame.
Frame 1: body has an onload event handler, which calls JS is click an anchor link to navigate the frame.
Frame 2: body has an onload event handler to do some logging
Frame 3: body has an onload event handler and finishes the test (calls testRunner.notifyDone())

The issue is that with asynchronous policy delegates, the first frame may not have navigated yet by the
time the third frame is loaded. Indeed, the onload event of the first frame merely clicks am anchor link
which will trigger a navigation policy check and then later navigate.

To make the test more robust, we now count the number of loads and call testRunner.notifyDone() when
we've reached the expected number of loads.

* http/tests/security/frame-loading-via-document-write-async-delegates-expected.txt: Added.
* http/tests/security/frame-loading-via-document-write-async-delegates.html: Copied from LayoutTests/http/tests/security/frame-loading-via-document-write.html.
* http/tests/security/frame-loading-via-document-write.html:
* http/tests/security/resources/frame-loading-via-document-write.js:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (229538 => 229539)


--- trunk/LayoutTests/ChangeLog	2018-03-12 16:47:59 UTC (rev 229538)
+++ trunk/LayoutTests/ChangeLog	2018-03-12 17:50:53 UTC (rev 229539)
@@ -1,3 +1,28 @@
+2018-03-12  Chris Dumez  <cdu...@apple.com>
+
+        http/tests/security/frame-loading-via-document-write-async-delegates.html fails with async delegates
+        https://bugs.webkit.org/show_bug.cgi?id=183460
+
+        Reviewed by Alex Christensen.
+
+        The test has 3 frames which all initially load "about:blank". Then using document.write(), it inserts
+        HTML in each frame.
+        Frame 1: body has an onload event handler, which calls JS is click an anchor link to navigate the frame.
+        Frame 2: body has an onload event handler to do some logging
+        Frame 3: body has an onload event handler and finishes the test (calls testRunner.notifyDone())
+
+        The issue is that with asynchronous policy delegates, the first frame may not have navigated yet by the
+        time the third frame is loaded. Indeed, the onload event of the first frame merely clicks am anchor link
+        which will trigger a navigation policy check and then later navigate.
+
+        To make the test more robust, we now count the number of loads and call testRunner.notifyDone() when
+        we've reached the expected number of loads.
+
+        * http/tests/security/frame-loading-via-document-write-async-delegates-expected.txt: Added.
+        * http/tests/security/frame-loading-via-document-write-async-delegates.html: Copied from LayoutTests/http/tests/security/frame-loading-via-document-write.html.
+        * http/tests/security/frame-loading-via-document-write.html:
+        * http/tests/security/resources/frame-loading-via-document-write.js:
+
 2018-03-12  Per Arne Vollan  <pvol...@apple.com>
 
         Mark webanimations/css-animations.html and webanimations/css-transitions.html as failures on Windows.

Modified: trunk/LayoutTests/TestExpectations (229538 => 229539)


--- trunk/LayoutTests/TestExpectations	2018-03-12 16:47:59 UTC (rev 229538)
+++ trunk/LayoutTests/TestExpectations	2018-03-12 17:50:53 UTC (rev 229539)
@@ -188,6 +188,10 @@
 imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-protocol-setter-non-broken.html [ DumpJSConsoleLogInStdErr ]
 imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-protocol-setter-non-broken-weird.html [ DumpJSConsoleLogInStdErr ]
 
+# Line number in the console logging may change so we silence it to avoid flakiness.
+http/tests/security/frame-loading-via-document-write.html [ DumpJSConsoleLogInStdErr ]
+http/tests/security/frame-loading-via-document-write-async-delegates.html [ DumpJSConsoleLogInStdErr ]
+
 webkit.org/b/181901 imported/w3c/web-platform-tests/service-workers/service-worker/fetch-cors-xhr.https.html [ DumpJSConsoleLogInStdErr ]
 webkit.org/b/181897 imported/w3c/web-platform-tests/service-workers/service-worker/fetch-canvas-tainting.https.html [ DumpJSConsoleLogInStdErr ]
 webkit.org/b/181900 imported/w3c/web-platform-tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html [ DumpJSConsoleLogInStdErr ]

Copied: trunk/LayoutTests/http/tests/security/frame-loading-via-document-write-async-delegates-expected.txt (from rev 229538, trunk/LayoutTests/http/tests/security/frame-loading-via-document-write-expected.txt) (0 => 229539)


--- trunk/LayoutTests/http/tests/security/frame-loading-via-document-write-async-delegates-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/frame-loading-via-document-write-async-delegates-expected.txt	2018-03-12 17:50:53 UTC (rev 229539)
@@ -0,0 +1,21 @@
+
+
+--------
+Frame: 'topRow'
+--------
+This page was successfully loaded.
+My protocol is http:
+My referrer is blank
+
+
+--------
+Frame: 'middleRow'
+--------
+Image NOT loaded.
+
+
+--------
+Frame: 'bottomRow'
+--------
+Image loaded.
+

Copied: trunk/LayoutTests/http/tests/security/frame-loading-via-document-write-async-delegates.html (from rev 229538, trunk/LayoutTests/http/tests/security/frame-loading-via-document-write.html) (0 => 229539)


--- trunk/LayoutTests/http/tests/security/frame-loading-via-document-write-async-delegates.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/frame-loading-via-document-write-async-delegates.html	2018-03-12 17:50:53 UTC (rev 229539)
@@ -0,0 +1,82 @@
+<html>
+<head>
+<title></title>
+
+<script language="_javascript_">
+
+const expectedLoadCount = 7;
+let loadCount = 0;
+function finishTestIfLastLoad()
+{
+    if (++loadCount == expectedLoadCount && window.testRunner)
+        testRunner.notifyDone();
+}
+
+function buildFrameset()
+{
+    if (window.testRunner) {
+        testRunner.waitUntilDone();
+        testRunner.dumpAsText();
+        testRunner.dumpChildFramesAsText();
+        if (testRunner.setShouldDecideNavigationPolicyAfterDelay)
+            testRunner.setShouldDecideNavigationPolicyAfterDelay(true);
+    }
+
+    var outHTML="<frameset rows=\"33%, 33%, 33%\">"+
+                "<frame src="" _onload_=\"finishTestIfLastLoad()\" name=\"topRow\">"+
+                "<frame src="" _onload_=\"finishTestIfLastLoad()\" name=\"middleRow\">"+
+                "<frame src="" _onload_=\"finishTestIfLastLoad()\" name=\"bottomRow\">"+
+                "</frameset>";
+
+    document.open("text/html","replace");
+    document.write(outHTML);
+    document.close();
+
+    outHTML = "<html><head><scr" + "ipt language=\"_javascript_\" src=""
+              "</scr" + "ipt></head><body _onLoad_=\"clickAnchor()\"><table><tr><td>"+
+              "<a href="" target=\"topRow\" id=\"anchorLink\">Click me. If nothing loads above we have a problem.</a>"+
+              "</td></tr></table></body></html>";
+
+    frames['topRow'].document.open("text/html","replace");
+    frames['topRow'].document.charset=document.charset;
+    frames['topRow'].document.write(outHTML);
+    frames['topRow'].document.close();
+
+    var localImageLocation = "file:///tmp/LayoutTests/fast/dom/resources/abe.png";
+    if (window.testRunner)
+        localImageLocation = testRunner.pathToLocalResource(localImageLocation);
+
+    outHTML = "<html><head><scr" + "ipt language=\"_javascript_\" src=""
+              "</scr" + "ipt></head><body _onLoad_=\"didImageLoad()\"><table><tr><td>"+
+              "<div id=\"result\"></div>"+
+              "<img src="" + localImageLocation + "\" id=\"myImg\">"+
+              "</td></tr></table></body></html>";
+
+    frames['middleRow'].document.open("text/html","replace");
+    frames['middleRow'].document.charset=document.charset;
+    frames['middleRow'].document.write(outHTML);
+    frames['middleRow'].document.close();
+
+    outHTML = "<html><head><scr" + "ipt language=\"_javascript_\" src=""
+              "</scr" + "ipt></head><body _onLoad_=\"didImageLoad()\"><table><tr><td>"+
+              "<div id=\"result\"></div>"+
+              "<img src="" id=\"myImg\">"+
+              "</td></tr></table></body></html>";
+
+    frames['bottomRow'].document.open("text/html","replace");
+    frames['bottomRow'].document.charset=document.charset;
+    frames['bottomRow'].document.write(outHTML);
+    frames['bottomRow'].document.close();
+}
+
+buildFrameset();
+
+</script>
+</head>
+
+<body>
+<p>_javascript_ FAILED! you should not see this.</p>
+</body>
+
+</html>
+

Modified: trunk/LayoutTests/http/tests/security/frame-loading-via-document-write-expected.txt (229538 => 229539)


--- trunk/LayoutTests/http/tests/security/frame-loading-via-document-write-expected.txt	2018-03-12 16:47:59 UTC (rev 229538)
+++ trunk/LayoutTests/http/tests/security/frame-loading-via-document-write-expected.txt	2018-03-12 17:50:53 UTC (rev 229539)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 1: Not allowed to load local resource: abe.png
 
 
 --------

Modified: trunk/LayoutTests/http/tests/security/frame-loading-via-document-write.html (229538 => 229539)


--- trunk/LayoutTests/http/tests/security/frame-loading-via-document-write.html	2018-03-12 16:47:59 UTC (rev 229538)
+++ trunk/LayoutTests/http/tests/security/frame-loading-via-document-write.html	2018-03-12 17:50:53 UTC (rev 229539)
@@ -4,6 +4,14 @@
 
 <script language="_javascript_">
 
+const expectedLoadCount = 7;
+let loadCount = 0;
+function finishTestIfLastLoad()
+{
+    if (++loadCount == expectedLoadCount && window.testRunner)
+        testRunner.notifyDone();
+}
+
 function buildFrameset()
 {
     if (window.testRunner) {
@@ -13,9 +21,9 @@
     }
 
     var outHTML="<frameset rows=\"33%, 33%, 33%\">"+
-                "<frame src="" name=\"topRow\">"+
-                "<frame src="" name=\"middleRow\">"+
-                "<frame src="" name=\"bottomRow\">"+
+                "<frame src="" _onload_=\"finishTestIfLastLoad()\" name=\"topRow\">"+
+                "<frame src="" _onload_=\"finishTestIfLastLoad()\" name=\"middleRow\">"+
+                "<frame src="" _onload_=\"finishTestIfLastLoad()\" name=\"bottomRow\">"+
                 "</frameset>";
 
     document.open("text/html","replace");
@@ -48,7 +56,7 @@
     frames['middleRow'].document.close();
 
     outHTML = "<html><head><scr" + "ipt language=\"_javascript_\" src=""
-              "</scr" + "ipt></head><body _onLoad_=\"lastTest()\"><table><tr><td>"+
+              "</scr" + "ipt></head><body _onLoad_=\"didImageLoad()\"><table><tr><td>"+
               "<div id=\"result\"></div>"+
               "<img src="" id=\"myImg\">"+
               "</td></tr></table></body></html>";

Modified: trunk/LayoutTests/http/tests/security/resources/frame-loading-via-document-write.js (229538 => 229539)


--- trunk/LayoutTests/http/tests/security/resources/frame-loading-via-document-write.js	2018-03-12 16:47:59 UTC (rev 229538)
+++ trunk/LayoutTests/http/tests/security/resources/frame-loading-via-document-write.js	2018-03-12 17:50:53 UTC (rev 229539)
@@ -17,11 +17,3 @@
     }
 }
 
-function lastTest()
-{
-    didImageLoad();
-
-    if (window.testRunner)
-        testRunner.notifyDone();
-}
-
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to