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

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/test-helpers.js

Issue 472293002: Don't use ServiceWorkerContainer.unregister in service_worker_unregister_and_register (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
OLDNEW
1 // Adapter for testharness.js-style tests with Service Workers 1 // Adapter for testharness.js-style tests with Service Workers
2 2
3 // Can only be used with a worker that installs successfully, since it
4 // first registers to acquire a ServiceWorkerRegistration object to
5 // unregister.
6 // FIXME: Use getRegistration() when implemented.
3 function service_worker_unregister_and_register(test, url, scope) { 7 function service_worker_unregister_and_register(test, url, scope) {
4 var options = scope ? { scope: scope } : {}; 8 var options = scope ? { scope: scope } : {};
5 return navigator.serviceWorker.unregister(scope).then( 9 return navigator.serviceWorker.register(url, options)
6 test.step_func(function() { 10 .then(function(registration) {
7 return navigator.serviceWorker.register(url, options); 11 return registration.unregister();
8 }), 12 })
9 unreached_rejection(test, 'Unregister should not fail') 13 .then(function() {
10 ).then(test.step_func(function(worker) { 14 return navigator.serviceWorker.register(url, options);
11 return Promise.resolve(worker); 15 })
12 }), 16 .catch(unreached_rejection(test));
13 unreached_rejection(test, 'Registration should not fail')
14 );
15 } 17 }
16 18
17 function service_worker_unregister_and_done(test, scope) { 19 function service_worker_unregister_and_done(test, scope) {
18 return navigator.serviceWorker.unregister(scope).then( 20 return navigator.serviceWorker.unregister(scope).then(
19 test.done.bind(test), 21 test.done.bind(test),
20 unreached_rejection(test, 'Unregister should not fail')); 22 unreached_rejection(test, 'Unregister should not fail'));
21 } 23 }
22 24
23 // Rejection-specific helper that provides more details 25 // Rejection-specific helper that provides more details
24 function unreached_rejection(test, prefix) { 26 function unreached_rejection(test, prefix) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT, 153 HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT,
152 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT, 154 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT,
153 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT, 155 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT,
154 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT 156 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT
155 }; 157 };
156 } 158 }
157 159
158 function base_path() { 160 function base_path() {
159 return location.pathname.replace(/\/[^\/]*$/, '/'); 161 return location.pathname.replace(/\/[^\/]*$/, '/');
160 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698