Title: [221604] trunk/LayoutTests
Revision
221604
Author
[email protected]
Date
2017-09-04 20:31:20 -0700 (Mon, 04 Sep 2017)

Log Message

[iOS Simulator] http/tests/preload/viewport/meta-viewport-link-headers.php is a flaky failure.
https://bugs.webkit.org/show_bug.cgi?id=172518

This unflakes the test by downloading a "timer" image and kicking off the timer that runs the
test only once that image was downloaded, while potentially waiting for the preloaded images to arrive,
up to 1 second.
That means that slow test environments would have a longer timer than today, avoiding flakiness.

Reviewed by Youenn Fablet.

* http/tests/preload/viewport/meta-viewport-link-headers.php: Add a "timer" image, which load event starts the test.
* platform/ios/TestExpectations: Unflake the test in expectations.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (221603 => 221604)


--- trunk/LayoutTests/ChangeLog	2017-09-05 03:29:46 UTC (rev 221603)
+++ trunk/LayoutTests/ChangeLog	2017-09-05 03:31:20 UTC (rev 221604)
@@ -1,3 +1,18 @@
+2017-09-04  Yoav Weiss  <[email protected]>
+
+        [iOS Simulator] http/tests/preload/viewport/meta-viewport-link-headers.php is a flaky failure.
+        https://bugs.webkit.org/show_bug.cgi?id=172518
+
+        This unflakes the test by downloading a "timer" image and kicking off the timer that runs the
+        test only once that image was downloaded, while potentially waiting for the preloaded images to arrive,
+        up to 1 second.
+        That means that slow test environments would have a longer timer than today, avoiding flakiness.
+
+        Reviewed by Youenn Fablet.
+
+        * http/tests/preload/viewport/meta-viewport-link-headers.php: Add a "timer" image, which load event starts the test.
+        * platform/ios/TestExpectations: Unflake the test in expectations.
+
 2017-09-03  Darin Adler  <[email protected]>
 
         Fix a few minor problems found while working toward removing unneeded calls to updateStyle

Modified: trunk/LayoutTests/http/tests/preload/viewport/meta-viewport-link-headers.php (221603 => 221604)


--- trunk/LayoutTests/http/tests/preload/viewport/meta-viewport-link-headers.php	2017-09-05 03:29:46 UTC (rev 221603)
+++ trunk/LayoutTests/http/tests/preload/viewport/meta-viewport-link-headers.php	2017-09-05 03:31:20 UTC (rev 221604)
@@ -1,32 +1,45 @@
 <?php
+header("Link: <http://127.0.0.1:8000/resources/square100.png?timer>;rel=preload;as=image;\"", false);
 header("Link: <http://127.0.0.1:8000/resources/square100.png?control>;rel=preload;as=image;\"", false);
 header("Link: <http://127.0.0.1:8000/resources/square100.png?large>;rel=preload;as=image;media=\"(min-width: 300px)\"", false);
 header("Link: <http://127.0.0.1:8000/resources/square100.png?small>;rel=preload;as=image;media=\"(max-width: 299px)\"", false);
 ?>
-<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<!DOCTYPE html>
 <meta name="viewport" content="width=160">
 <script src=""
 <script src=""
 <script>
     var t = async_test('Makes sure that Link headers support the media attribute and respond to <meta content=viewport>');
-    window.addEventListener("load", t.step_func(function() {
-        var entries = performance.getEntriesByType("resource");
-        var controlLoaded = false;
-        var smallLoaded = false;
-        var largeLoaded = false;
-        for (var i = 0; i < entries.length; ++i) {
-            if (entries[i].name.indexOf("control") != -1)
-                controlLoaded = true;
-            else if (entries[i].name.indexOf("large") != -1)
-                largeLoaded = true;
-            else if (entries[i].name.indexOf("small") != -1)
-                smallLoaded = true;
-        }
-        assert_true(controlLoaded);
-        assert_false(largeLoaded);
-        assert_true(smallLoaded);
-        t.done();
+    var img = new Image();
+    var counter = 20;
+    var timeout = 50;
+    img.addEventListener("load", t.step_func(function(){
+        var test = function() {
+            var entries = performance.getEntriesByType("resource");
+            var controlLoaded = false;
+            var smallLoaded = false;
+            var largeLoaded = false;
+            for (var i = 0; i < entries.length; ++i) {
+                if (entries[i].name.indexOf("control") != -1)
+                    controlLoaded = true;
+                else if (entries[i].name.indexOf("large") != -1)
+                    largeLoaded = true;
+                else if (entries[i].name.indexOf("small") != -1)
+                    smallLoaded = true;
+            }
+            // It's possible that due to network variance, these resource downloads didn't yet finish.
+            // If so, wait a bit longer (up to 1 second).
+            if (!(controlLoaded || smallLoaded) && counter) {
+                --counter;
+                t.step_timeout(test, timeout);
+            }
+
+            assert_true(controlLoaded, "The control element should be loaded");
+            assert_false(largeLoaded, "The large element should not be loaded");
+            assert_true(smallLoaded, "The small element should be loaded");
+            t.done();
+        };
+        t.step_timeout(test, timeout);
     }));
+    img.src = ""
 </script>
-<script src=""
-

Modified: trunk/LayoutTests/platform/ios/TestExpectations (221603 => 221604)


--- trunk/LayoutTests/platform/ios/TestExpectations	2017-09-05 03:29:46 UTC (rev 221603)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2017-09-05 03:31:20 UTC (rev 221604)
@@ -2880,8 +2880,6 @@
 # This test is specific to Core Text.
 fast/text/font-lookup-dot-prefix-case-sensitive.html [ Pass ]
 
-webkit.org/b/172518 http/tests/preload/viewport/meta-viewport-link-headers.php [ Pass Failure ]
-
 # Missing support for 521-bit elliptic curves.
 crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521.html
 crypto/subtle/ec-import-spki-key-export-spki-key-p521.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to