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

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

Issue 822593003: ServiceWorker: Expose registration within ServiceWorkerGlobalScope [3/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@expose_swreg
Patch Set: address falken@'s comment Created 5 years, 11 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 // Adapter for testharness.js-style tests with Service Workers 1 // Adapter for testharness.js-style tests with Service Workers
2 2
3 function service_worker_unregister_and_register(test, url, scope) { 3 function service_worker_unregister_and_register(test, url, scope) {
4 if (!scope || scope.length == 0) 4 if (!scope || scope.length == 0)
5 return Promise.reject(new Error('tests must define a scope')); 5 return Promise.reject(new Error('tests must define a scope'));
6 6
7 var options = { scope: scope }; 7 var options = { scope: scope };
8 return service_worker_unregister(test, scope) 8 return service_worker_unregister(test, scope)
9 .then(function() { 9 .then(function() {
10 return navigator.serviceWorker.register(url, options); 10 return navigator.serviceWorker.register(url, options);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 iframe.contentWindow.addEventListener('unload', function() { 56 iframe.contentWindow.addEventListener('unload', function() {
57 resolve(); 57 resolve();
58 }); 58 });
59 }); 59 });
60 iframe.src = ''; 60 iframe.src = '';
61 iframe.remove(); 61 iframe.remove();
62 return saw_unload; 62 return saw_unload;
63 } 63 }
64 64
65 function normalizeURL(url) { 65 function normalizeURL(url) {
66 return new URL(url, document.location).toString().replace(/#.*$/, ''); 66 return new URL(url, self.location).toString().replace(/#.*$/, '');
67 } 67 }
68 68
69 function wait_for_update(test, registration) { 69 function wait_for_update(test, registration) {
70 if (!registration || registration.unregister == undefined) { 70 if (!registration || registration.unregister == undefined) {
71 return Promise.reject(new Error( 71 return Promise.reject(new Error(
72 'wait_for_update must be passed a ServiceWorkerRegistration')); 72 'wait_for_update must be passed a ServiceWorkerRegistration'));
73 } 73 }
74 74
75 return new Promise(test.step_func(function(resolve) { 75 return new Promise(test.step_func(function(resolve) {
76 registration.addEventListener('updatefound', test.step_func(function() { 76 registration.addEventListener('updatefound', test.step_func(function() {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 channel.port1.onmessage = test.step_func(function() { 202 channel.port1.onmessage = test.step_func(function() {
203 unload_iframe(frame).catch(function() {}); 203 unload_iframe(frame).catch(function() {});
204 resolve(); 204 resolve();
205 }); 205 });
206 frame.contentWindow.postMessage( 206 frame.contentWindow.postMessage(
207 {username: username, password: password, cookie: cookie}, 207 {username: username, password: password, cookie: cookie},
208 [channel.port2], origin); 208 [channel.port2], origin);
209 })); 209 }));
210 }); 210 });
211 } 211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698