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

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

Issue 723923002: ServiceWorker: Add support for .skipWaiting and controllerchange event(1/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: webcallback->skipwaitingcallbacks, test re-write 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/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script>
6 <script>
7
8 promise_test(function(t) {
9 var scope = 'resources/blank.html';
10 var url1 = 'resources/empty.js';
11 var url2 = 'resources/skip-waiting-installed-worker.js';
12 var iframeContainer, serviceWorker, onMessage, onControllerChanged;
13 var promise1 = new Promise(function(resolve) {
14 onMessage = function(e) {
15 var message = e.data;
16 assert_equals(
17 message, 'PASS',
18 'skipWaiting promise should be resolved after activated');
19 resolve();
20 };
21 });
22 var promise2 = new Promise(function(resolve) {
23 onControllerChanged = function() {
24 assert_equals(
25 iframeContainer.controller.scriptURL, normalizeURL(url2),
26 'Controller scriptURL should change to the second one');
27 resolve();
28 };
29 });
30 return service_worker_unregister_and_register(t, url1, scope)
31 .then(function(registration) {
32 return wait_for_update(t, registration);
33 })
34 .then(function(sw) {
35 return wait_for_state(t, sw, 'activated');
36 })
37 .then(function() {
38 return with_iframe(scope);
39 })
40 .then(function(frame) {
41 iframeContainer = frame.contentWindow.navigator.serviceWorker;
42 assert_equals(
43 iframeContainer.controller.scriptURL, normalizeURL(url1),
44 'Document controller scriptURL should equal to the first one');
45 iframeContainer.oncontrollerchange = t.step_func(onControllerChanged);
46 return navigator.serviceWorker.register(url2, {scope: scope});
47 })
48 .then(function(registration) {
49 return wait_for_update(t, registration);
50 })
51 .then(function(sw) {
52 serviceWorker = sw;
53 return wait_for_state(t, sw, 'installed');
54 })
55 .then(function() {
56 var channel = new MessageChannel();
57 channel.port1.onmessage = t.step_func(onMessage);
58 serviceWorker.postMessage({port: channel.port2}, [channel.port2]);
59 return Promise.all([promise1, promise2]);
60 })
61 .then(function() {
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