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

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

Issue 723923002: ServiceWorker: Add support for .skipWaiting and controllerchange event(1/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: webcallback->skipwaitingcallbacks, test re-write Created 6 years 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 registration = r; 209 registration = r;
210 return wait_for_update(test, registration); 210 return wait_for_update(test, registration);
211 }) 211 })
212 .then(function(worker) { return fetch_tests_from_worker(worker); }) 212 .then(function(worker) { return fetch_tests_from_worker(worker); })
213 .then(function() { return registration.unregister(); }) 213 .then(function() { return registration.unregister(); })
214 .then(function() { test.done(); }) 214 .then(function() { test.done(); })
215 .catch(test.step_func(function(e) { throw e; })); 215 .catch(test.step_func(function(e) { throw e; }));
216 }; 216 };
217 217
218 self.service_worker_test = service_worker_test; 218 self.service_worker_test = service_worker_test;
219 self.fetch_tests_from_worker = fetch_tests_from_worker;
219 })(); 220 })();
220 221
221 function get_host_info() { 222 function get_host_info() {
222 var ORIGINAL_HOST = '127.0.0.1'; 223 var ORIGINAL_HOST = '127.0.0.1';
223 var REMOTE_HOST = 'localhost'; 224 var REMOTE_HOST = 'localhost';
224 var UNAUTHENTICATED_HOST = 'example.test'; 225 var UNAUTHENTICATED_HOST = 'example.test';
225 var HTTP_PORT = 8000; 226 var HTTP_PORT = 8000;
226 var HTTPS_PORT = 8443; 227 var HTTPS_PORT = 8443;
227 try { 228 try {
228 // In W3C test, we can get the hostname and port number in config.json 229 // In W3C test, we can get the hostname and port number in config.json
(...skipping 28 matching lines...) Expand all
257 channel.port1.onmessage = test.step_func(function() { 258 channel.port1.onmessage = test.step_func(function() {
258 unload_iframe(frame).catch(function() {}); 259 unload_iframe(frame).catch(function() {});
259 resolve(); 260 resolve();
260 }); 261 });
261 frame.contentWindow.postMessage( 262 frame.contentWindow.postMessage(
262 {username: username, password: password, cookie: cookie}, 263 {username: username, password: password, cookie: cookie},
263 [channel.port2], origin); 264 [channel.port2], origin);
264 })); 265 }));
265 }); 266 });
266 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698