http/tests/misc/location-replace-crossdomain.html is failing with async policy delegates
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Mar 2018 18:53:21 +0000 (18:53 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Mar 2018 18:53:21 +0000 (18:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183408

Reviewed by Alex Christensen.

The test was trying to navigate a cross-origin iframe via location.replace() and checking
that the load succeeded in a setTimeout(1). There is no guarantee that the frame has loaded
by that point. We would normally rely on the 'load' event but it is not feasible here since
the iframe is cross-origin. Instead, I opted to have the iframe to a page that posts a
message to its parent window to indicate that the load has succeeded.

* http/tests/misc/location-replace-crossdomain-async-delegates-expected.txt: Added.
* http/tests/misc/location-replace-crossdomain-async-delegates.html: Added.
* http/tests/misc/location-replace-crossdomain-expected.txt: Added.
* http/tests/misc/location-replace-crossdomain.html:
* platform/gtk/http/tests/misc/location-replace-crossdomain-expected.txt: Removed.
* platform/ios/http/tests/misc/location-replace-crossdomain-expected.txt: Removed.
* platform/mac/http/tests/misc/location-replace-crossdomain-expected.txt: Removed.
* platform/win/http/tests/misc/location-replace-crossdomain-expected.txt: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229371 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/misc/location-replace-crossdomain-async-delegates-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/misc/location-replace-crossdomain-async-delegates.html [new file with mode: 0644]
LayoutTests/http/tests/misc/location-replace-crossdomain-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/misc/location-replace-crossdomain.html
LayoutTests/platform/gtk/http/tests/misc/location-replace-crossdomain-expected.txt [deleted file]
LayoutTests/platform/ios/http/tests/misc/location-replace-crossdomain-expected.txt [deleted file]
LayoutTests/platform/mac/http/tests/misc/location-replace-crossdomain-expected.txt [deleted file]
LayoutTests/platform/win/http/tests/misc/location-replace-crossdomain-expected.txt [deleted file]

index 3dcd731..026ca5a 100644 (file)
@@ -1,3 +1,25 @@
+2018-03-07  Chris Dumez  <cdumez@apple.com>
+
+        http/tests/misc/location-replace-crossdomain.html is failing with async policy delegates
+        https://bugs.webkit.org/show_bug.cgi?id=183408
+
+        Reviewed by Alex Christensen.
+
+        The test was trying to navigate a cross-origin iframe via location.replace() and checking
+        that the load succeeded in a setTimeout(1). There is no guarantee that the frame has loaded
+        by that point. We would normally rely on the 'load' event but it is not feasible here since
+        the iframe is cross-origin. Instead, I opted to have the iframe to a page that posts a
+        message to its parent window to indicate that the load has succeeded.
+
+        * http/tests/misc/location-replace-crossdomain-async-delegates-expected.txt: Added.
+        * http/tests/misc/location-replace-crossdomain-async-delegates.html: Added.
+        * http/tests/misc/location-replace-crossdomain-expected.txt: Added.
+        * http/tests/misc/location-replace-crossdomain.html:
+        * platform/gtk/http/tests/misc/location-replace-crossdomain-expected.txt: Removed.
+        * platform/ios/http/tests/misc/location-replace-crossdomain-expected.txt: Removed.
+        * platform/mac/http/tests/misc/location-replace-crossdomain-expected.txt: Removed.
+        * platform/win/http/tests/misc/location-replace-crossdomain-expected.txt: Removed.
+
 2018-03-07  Per Arne Vollan  <pvollan@apple.com>
 
         Fix incorrect test expectations for http/wpt/resource-timing/rt-initiatorType-media.html.
diff --git a/LayoutTests/http/tests/misc/location-replace-crossdomain-async-delegates-expected.txt b/LayoutTests/http/tests/misc/location-replace-crossdomain-async-delegates-expected.txt
new file mode 100644 (file)
index 0000000..147de87
--- /dev/null
@@ -0,0 +1,11 @@
+Checks that a cross origin iframe can be navigated using location.replace().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Navigated cross-origin frame via Location.replace
+PASS window.frames['crossDomainFrame'].location.href is "http://127.0.0.1:8000/security/resources/postMessage.html"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/misc/location-replace-crossdomain-async-delegates.html b/LayoutTests/http/tests/misc/location-replace-crossdomain-async-delegates.html
new file mode 100644 (file)
index 0000000..e273246
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+description("Checks that a cross origin iframe can be navigated using location.replace().");
+jsTestIsAsync = true;
+
+if (window.testRunner && testRunner.setShouldDecideNavigationPolicyAfterDelay) 
+    testRunner.setShouldDecideNavigationPolicyAfterDelay(true);
+
+onload = function()
+{
+    addEventListener("message", function() {
+        testPassed("Navigated cross-origin frame via Location.replace");
+        shouldBeEqualToString("window.frames['crossDomainFrame'].location.href", "http://127.0.0.1:8000/security/resources/postMessage.html");
+        finishJSTest();
+    });
+    window.frames['crossDomainFrame'].location.replace("http://127.0.0.1:8000/security/resources/postMessage.html");
+    setTimeout(function() {
+        testFailed("Failed to navigate cross-origin frame via Location.replace");
+        finishJSTest();
+    }, 10000);
+}
+</script>
+<iframe id="crossDomainFrame" name="crossDomainFrame" src="http://localhost:8000/misc/resources/failure.html"></iframe>
+</body>
+</html>
+<!--     
+<rdar://problem/4808039> 
+http://bugs.webkit.org/show_bug.cgi?id=11230
+-->
diff --git a/LayoutTests/http/tests/misc/location-replace-crossdomain-expected.txt b/LayoutTests/http/tests/misc/location-replace-crossdomain-expected.txt
new file mode 100644 (file)
index 0000000..147de87
--- /dev/null
@@ -0,0 +1,11 @@
+Checks that a cross origin iframe can be navigated using location.replace().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Navigated cross-origin frame via Location.replace
+PASS window.frames['crossDomainFrame'].location.href is "http://127.0.0.1:8000/security/resources/postMessage.html"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
index 2202500..3792b64 100644 (file)
@@ -1,19 +1,25 @@
+<!DOCTYPE html>
 <html>
-<head>
+<body>
+<script src="/js-test-resources/js-test.js"></script>
 <script>
-function test()
-{    
-    window.frames['crossDomainFrame'].location.replace("http://127.0.0.1:8000/misc/resources/success.html");
-    if (window.testRunner)
-        setTimeout("testRunner.notifyDone()", 1);
-}
+description("Checks that a cross origin iframe can be navigated using location.replace().");
+jsTestIsAsync = true;
 
-if (window.testRunner)
-    testRunner.waitUntilDone();
-    
+onload = function()
+{
+    addEventListener("message", function() {
+        testPassed("Navigated cross-origin frame via Location.replace");
+        shouldBeEqualToString("window.frames['crossDomainFrame'].location.href", "http://127.0.0.1:8000/security/resources/postMessage.html");
+        finishJSTest();
+    });
+    window.frames['crossDomainFrame'].location.replace("http://127.0.0.1:8000/security/resources/postMessage.html");
+    setTimeout(function() {
+        testFailed("Failed to navigate cross-origin frame via Location.replace");
+        finishJSTest();
+    }, 10000);
+}
 </script>
-</head>
-<body onload="test();">
 <iframe id="crossDomainFrame" name="crossDomainFrame" src="http://localhost:8000/misc/resources/failure.html"></iframe>
 </body>
 </html>
diff --git a/LayoutTests/platform/gtk/http/tests/misc/location-replace-crossdomain-expected.txt b/LayoutTests/platform/gtk/http/tests/misc/location-replace-crossdomain-expected.txt
deleted file mode 100644 (file)
index 426938e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderIFrame {IFRAME} at (0,0) size 304x154 [border: (2px inset #000000)]
-        layer at (0,0) size 300x150
-          RenderView at (0,0) size 300x150
-        layer at (0,0) size 300x150
-          RenderBlock {HTML} at (0,0) size 300x150
-            RenderBody {BODY} at (8,8) size 284x134
-              RenderText {#text} at (0,0) size 71x17
-                text run at (0,0) width 71: "SUCCESS"
-      RenderText {#text} at (0,0) size 0x0
-      RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/platform/ios/http/tests/misc/location-replace-crossdomain-expected.txt b/LayoutTests/platform/ios/http/tests/misc/location-replace-crossdomain-expected.txt
deleted file mode 100644 (file)
index 7ee17b9..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderPartObject {IFRAME} at (0,0) size 304x154 [border: (2px inset #000000)]
-        layer at (0,0) size 300x150
-          RenderView at (0,0) size 300x150
-        layer at (0,0) size 300x150
-          RenderBlock {HTML} at (0,0) size 300x150
-            RenderBody {BODY} at (8,8) size 284x134
-              RenderText {#text} at (0,0) size 70x19
-                text run at (0,0) width 70: "SUCCESS"
-      RenderText {#text} at (0,0) size 0x0
-      RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/platform/mac/http/tests/misc/location-replace-crossdomain-expected.txt b/LayoutTests/platform/mac/http/tests/misc/location-replace-crossdomain-expected.txt
deleted file mode 100644 (file)
index 9ef1cde..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderIFrame {IFRAME} at (0,0) size 304x154 [border: (2px inset #000000)]
-        layer at (0,0) size 300x150
-          RenderView at (0,0) size 300x150
-        layer at (0,0) size 300x150
-          RenderBlock {HTML} at (0,0) size 300x150
-            RenderBody {BODY} at (8,8) size 284x134
-              RenderText {#text} at (0,0) size 70x18
-                text run at (0,0) width 70: "SUCCESS"
-      RenderText {#text} at (0,0) size 0x0
-      RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/platform/win/http/tests/misc/location-replace-crossdomain-expected.txt b/LayoutTests/platform/win/http/tests/misc/location-replace-crossdomain-expected.txt
deleted file mode 100644 (file)
index 915dd4b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderIFrame {IFRAME} at (0,0) size 304x154 [border: (2px inset #000000)]
-        layer at (0,0) size 300x150
-          RenderView at (0,0) size 300x150
-        layer at (0,0) size 300x150
-          RenderBlock {HTML} at (0,0) size 300x150
-            RenderBody {BODY} at (8,8) size 284x134
-              RenderText {#text} at (0,0) size 71x18
-                text run at (0,0) width 71: "SUCCESS"
-      RenderText {#text} at (0,0) size 0x0
-      RenderText {#text} at (0,0) size 0x0