Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: LayoutTests/http/tests/serviceworker/skip-waiting.html

Issue 765323002: ServiceWorker: Add support for .skipWaiting and controllerchange event(3/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: repick the not controlled test Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Service Worker: Skip waiting</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharness-helpers.js"></script>
5 <script src="../resources/testharnessreport.js"></script>
6 <script src="resources/test-helpers.js"></script>
7 <script>
8
9 promise_test(function(t) {
10 var scope = 'resources/simple.html';
11 var url = 'resources/skip-waiting-worker.js';
12 var frame, frame_sw;
13
14 return service_worker_unregister(t, scope)
15 .then(function() {
16 return with_iframe(scope);
17 })
18 .then(function(f) {
19 frame = f;
20 frame_sw = f.contentWindow.navigator.serviceWorker;
21 assert_equals(frame_sw.controller, null,
22 'Document controller should be null');
23 return navigator.serviceWorker.register(url, {scope: scope});
24 })
25 .then(function(registration) {
26 return wait_for_state(t, registration.installing, 'activated');
27 })
28 .then(function() {
29 assert_equals(frame_sw.controller, null,
30 'Document controller should still be null');
31 })
32 .then(function() {
33 frame.remove();
34 return service_worker_unregister_and_done(t, scope);
35 });
36 }, 'Test skipWaiting while a client is not being controlled');
37
38 promise_test(function(t) {
39 var scope = 'resources/blank.html';
40 var url1 = 'resources/empty.js';
41 var url2 = 'resources/skip-waiting-worker.js';
42 var frame, frame_sw, oncontrollerchanged;
43 var saw_controllerchanged = new Promise(function(resolve) {
44 oncontrollerchanged = function(e) {
45 assert_equals(e.type, 'controllerchange',
46 'Event name should be "controllerchange"');
47 assert_true(
48 e.target instanceof frame.contentWindow.ServiceWorkerContainer,
49 'Event target should be a ServiceWorkerContainer');
50 assert_equals(e.target.controller.state, 'activating',
51 'Controller state should be activating');
52 assert_equals(
53 frame_sw.controller.scriptURL, normalizeURL(url2),
54 'Controller scriptURL should change to the second one');
55 resolve();
56 };
57 });
58 return service_worker_unregister_and_register(t, url1, scope)
59 .then(function(registration) {
60 return wait_for_state(t, registration.installing, 'activated');
61 })
62 .then(function() {
63 return with_iframe(scope);
64 })
65 .then(function(f) {
66 frame = f;
67 frame_sw = f.contentWindow.navigator.serviceWorker;
68 assert_equals(
69 frame_sw.controller.scriptURL, normalizeURL(url1),
70 'Document controller scriptURL should equal to the first one');
71 frame_sw.oncontrollerchange = t.step_func(oncontrollerchanged);
72 return navigator.serviceWorker.register(url2, {scope: scope});
73 })
74 .then(function(registration) {
75 return Promise.all([saw_controllerchanged,
76 fetch_tests_from_worker(registration.installing)]) ;
77 })
78 .then(function() {
79 frame.remove();
80 return service_worker_unregister_and_done(t, scope);
81 });
82 }, 'Test skipWaiting while a client is using the registration');
83
84 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698