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

Side by Side Diff: LayoutTests/http/tests/serviceworker/skip-waiting-installed.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 installed worker</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/blank.html';
11 var url1 = 'resources/empty.js';
12 var url2 = 'resources/skip-waiting-installed-worker.js';
13 var frame, frame_sw, service_worker, onmessage, oncontrollerchanged;
14 var saw_message = new Promise(function(resolve) {
15 onmessage = function(e) {
16 var message = e.data;
17 assert_equals(
18 message, 'PASS',
19 'skipWaiting promise should be resolved after activated');
20 resolve();
21 };
22 });
23 var saw_controllerchanged = new Promise(function(resolve) {
24 oncontrollerchanged = function() {
25 assert_equals(
26 frame_sw.controller.scriptURL, normalizeURL(url2),
27 'Controller scriptURL should change to the second one');
28 resolve();
29 };
30 });
31 return service_worker_unregister_and_register(t, url1, scope)
32 .then(function(registration) {
33 return wait_for_state(t, registration.installing, 'activated');
34 })
35 .then(function() {
36 return with_iframe(scope);
37 })
38 .then(function(f) {
39 frame = f;
40 frame_sw = f.contentWindow.navigator.serviceWorker;
41 assert_equals(
42 frame_sw.controller.scriptURL, normalizeURL(url1),
43 'Document controller scriptURL should equal to the first one');
44 frame_sw.oncontrollerchange = t.step_func(oncontrollerchanged);
45 return navigator.serviceWorker.register(url2, {scope: scope});
46 })
47 .then(function(registration) {
48 return wait_for_update(t, registration);
49 })
50 .then(function(sw) {
51 service_worker = sw;
52 return wait_for_state(t, sw, 'installed');
falken 2014/12/15 06:54:04 you can collapse lines 48-52 into: service_worker
53 })
54 .then(function() {
55 var channel = new MessageChannel();
56 channel.port1.onmessage = t.step_func(onmessage);
57 service_worker.postMessage({port: channel.port2}, [channel.port2]);
58 return Promise.all([saw_message, saw_controllerchanged]);
59 })
60 .then(function() {
61 frame.remove();
62 return service_worker_unregister_and_done(t, scope);
63 });
64 }, 'Test skipWaiting when a installed worker is waiting');
65
66 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698