Bug 1332440 - Fix race condition in single-download-late-used-preload test. a=test-only
authorJames Graham <james@hoppipolla.co.uk>
Tue, 28 Feb 2017 09:48:00 -0500
changeset 376478 ab0887b15c691245ad28522a8227ae63df97738e
parent 376477 f887fafcd4a9a62145ae2dc23f4cc2b3e9fe2275
child 376479 a8b6ae21249233027c2e125225f0905a16e98fb7
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstest-only
bugs1332440
milestone53.0a2
Bug 1332440 - Fix race condition in single-download-late-used-preload test. a=test-only MozReview-Commit-ID: 5s3fUlnwxBw
testing/web-platform/meta/preload/single-download-late-used-preload.html.ini
testing/web-platform/tests/preload/single-download-late-used-preload.html
testing/web-platform/tests/preload/single_download_late_used_preload.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/preload/single-download-late-used-preload.html.ini
@@ -0,0 +1,5 @@
+[single-download-late-used-preload.html]
+  type: testharness
+  [Ensure preloaded resources are not downloaded again when used]
+    expected: FAIL
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/preload/single-download-late-used-preload.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<title>Ensure preloaded resources are not downloaded again when used</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/preload/resources/preload_helper.js"></script>
+<link rel=preload href="resources/square.png?pipe=trickle(d1)" as=image>
+<script>
+    var link = document.getElementsByTagName("link")[0]
+    assert_equals(link.as, "image");
+    link.addEventListener("load", () => {
+        verifyPreloadAndRTSupport();
+        verifyNumberOfDownloads("resources/square.png?pipe=trickle(d1)", 1);
+        var img = document.createElement("img");
+        img.src = "resources/square.png?pipe=trickle(d1)";
+        img.onload = () => {
+            verifyNumberOfDownloads("resources/square.png?pipe=trickle(d1)", 1);
+            done();
+        };
+        document.body.appendChild(img);
+    });
+</script>
+<body>
deleted file mode 100644
--- a/testing/web-platform/tests/preload/single_download_late_used_preload.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE html>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
-    var t = async_test('Makes sure that preloaded resources are not downloaded again when used');
-</script>
-<div id=result></div>
-<link rel=preload href="resources/square.png" as=image>
-<script>
-    window.addEventListener("load", t.step_func(function() {
-        t.step_timeout(function() {
-            document.getElementById("result").innerHTML = "<image src='resources/square.png'>";
-            t.step_timeout(function() {
-                assert_equals(performance.getEntriesByType("resource").length, 3);
-                t.done();
-            }, 1000);
-        }, 1000);
-    }));
-</script>