Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / serviceworker / waiting.html
1 <!DOCTYPE html>
2 <title>ServiceWorker: navigator.serviceWorker.waiting</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script>
6 <body>
7 <script>
8 // "waiting" is set
9 async_test(function(t) {
10     var step = t.step_func.bind(t);
11     var url = 'resources/empty-worker.js';
12     var scope = 'resources/blank.html';
13     var frame;
14     var registration;
15
16     service_worker_unregister(t, scope)
17     .then(function() { return with_iframe(scope); })
18     .then(function(f) {
19         frame = f;
20         return navigator.serviceWorker.register(url, {scope: scope});
21       })
22     .then(function(r) {
23         registration = r;
24         return wait_for_update(t, registration);
25       })
26     .then(function(serviceWorker) {
27         return wait_for_state(t, serviceWorker, 'installed');
28       }, unreached_rejection(t, 'Registration should not fail'))
29     .then(function() {
30         var controller = frame.contentWindow.navigator.serviceWorker.controller;
31         assert_equals(controller, null);
32         assert_equals(registration.active, null);
33         assert_equals(registration.waiting.scriptURL, normalizeURL(url));
34         assert_equals(registration.installing, null);
35
36         // FIXME: Add a test for a frame created after installation.
37         // Should the existing frame ("frame") block activation?
38       })
39     .then(function() {
40         frame.remove();
41         return service_worker_unregister_and_done(t, scope);
42       });
43 }, 'waiting is set');
44 </script>