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

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

Issue 580033002: ServiceWorker: Stabilize install-phase-event-waituntil.html (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
« no previous file with comments | « LayoutTests/http/tests/serviceworker/install-phase-event-waituntil.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3 // Can only be used with a worker that installs successfully, since it
4 // first registers to acquire a ServiceWorkerRegistration object to 4 // first registers to acquire a ServiceWorkerRegistration object to
5 // unregister. 5 // unregister.
6 // FIXME: Use getRegistration() when implemented. 6 // FIXME: Use getRegistration() when implemented.
7 function service_worker_unregister_and_register(test, url, scope) { 7 function service_worker_unregister_and_register(test, url, scope) {
8 if (!scope || scope.length == 0) 8 if (!scope || scope.length == 0)
9 return Promise.reject(new Error('tests must define a scope')); 9 return Promise.reject(new Error('tests must define a scope'));
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 }); 58 });
59 iframe.src = ''; 59 iframe.src = '';
60 iframe.remove(); 60 iframe.remove();
61 return saw_unload; 61 return saw_unload;
62 } 62 }
63 63
64 function normalizeURL(url) { 64 function normalizeURL(url) {
65 return new URL(url, document.location).toString().replace(/#.*$/, ''); 65 return new URL(url, document.location).toString().replace(/#.*$/, '');
66 } 66 }
67 67
68 function get_newest_worker(registration) {
69 if (!registration) {
70 return Promise.reject(new Error(
71 'get_newest_worker must be passed a ServiceWorkerRegistration'));
72 }
73 if (registration.installing)
74 return Promise.resolve(registration.installing);
75 if (registration.waiting)
76 return Promise.resolve(registration.waiting);
77 if (registration.active)
78 return Promise.resolve(registration.active);
79 return Promise.reject(new Error(
80 'registration must have at least one version'));
81 }
82
68 function wait_for_update(test, registration) { 83 function wait_for_update(test, registration) {
69 if (!registration || registration.unregister == undefined) { 84 if (!registration || registration.unregister == undefined) {
70 return Promise.reject(new Error( 85 return Promise.reject(new Error(
71 'wait_for_update must be passed a ServiceWorkerRegistration')); 86 'wait_for_update must be passed a ServiceWorkerRegistration'));
72 } 87 }
73 88
74 return new Promise(test.step_func(function(resolve) { 89 return new Promise(test.step_func(function(resolve) {
75 registration.addEventListener('updatefound', test.step_func(function() { 90 registration.addEventListener('updatefound', test.step_func(function() {
76 resolve(registration.installing); 91 resolve(registration.installing);
77 })); 92 }));
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT, 200 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT,
186 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT, 201 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT,
187 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT, 202 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT,
188 UNAUTHENTICATED_ORIGIN: 'http://' + UNAUTHENTICATED_HOST + ':' + HTTP_PO RT 203 UNAUTHENTICATED_ORIGIN: 'http://' + UNAUTHENTICATED_HOST + ':' + HTTP_PO RT
189 }; 204 };
190 } 205 }
191 206
192 function base_path() { 207 function base_path() {
193 return location.pathname.replace(/\/[^\/]*$/, '/'); 208 return location.pathname.replace(/\/[^\/]*$/, '/');
194 } 209 }
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/install-phase-event-waituntil.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698