summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/waiting.https.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/service-workers/service-worker/waiting.https.html')
-rw-r--r--testing/web-platform/tests/service-workers/service-worker/waiting.https.html44
1 files changed, 44 insertions, 0 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/waiting.https.html b/testing/web-platform/tests/service-workers/service-worker/waiting.https.html
new file mode 100644
index 000000000..eff9c80a4
--- /dev/null
+++ b/testing/web-platform/tests/service-workers/service-worker/waiting.https.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<title>ServiceWorker: navigator.serviceWorker.waiting</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.sub.js"></script>
+<body>
+<script>
+// "waiting" is set
+async_test(function(t) {
+ var step = t.step_func.bind(t);
+ var url = 'resources/empty-worker.js';
+ var scope = 'resources/blank.html';
+ var frame;
+ var registration;
+
+ service_worker_unregister(t, scope)
+ .then(function() { return with_iframe(scope); })
+ .then(function(f) {
+ frame = f;
+ return navigator.serviceWorker.register(url, {scope: scope});
+ })
+ .then(function(r) {
+ registration = r;
+ return wait_for_state(t, r.installing, 'installed');
+ }, unreached_rejection(t, 'Registration should not fail'))
+ .then(function() {
+ var controller = frame.contentWindow.navigator.serviceWorker.controller;
+ assert_equals(controller, null);
+ // Nothing in the spec prohibits a worker from going to active
+ // immediately.
+ // Step 26 of the [[Install]] algorithm
+ // "If registration's waiting worker waitingWorker is not null and
+ // waitingWorker's skip waiting flag is not set, invoke Activate
+ // algorithm, or its equivalent, with registration as its argument."
+ var w = registration.waiting || registration.active;
+ assert_equals(w.scriptURL, normalizeURL(url));
+ assert_equals(registration.installing, null);
+ })
+ .then(function() {
+ frame.remove();
+ return service_worker_unregister_and_done(t, scope);
+ });
+}, 'waiting or active is set');
+</script>