gecko-dev/testing/web-platform/tests/preload/dynamic-adding-preload-nonce.html
Kunihiko Sakamoto 27d81ff0b9 Bug 1526643 [wpt PR 15129] - Fix remaining preload tests flaking on wpt.fyi, a=testonly
Automatic update from web-platform-tests
Fix remaining preload tests flaking on wpt.fyi

This is a follow-up to https://github.com/web-platform-tests/wpt/pull/15075.

https://crrev.com/c/1436777 successfully fixed the wpt.fyi flakiness
for link-header-preload-srcset.tentative.html and
link-header-preload-nonce.html. This patch fixes that for the remaining
preload tests.

- Use step_timeout instead of dummy.js?pipe=trickle, because
  dummy.js?pipe=trickle may be loaded from cache with no delay.
- Replace verifyNumberOfDownloads() with
  - verifyNumberOfResourceTimingEntries() if possible
  - A new helper function verifyLoadedAndNoDoubleDownload() that
    doesn't fail if the resource was already cached before running
    the test.

Bug: 922343
Change-Id: Ia9b7c4bd49dd76463df4607349fe4f935e5410d0
Reviewed-on: https://chromium-review.googlesource.com/c/1442020
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629029}

--

wpt-commits: eb5aa0038ee7a938beabbe4c732a685af2581dbc
wpt-pr: 15129
2019-02-26 12:05:22 +00:00

40 lines
1.3 KiB
HTML

<!DOCTYPE html>
<script nonce="abc" src="/resources/testharness.js"></script>
<script nonce="abc" src="/resources/testharnessreport.js"></script>
<script nonce="abc" src="/preload/resources/preload_helper.js"></script>
<body>
<script nonce="abc">
async_test(function(t) {
verifyPreloadAndRTSupport();
var link = document.createElement("link");
link.as = "script";
link.rel = "preload";
link.href = "resources/dummy.js?with-nonce";
link.nonce = "abc";
link.onload = link.onerror = t.step_func(function() {
t.step_timeout(function() {
verifyNumberOfResourceTimingEntries("resources/dummy.js?with-nonce", 1);
t.done();
}, 0);
});
document.body.appendChild(link);
}, "link preload with nonce attribute");
async_test(function(t) {
verifyPreloadAndRTSupport();
var link = document.createElement("link");
link.as = "script";
link.rel = "preload";
link.href = "resources/dummy.js?without-nonce";
link.onload = link.onerror = t.step_func(function() {
t.step_timeout(function() {
verifyNumberOfResourceTimingEntries("resources/dummy.js?without-nonce", 0);
t.done();
}, 0);
});
document.body.appendChild(link);
}, "link preload without nonce attribute");
</script>
</body>