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
56
57
58
59
60
61
62
63
64
65
66
67
|
<!DOCTYPE html>
<html>
<title>Service Workers: ready</title>
<head>
<link rel="help" href="https://w3c.github.io/ServiceWorker/#navigator-service-worker-ready">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<!--
`navigator.serviceWorker.ready` attribute must return the result of running
these steps:
1. Let `promise` be a newly-created [promise][1].
2. Return `promise`.
3. Run the following steps asynchronously:
1. Let `registration` be the result of running [_ScopeMatch
algorithm][2] with document's url as its argument.
2. If `registration` is null, then:
1. Wait for the document to have a matching [registration][3].
3. If the [registration][3], represented by `registration`, for the
document has an [active worker][4], then:
1. Resolve `promise` with the [ServiceWorker][5] object associated
with the [active worker][4].
2. Abort these steps.
4. If the [registration][3], represented by `registration`, for the
document has a [worker in waiting][6], then:
1. Resolve `promise` with the [ServiceWorker][5] object associated
with the [worker in waiting][6].
2. Abort these steps.
5. Wait until the [registration][3], represented by `registration`,
for the document acquires a [worker in waiting][6] through a new
[installation process][7].
6. Resolve `promise` with the [ServiceWorker][5] object associated
with the [worker in waiting][6].
Note that `ready` attribute is desinged in a way that the returned [promise][1]
will never reject. Instead, it waits until the [promise][1] resolves with a
newly installed [worker in waiting][6]. Hence, the `state` of the acquired
[`ServiceWorker`][8] object is either `installed`, `activating` or `activated`.
[1]: http://goo.gl/3TobQS
[2]: #scope-match-algorithm
[3]: #registration
[4]: #active-worker
[5]: #service-worker-interface
[6]: #worker-in-waiting
[7]: #installation-process
[8]: #service-worker
-->
<script>
test(function() {
// not_implemented();
}, "There are no tests for section ready so far.");
</script>
</body>
</html>
|