Make mixed content basic auth tests more robust
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Feb 2018 21:00:52 +0000 (21:00 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Feb 2018 21:00:52 +0000 (21:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182537

Reviewed by Chris Dumez.

Load the test image programmatically instead of declaratively to avoid output flakiness caused by
the preload scanner preloading the test image. The preload scanner performs mixed content checks
and this can cause duplicate mixed content warnings in the test output.

* http/tests/security/mixedContent/secure-redirect-to-insecure-redirect-to-basic-auth-secure-image.https.html:
* http/tests/security/mixedContent/secure-redirect-to-secure-redirect-to-basic-auth-secure-image.https.html:

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

LayoutTests/ChangeLog
LayoutTests/http/tests/security/mixedContent/secure-redirect-to-insecure-redirect-to-basic-auth-secure-image.https.html
LayoutTests/http/tests/security/mixedContent/secure-redirect-to-secure-redirect-to-basic-auth-secure-image.https.html

index 6418184..dd7dd3b 100644 (file)
@@ -1,3 +1,17 @@
+2018-02-06  Daniel Bates  <dabates@apple.com>
+
+        Make mixed content basic auth tests more robust
+        https://bugs.webkit.org/show_bug.cgi?id=182537
+
+        Reviewed by Chris Dumez.
+
+        Load the test image programmatically instead of declaratively to avoid output flakiness caused by
+        the preload scanner preloading the test image. The preload scanner performs mixed content checks
+        and this can cause duplicate mixed content warnings in the test output.
+
+        * http/tests/security/mixedContent/secure-redirect-to-insecure-redirect-to-basic-auth-secure-image.https.html:
+        * http/tests/security/mixedContent/secure-redirect-to-secure-redirect-to-basic-auth-secure-image.https.html:
+
 2018-02-06  Antoine Quint  <graouts@apple.com>
 
         [Modern Media Controls] Test at media/modern-media-controls/tracks-panel/tracks-panel-controls-bar-remains-visible-after-clicking-over-it.html fails
index 95f9c5e..ecb69f3 100644 (file)
@@ -22,10 +22,22 @@ function fail()
     testFailed("did load image.");
     finishJSTest();
 }
+
+function runTest()
+{
+    // Load the image programmatically instead of declaratively to avoid output flakiness caused by
+    // the preload scanner performing mixed content checks as part of preloading the image.
+    let image = new Image;
+    image.onload = fail;
+    image.onerror = pass;
+    image.src = "https://127.0.0.1:8443/resources/redirect.php?url=http%3A//127.0.0.1%3A8080/resources/redirect.php%3Furl%3Dhttps%3A//localhost%3A8443/security/mixedContent/resources/subresource/protected-image.php";
+    document.body.appendChild(image);
+}
+
+window.onload = runTest;
 </script>
 <script>
 description("This test loads a secure image that redirects to an insecure image that redirects to a secure image guarded by basic authentication. The secure image should be blocked because it requires credentials and was loaded via an insecure redirect.");
 </script>
-<img src="https://127.0.0.1:8443/resources/redirect.php?url=http%3A//127.0.0.1%3A8080/resources/redirect.php%3Furl%3Dhttps%3A//localhost%3A8443/security/mixedContent/resources/subresource/protected-image.php" onerror="pass()" onload="fail()">
 </body>
 </html>
index 9dd075f..e374855 100644 (file)
@@ -22,10 +22,22 @@ function fail()
     testFailed("did not load image.");
     finishJSTest();
 }
+
+function runTest()
+{
+    // Load the image programmatically instead of declaratively to avoid output flakiness caused by
+    // the preload scanner performing mixed content checks as part of preloading the image.
+    let image = new Image;
+    image.onload = pass;
+    image.onerror = fail;
+    image.src = "https://127.0.0.1:8443/resources/redirect.php?url=https%3A//127.0.0.1%3A8443/resources/redirect.php%3Furl%3Dhttps%3A//localhost%3A8443/security/mixedContent/resources/subresource/protected-image.php";
+    document.body.appendChild(image);
+}
+
+window.onload = runTest;
 </script>
 <script>
 description("This test loads a secure image that redirects to a secure image that redirects to a secure image guarded by basic authentication. The secure image should load.");
 </script>
-<img src="https://127.0.0.1:8443/resources/redirect.php?url=https%3A//127.0.0.1%3A8443/resources/redirect.php%3Furl%3Dhttps%3A//localhost%3A8443/security/mixedContent/resources/subresource/protected-image.php" onerror="fail()" onload="pass()">
 </body>
 </html>