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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/registration-tests.js

Issue 2059953003: service worker: Fix the type of a register promise reject value (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Use ServiceWorkerErrorForUpdate directly Created 4 years, 5 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 function registration_tests(register_method, check_error_types) { 1 function registration_tests(register_method, check_error_types) {
2 // The navigator.serviceWorker.register() method guarantees that the newly 2 // The navigator.serviceWorker.register() method guarantees that the newly
3 // installing worker is available as registration.installing when its promise 3 // installing worker is available as registration.installing when its promise
4 // resolves. However these tests are also used to test installation using a 4 // resolves. However these tests are also used to test installation using a
5 // <link> element where it is possible for the installing worker to have 5 // <link> element where it is possible for the installing worker to have
6 // already become the waiting or active worker. So This method is used to get 6 // already become the waiting or active worker. So This method is used to get
7 // the newest worker when these tests need access to the ServiceWorker itself. 7 // the newest worker when these tests need access to the ServiceWorker itself.
8 function get_newest_worker(registration) { 8 function get_newest_worker(registration) {
9 if (registration.installing) 9 if (registration.installing)
10 return registration.installing; 10 return registration.installing;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return promise_rejects(t, 89 return promise_rejects(t,
90 check_error_types ? 'SecurityError' : null, 90 check_error_types ? 'SecurityError' : null,
91 register_method(script, {scope: scope}), 91 register_method(script, {scope: scope}),
92 'Registration script outside domain should fail with SecurityError.'); 92 'Registration script outside domain should fail with SecurityError.');
93 }, 'Registering script outside domain'); 93 }, 'Registering script outside domain');
94 94
95 promise_test(function(t) { 95 promise_test(function(t) {
96 var script = 'resources/no-such-worker.js'; 96 var script = 'resources/no-such-worker.js';
97 var scope = 'resources/scope/no-such-worker'; 97 var scope = 'resources/scope/no-such-worker';
98 return promise_rejects(t, 98 return promise_rejects(t,
99 check_error_types ? 'NetworkError' : null, 99 check_error_types ? new TypeError : null,
100 register_method(script, {scope: scope}), 100 register_method(script, {scope: scope}),
101 navigator.serviceWorker.register(script, {scope: scope}), 101 navigator.serviceWorker.register(script, {scope: scope}),
102 'Registration of non-existent script should fail.'); 102 'Registration of non-existent script should fail.');
103 }, 'Registering non-existent script'); 103 }, 'Registering non-existent script');
104 104
105 promise_test(function(t) { 105 promise_test(function(t) {
106 var script = 'resources/invalid-chunked-encoding.php'; 106 var script = 'resources/invalid-chunked-encoding.php';
107 var scope = 'resources/scope/invalid-chunked-encoding/'; 107 var scope = 'resources/scope/invalid-chunked-encoding/';
108 return promise_rejects(t, 108 return promise_rejects(t,
109 check_error_types ? 'NetworkError' : null, 109 check_error_types ? new TypeError : null,
110 register_method(script, {scope: scope}), 110 register_method(script, {scope: scope}),
111 'Registration of invalid chunked encoding script should fail.'); 111 'Registration of invalid chunked encoding script should fail.');
112 }, 'Registering invalid chunked encoding script'); 112 }, 'Registering invalid chunked encoding script');
113 113
114 promise_test(function(t) { 114 promise_test(function(t) {
115 var script = 'resources/invalid-chunked-encoding-with-flush.php'; 115 var script = 'resources/invalid-chunked-encoding-with-flush.php';
116 var scope = 'resources/scope/invalid-chunked-encoding-with-flush/'; 116 var scope = 'resources/scope/invalid-chunked-encoding-with-flush/';
117 return promise_rejects(t, 117 return promise_rejects(t,
118 check_error_types ? 'NetworkError' : null, 118 check_error_types ? new TypeError : null,
119 register_method(script, {scope: scope}), 119 register_method(script, {scope: scope}),
120 'Registration of invalid chunked encoding script should fail.'); 120 'Registration of invalid chunked encoding script should fail.');
121 }, 'Registering invalid chunked encoding script with flush'); 121 }, 'Registering invalid chunked encoding script with flush');
122 122
123 promise_test(function(t) { 123 promise_test(function(t) {
124 var script = 'resources/mime-type-worker.php'; 124 var script = 'resources/mime-type-worker.php';
125 var scope = 'resources/scope/no-mime-type-worker/'; 125 var scope = 'resources/scope/no-mime-type-worker/';
126 return promise_rejects(t, 126 return promise_rejects(t,
127 check_error_types ? 'SecurityError' : null, 127 check_error_types ? 'SecurityError' : null,
128 register_method(script, {scope: scope}), 128 register_method(script, {scope: scope}),
(...skipping 16 matching lines...) Expand all
145 return promise_rejects(t, 145 return promise_rejects(t,
146 check_error_types ? 'SecurityError' : null, 146 check_error_types ? 'SecurityError' : null,
147 register_method(script, {scope: scope}), 147 register_method(script, {scope: scope}),
148 'Registration of redirected script should fail.'); 148 'Registration of redirected script should fail.');
149 }, 'Registering redirected script'); 149 }, 'Registering redirected script');
150 150
151 promise_test(function(t) { 151 promise_test(function(t) {
152 var script = 'resources/malformed-worker.php?parse-error'; 152 var script = 'resources/malformed-worker.php?parse-error';
153 var scope = 'resources/scope/parse-error'; 153 var scope = 'resources/scope/parse-error';
154 return promise_rejects(t, 154 return promise_rejects(t,
155 check_error_types ? 'AbortError' : null, 155 check_error_types ? new TypeError : null,
156 register_method(script, {scope: scope}), 156 register_method(script, {scope: scope}),
157 'Registration of script including parse error should fail.'); 157 'Registration of script including parse error should fail.');
158 }, 'Registering script including parse error'); 158 }, 'Registering script including parse error');
159 159
160 promise_test(function(t) { 160 promise_test(function(t) {
161 var script = 'resources/malformed-worker.php?undefined-error'; 161 var script = 'resources/malformed-worker.php?undefined-error';
162 var scope = 'resources/scope/undefined-error'; 162 var scope = 'resources/scope/undefined-error';
163 return promise_rejects(t, 163 return promise_rejects(t,
164 check_error_types ? 'AbortError' : null, 164 check_error_types ? new TypeError : null,
165 register_method(script, {scope: scope}), 165 register_method(script, {scope: scope}),
166 'Registration of script including undefined error should fail.'); 166 'Registration of script including undefined error should fail.');
167 }, 'Registering script including undefined error'); 167 }, 'Registering script including undefined error');
168 168
169 promise_test(function(t) { 169 promise_test(function(t) {
170 var script = 'resources/malformed-worker.php?uncaught-exception'; 170 var script = 'resources/malformed-worker.php?uncaught-exception';
171 var scope = 'resources/scope/uncaught-exception'; 171 var scope = 'resources/scope/uncaught-exception';
172 return promise_rejects(t, 172 return promise_rejects(t,
173 check_error_types ? 'AbortError' : null, 173 check_error_types ? new TypeError : null,
174 register_method(script, {scope: scope}), 174 register_method(script, {scope: scope}),
175 'Registration of script including uncaught exception should fail.'); 175 'Registration of script including uncaught exception should fail.');
176 }, 'Registering script including uncaught exception'); 176 }, 'Registering script including uncaught exception');
177 177
178 promise_test(function(t) { 178 promise_test(function(t) {
179 var script = 'resources/malformed-worker.php?caught-exception'; 179 var script = 'resources/malformed-worker.php?caught-exception';
180 var scope = 'resources/scope/caught-exception'; 180 var scope = 'resources/scope/caught-exception';
181 return register_method(script, {scope: scope}) 181 return register_method(script, {scope: scope})
182 .then(function(registration) { 182 .then(function(registration) {
183 assert_equals(registration.constructor.name, 183 assert_equals(registration.constructor.name,
184 'ServiceWorkerRegistration', 184 'ServiceWorkerRegistration',
185 'Successfully registered.'); 185 'Successfully registered.');
186 service_worker_unregister_and_done(t, scope); 186 service_worker_unregister_and_done(t, scope);
187 }) 187 })
188 }, 'Registering script including caught exception'); 188 }, 'Registering script including caught exception');
189 189
190 promise_test(function(t) { 190 promise_test(function(t) {
191 var script = 'resources/malformed-worker.php?import-malformed-script'; 191 var script = 'resources/malformed-worker.php?import-malformed-script';
192 var scope = 'resources/scope/import-malformed-script'; 192 var scope = 'resources/scope/import-malformed-script';
193 return promise_rejects(t, 193 return promise_rejects(t,
194 check_error_types ? 'AbortError' : null, 194 check_error_types ? new TypeError : null,
195 register_method(script, {scope: scope}), 195 register_method(script, {scope: scope}),
196 'Registration of script importing malformed script should fail.'); 196 'Registration of script importing malformed script should fail.');
197 }, 'Registering script importing malformed script'); 197 }, 'Registering script importing malformed script');
198 198
199 promise_test(function(t) { 199 promise_test(function(t) {
200 var script = 'resources/malformed-worker.php?import-no-such-script'; 200 var script = 'resources/malformed-worker.php?import-no-such-script';
201 var scope = 'resources/scope/import-no-such-script'; 201 var scope = 'resources/scope/import-no-such-script';
202 return promise_rejects(t, 202 return promise_rejects(t,
203 check_error_types ? 'AbortError' : null, 203 check_error_types ? new TypeError : null,
204 register_method(script, {scope: scope}), 204 register_method(script, {scope: scope}),
205 'Registration of script importing non-existent script should fail.'); 205 'Registration of script importing non-existent script should fail.');
206 }, 'Registering script importing non-existent script'); 206 }, 'Registering script importing non-existent script');
207 207
208 promise_test(function(t) { 208 promise_test(function(t) {
209 // URL-encoded full-width 'scope'. 209 // URL-encoded full-width 'scope'.
210 var name = '%ef%bd%93%ef%bd%83%ef%bd%8f%ef%bd%90%ef%bd%85'; 210 var name = '%ef%bd%93%ef%bd%83%ef%bd%8f%ef%bd%90%ef%bd%85';
211 var script = 'resources/empty-worker.js'; 211 var script = 'resources/empty-worker.js';
212 var scope = 'resources/' + name + '/escaped-multibyte-character-scope'; 212 var scope = 'resources/' + name + '/escaped-multibyte-character-scope';
213 return register_method(script, {scope: scope}) 213 return register_method(script, {scope: scope})
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 promise_test(function(t) { 388 promise_test(function(t) {
389 var script = 'resources/empty-worker.js'; 389 var script = 'resources/empty-worker.js';
390 var scope = 'filesystem:' + normalizeURL('resources/scope/filesystem-scope -url'); 390 var scope = 'filesystem:' + normalizeURL('resources/scope/filesystem-scope -url');
391 return promise_rejects(t, 391 return promise_rejects(t,
392 check_error_types ? 'SecurityError' : null, 392 check_error_types ? 'SecurityError' : null,
393 register_method(script, {scope: scope}), 393 register_method(script, {scope: scope}),
394 'Registering with the scope that has same-origin filesystem: URL ' + 394 'Registering with the scope that has same-origin filesystem: URL ' +
395 'should fail with SecurityError.'); 395 'should fail with SecurityError.');
396 }, 'Scope URL is same-origin filesystem: URL'); 396 }, 'Scope URL is same-origin filesystem: URL');
397 } 397 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698