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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/multiple-register.https.html

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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.sub.js"></script>
5 <body>
5 <script> 6 <script>
6 var worker_url = 'resources/empty-worker.js'; 7 var worker_url = 'resources/empty-worker.js';
7 8
8 async_test(function(t) { 9 async_test(function(t) {
9 var scope = 'resources/scope/subsequent-register-from-same-window'; 10 var scope = 'resources/scope/subsequent-register-from-same-window';
10 var registration; 11 var 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(r) { 14 .then(function(r) {
14 registration = r; 15 registration = r;
(...skipping 18 matching lines...) Expand all
33 async_test(function(t) { 34 async_test(function(t) {
34 var scope = 'resources/scope/subsequent-register-from-different-iframe'; 35 var scope = 'resources/scope/subsequent-register-from-different-iframe';
35 var frame; 36 var frame;
36 var registration; 37 var registration;
37 38
38 service_worker_unregister_and_register(t, worker_url, scope) 39 service_worker_unregister_and_register(t, worker_url, scope)
39 .then(function(r) { 40 .then(function(r) {
40 registration = r; 41 registration = r;
41 return wait_for_state(t, r.installing, 'activated'); 42 return wait_for_state(t, r.installing, 'activated');
42 }) 43 })
43 .then(function() { return with_iframe('out-of-scope'); }) 44 .then(function() { return with_iframe('resources/404.py'); })
44 .then(function(f) { 45 .then(function(f) {
45 frame = f; 46 frame = f;
46 return frame.contentWindow.navigator.serviceWorker.register( 47 return frame.contentWindow.navigator.serviceWorker.register(
47 worker_url, { scope: scope }); 48 worker_url, { scope: scope });
48 }) 49 })
49 .then(function(new_registration) { 50 .then(function(new_registration) {
50 assert_not_equals( 51 assert_not_equals(
51 registration, new_registration, 52 registration, new_registration,
52 'register should resolve to a different registration'); 53 'register should resolve to a different registration');
53 assert_equals( 54 assert_equals(
54 registration.scope, new_registration.scope, 55 registration.scope, new_registration.scope,
55 'registrations should have the same scope'); 56 'registrations should have the same scope');
56 57
57 assert_equals( 58 assert_equals(
58 registration.installing, null, 59 registration.installing, null,
59 'installing worker should be null'); 60 'installing worker should be null');
60 assert_equals( 61 assert_equals(
61 new_registration.installing, null, 62 new_registration.installing, null,
62 'installing worker should be null'); 63 'installing worker should be null');
63 assert_equals( 64 assert_equals(
64 registration.waiting, null, 65 registration.waiting, null,
65 'waiting worker should be null') 66 'waiting worker should be null')
66 assert_equals( 67 assert_equals(
67 new_registration.waiting, null, 68 new_registration.waiting, null,
68 'waiting worker should be null') 69 'waiting worker should be null')
69 70
70 assert_not_equals( 71 assert_not_equals(
71 registration.active, new_registration.active, 72 registration.active, new_registration.active,
72 'registration should have a different active worker'); 73 'registration should have the different active worker');
73 assert_equals( 74 assert_equals(
74 registration.active.scriptURL, 75 registration.active.scriptURL,
75 new_registration.active.scriptURL, 76 new_registration.active.scriptURL,
76 'active workers should have the same script URL'); 77 'active workers should have the same script URL');
77 assert_equals( 78 assert_equals(
78 registration.active.state, 79 registration.active.state,
79 new_registration.active.state, 80 new_registration.active.state,
80 'active workers should be in the same state'); 81 'active workers should be in the same state');
81 82
82 frame.remove(); 83 frame.remove();
83 return registration.unregister(); 84 return registration.unregister();
84 }) 85 })
85 .then(function() { t.done(); }) 86 .then(function() { t.done(); })
86 .catch(unreached_rejection(t)); 87 .catch(unreached_rejection(t));
87 }, 'Subsequent registrations from a different iframe resolve to the ' + 88 }, 'Subsequent registrations from a different iframe resolve to the ' +
88 'different registration object but they refer to the same ' + 89 'different registration object but they refer to the same ' +
89 'registration and workers'); 90 'registration and workers');
90 91
91 async_test(function(t) { 92 async_test(function(t) {
92 var scope = 'resources/scope/concurrent-register'; 93 var scope = 'resources/scope/concurrent-register';
93 var number_of_registrations = 10;
94 94
95 service_worker_unregister(t, scope) 95 service_worker_unregister(t, scope)
96 .then(function() { 96 .then(function() {
97 var promises = []; 97 var promises = [];
98 for (var i = 0; i < number_of_registrations; ++i) { 98 for (var i = 0; i < 10; ++i) {
99 promises.push(navigator.serviceWorker.register(worker_url, 99 promises.push(navigator.serviceWorker.register(worker_url,
100 { scope: scope })); 100 { scope: scope }));
101 } 101 }
102 return Promise.all(promises); 102 return Promise.all(promises);
103 }) 103 })
104 .then(function(registrations) { 104 .then(function(registrations) {
105 registrations.forEach(function(registration) { 105 registrations.forEach(function(registration) {
106 assert_equals(registration, registrations[0], 106 assert_equals(registration, registrations[0],
107 'register should resolve to the same registration'); 107 'register should resolve to the same registration');
108 }); 108 });
109 return registrations[0].unregister(); 109 return registrations[0].unregister();
110 }) 110 })
111 .then(function() { t.done(); }) 111 .then(function() { t.done(); })
112 .catch(unreached_rejection(t)); 112 .catch(unreached_rejection(t));
113 }, 'Concurrent registrations resolve to the same registration object'); 113 }, 'Concurrent registrations resolve to the same registration object');
114 114
115 </script> 115 </script>
116 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698