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

Side by Side Diff: LayoutTests/http/tests/serviceworker/registration-end-to-end.html

Issue 517223002: ServiceWorker: Tweak layout tests based on the latest install sequence (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 3 months 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: registration end-to-end</title> 2 <title>Service Worker: registration end-to-end</title>
3 <script src="../resources/testharness.js"></script> 3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script> 5 <script src="resources/test-helpers.js"></script>
6 <script> 6 <script>
7 var t = async_test('Registration: end-to-end'); 7 var t = async_test('Registration: end-to-end');
8 t.step(function() { 8 t.step(function() {
9 9
10 var scope = '/in-scope/'; 10 var scope = '/in-scope/';
11 var serviceWorkerStates = []; 11 var serviceWorkerStates = [];
12 var lastServiceWorkerState = ''; 12 var lastServiceWorkerState = '';
13 var receivedMessageFromPort = ''; 13 var receivedMessageFromPort = '';
14 var currentChangeCount = 0; 14 var currentChangeCount = 0;
15 15
16 assert_true(navigator.serviceWorker instanceof ServiceWorkerContainer); 16 assert_true(navigator.serviceWorker instanceof ServiceWorkerContainer);
17 assert_equals(typeof navigator.serviceWorker.register, 'function'); 17 assert_equals(typeof navigator.serviceWorker.register, 'function');
18 assert_equals(typeof navigator.serviceWorker.unregister, 'function'); 18 assert_equals(typeof navigator.serviceWorker.unregister, 'function');
19 19
20 navigator.serviceWorker.oncurrentchange = function() { 20 navigator.serviceWorker.oncurrentchange = function() {
21 ++currentChangeCount; 21 ++currentChangeCount;
22 }; 22 };
23 23
24 service_worker_unregister_and_register( 24 service_worker_unregister_and_register(
25 t, 'resources/end-to-end-worker.js', scope) 25 t, 'resources/end-to-end-worker.js', scope)
26 .then(function(registration) {
27 return wait_for_update(t, registration);
28 })
29 .then(onRegister) 26 .then(onRegister)
30 .catch(unreached_rejection(t)); 27 .catch(unreached_rejection(t));
31 28
32 function sendMessagePort(worker, from) { 29 function sendMessagePort(worker, from) {
33 var messageChannel = new MessageChannel(); 30 var messageChannel = new MessageChannel();
34 worker.postMessage({from:from, port:messageChannel.port2}, [messageChann el.port2]); 31 worker.postMessage({from:from, port:messageChannel.port2}, [messageChann el.port2]);
35 return messageChannel.port1; 32 return messageChannel.port1;
36 } 33 }
37 34
38 function onRegister(sw) { 35 function onRegister(registration) {
36 var sw = registration.installing;
39 serviceWorkerStates.push(sw.state); 37 serviceWorkerStates.push(sw.state);
40 lastServiceWorkerState = sw.state; 38 lastServiceWorkerState = sw.state;
41 39
42 var sawMessage = new Promise(t.step_func(function(resolve) { 40 var sawMessage = new Promise(t.step_func(function(resolve) {
43 sendMessagePort(sw, 'registering doc').onmessage = t.step_func(funct ion (e) { 41 sendMessagePort(sw, 'registering doc').onmessage = t.step_func(funct ion (e) {
44 receivedMessageFromPort = e.data; 42 receivedMessageFromPort = e.data;
45 resolve(); 43 resolve();
46 }); 44 });
47 })); 45 }));
48 46
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 }); 90 });
93 })); 91 }));
94 navigator.serviceWorker.unregister(scope); 92 navigator.serviceWorker.unregister(scope);
95 sawRedundant.then(t.step_func(function() { 93 sawRedundant.then(t.step_func(function() {
96 t.done(); 94 t.done();
97 })); 95 }));
98 })); 96 }));
99 } 97 }
100 }); 98 });
101 </script> 99 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698