1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<!DOCTYPE html>
<meta charset="utf-8">
<title>Tests for importScripts: redirect</title>
<script src="/common/utils.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<body>
<script>
promise_test(async t => {
const scope = 'resources/import-scripts-redirect';
await service_worker_unregister(t, scope);
let reg = await navigator.serviceWorker.register(
'resources/import-scripts-redirect-worker.js', { scope: scope });
assert_not_equals(reg.installing, null, 'worker is installing');
await reg.unregister();
}, 'importScripts() supports redirects');
promise_test(async t => {
const scope = 'resources/import-scripts-redirect';
await service_worker_unregister(t, scope);
let reg = await navigator.serviceWorker.register(
'resources/import-scripts-redirect-worker.js', { scope: scope });
assert_not_equals(reg.installing, null, 'before update');
await wait_for_state(t, reg.installing, 'activated');
await Promise.all([
wait_for_update(t, reg),
reg.update()
]);
assert_not_equals(reg.installing, null, 'after update');
await reg.unregister();
},
"an imported script redirects, and the body changes during the update check");
promise_test(async t => {
const key = token();
const scope = 'resources/import-scripts-redirect';
await service_worker_unregister(t, scope);
let reg = await navigator.serviceWorker.register(
`resources/import-scripts-redirect-on-second-time-worker.js?Key=${key}`,
{ scope });
t.add_cleanup(() => reg.unregister());
assert_not_equals(reg.installing, null, 'before update');
await wait_for_state(t, reg.installing, 'activated');
await Promise.all([
wait_for_update(t, reg),
reg.update()
]);
assert_not_equals(reg.installing, null, 'after update');
},
"an imported script doesn't redirect initially, then redirects during " +
"the update check and the body changes");
</script>
</body>
|