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

Side by Side Diff: LayoutTests/http/tests/serviceworker/multiple-register.html

Issue 466723002: ServiceWorker: Enable ServiceWorkerRegistration and update layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@updatefound
Patch Set: rebase Created 6 years, 4 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 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/test-helpers.js"></script> 4 <script src="resources/test-helpers.js"></script>
5 <script> 5 <script>
6 var worker_url = 'resources/empty-worker.js'; 6 var worker_url = 'resources/empty-worker.js';
7 7
8 async_test(function(t) { 8 async_test(function(t) {
9 var scope = 'scope/subsequent-register'; 9 var scope = 'scope/subsequent-register';
10 var worker; 10 var worker;
11 var previous_registration;
11 12
12 service_worker_unregister_and_register(t, worker_url, scope) 13 service_worker_unregister_and_register(t, worker_url, scope)
13 .then(function(registered_worker) { 14 .then(function(registration) {
14 worker = registered_worker; 15 previous_registration = registration;
16 return wait_for_update(t, registration);
17 })
18 .then(function(installing_worker) {
19 worker = installing_worker;
15 return wait_for_state(t, worker, 'activated'); 20 return wait_for_state(t, worker, 'activated');
16 }) 21 })
17 .then(function() { 22 .then(function() {
18 return navigator.serviceWorker.register(worker_url, { scope: scope }); 23 return navigator.serviceWorker.register(worker_url, { scope: scope });
19 }) 24 })
20 .then(function(registered_worker) { 25 .then(function(registration) {
21 assert_equals(registered_worker, worker, 26 assert_equals(previous_registration, registration,
22 'register should resolve to the same worker'); 27 'register should resolve to the same registration');
23 assert_equals(registered_worker.state, 'activated', 28 // FIXME: When crbug.com/400602 is fixed, assert that active equals the
24 'the worker should be in state "activated"'); 29 // original worker.
30 assert_not_equals(registration.active, worker,
31 'register should resolve to the same worker');
32 assert_equals(registration.active.state, 'activated',
33 'the worker should be in state "activated"');
25 service_worker_unregister_and_done(t, scope); 34 service_worker_unregister_and_done(t, scope);
26 }) 35 })
27 .catch(unreached_rejection(t)); 36 .catch(unreached_rejection(t));
28 }, 'Subsequent registrations resolve to the same worker'); 37 }, 'Subsequent registrations resolve to the same registration object');
29 38
30 async_test(function(t) { 39 async_test(function(t) {
31 var scope = 'scope/concurrent-register'; 40 var scope = 'scope/concurrent-register';
32 var worker;
33 41
34 navigator.serviceWorker.unregister(scope) 42 navigator.serviceWorker.unregister(scope)
35 .then(function() { 43 .then(function() {
36 var promises = []; 44 var promises = [];
37 for (var i = 0; i < 100; ++i) { 45 for (var i = 0; i < 100; ++i) {
38 promises.push(navigator.serviceWorker.register(worker_url, 46 promises.push(navigator.serviceWorker.register(worker_url,
39 { scope: scope })); 47 { scope: scope }));
40 } 48 }
41 return Promise.all(promises); 49 return Promise.all(promises);
42 }) 50 })
43 .then(function(workers) { 51 .then(function(registrations) {
44 workers.forEach(function(worker) { 52 registrations.forEach(function(registration) {
45 assert_equals(worker, workers[0], 53 assert_equals(registration, registrations[0],
46 'register should resolve to the same worker'); 54 'register should resolve to the same registration');
47 }); 55 });
48 service_worker_unregister_and_done(t, scope); 56 service_worker_unregister_and_done(t, scope);
49 }) 57 })
50 .catch(unreached_rejection(t)); 58 .catch(unreached_rejection(t));
51 }, 'Concurrent registrations resolve to the same worker'); 59 }, 'Concurrent registrations resolve to the same registration object');
52 60
53 async_test(function(t) { 61 async_test(function(t) {
54 var scope = 'scope/multiple-frames'; 62 var scope = 'scope/multiple-frames';
55 var worker; 63 var previous_registration;
56 64
57 service_worker_unregister_and_register(t, worker_url, scope) 65 service_worker_unregister_and_register(t, worker_url, scope)
58 .then(function(registered_worker) { 66 .then(function(registration) {
59 worker = registered_worker; 67 previous_registration = registration;
60 return with_iframe('nothing-here.html'); 68 return with_iframe('nothing-here.html');
61 }) 69 })
62 .then(function(frame) { 70 .then(function(frame) {
63 return frame.contentWindow.navigator.serviceWorker.register( 71 return frame.contentWindow.navigator.serviceWorker.register(
64 worker_url, { scope: scope }); 72 worker_url, { scope: scope });
65 }) 73 })
66 .then(function(registered_worker) { 74 .then(function(registration) {
67 assert_not_equals(registered_worker, worker); 75 assert_not_equals(previous_registration, registration);
68 service_worker_unregister_and_done(t, scope); 76 service_worker_unregister_and_done(t, scope);
69 }) 77 })
70 .catch(unreached_rejection(t)); 78 .catch(unreached_rejection(t));
71 }, 'Registrations in separate frames resolve to different workers'); 79 }, 'Registrations in separate frames resolve to different ' +
80 'registration objects');
72 </script> 81 </script>
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/interfaces.html ('k') | LayoutTests/http/tests/serviceworker/postmessage.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698