Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / serviceworker / controller-on-reload.html
blob3af4f3a37d0c6ed295e3787d059cb1ce3168db59
1 <!DOCTYPE html>
2 <title>Service Worker: Controller on reload</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 promise_test(function(t) {
9 var scope = 'resources/blank.html';
10 var frame;
11 return service_worker_unregister(t, scope)
12 .then(function() {
13 return with_iframe(scope);
15 .then(function(f) {
16 frame = f;
17 return frame.contentWindow.navigator.serviceWorker.register(
18 'resources/empty-worker.js', {scope: scope});
20 .then(function(registration) {
21 return wait_for_state(t, registration.installing, 'activated');
23 .then(function() {
24 var w = frame.contentWindow;
25 assert_equals(w.navigator.serviceWorker.controller, null,
26 'controller should be null until the document is ' +
27 'reloaded');
28 return new Promise(function(resolve) {
29 frame.onload = function() { resolve(); }
30 w.location.reload();
31 });
33 .then(function() {
34 var w = frame.contentWindow;
35 assert_true(
36 w.navigator.serviceWorker.controller instanceof w.ServiceWorker,
37 'controller should be a ServiceWorker object upon reload');
38 frame.remove();
39 service_worker_unregister_and_done(t, scope);
40 });
41 }, 'controller is set upon reload after registration');
42 </script>
43 </body>