blob: 2a5bc1ae857adb9575b0be7351db7029ea564384 [file] [log] [blame]
Kunihiko Sakamoto1a4049a2017-09-27 09:54:311<!DOCTYPE html>
2<script nonce="abc" src="/resources/testharness.js"></script>
3<script nonce="abc" src="/resources/testharnessreport.js"></script>
Yutaka Hiranoba22f222022-06-30 06:32:144<script nonce="abc" src="/common/utils.js"></script>
Kunihiko Sakamoto1a4049a2017-09-27 09:54:315<script nonce="abc" src="/preload/resources/preload_helper.js"></script>
6<body>
7<script nonce="abc">
8
Yutaka Hiranoba22f222022-06-30 06:32:149promise_test(async (t) => {
10 verifyPreloadAndRTSupport();
11 const id = token();
12 const link = document.createElement("link");
13 link.as = "script";
14 link.rel = "preload";
15 link.href = stashPutUrl(id);
16 link.nonce = "abc";
17
18 const load = new Promise((resolve) => {
19 link.onload = resolve;
20 });
21 link.onerror = t.unreached_func("link.onerror");
22
23 document.body.appendChild(link);
24 await load;
25
26 const arrived = await hasArrivedAtServer(id);
27 assert_true(arrived, "The preload should've arrived at the server.");
Kunihiko Sakamoto1a4049a2017-09-27 09:54:3128}, "link preload with nonce attribute");
29
Yutaka Hiranoba22f222022-06-30 06:32:1430promise_test(async (t) => {
31 verifyPreloadAndRTSupport();
32 const id = token();
33 const link = document.createElement("link");
34 link.as = "script";
35 link.rel = "preload";
36 link.href = stashPutUrl(id);
37
38 const error = new Promise((resolve) => {
39 link.onerror = resolve;
40 });
41 link.onload = t.unreached_func("link.onload");
42
43 document.body.appendChild(link);
44 await error;
45
46 const arrived = await hasArrivedAtServer(id);
47 assert_false(arrived, "The preload should've arrived at the server.");
Kunihiko Sakamoto1a4049a2017-09-27 09:54:3148}, "link preload without nonce attribute");
49
50</script>
51</body>