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

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

Issue 287363004: ServiceWorker: support Response.{status,statusText,headers} [blink] (2/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 function service_worker_test(url, description) { 3 function service_worker_test(url, description) {
4 var t = async_test(description); 4 var t = async_test(description);
5 t.step(function() { 5 t.step(function() {
6 var scope = 'nonexistent';
7 service_worker_unregister_and_register(t, url, scope, onRegistered);
6 8
7 navigator.serviceWorker.register(url, {scope:'nonexistent'}).then( 9 function onRegistered(worker) {
8 t.step_func(function(worker) { 10 var messageChannel = new MessageChannel();
9 var messageChannel = new MessageChannel(); 11 messageChannel.port1.onmessage = t.step_func(onMessage);
10 messageChannel.port1.onmessage = t.step_func(onMessage); 12 worker.postMessage({port:messageChannel.port2}, [messageChannel.port 2]);
11 worker.postMessage({port:messageChannel.port2}, [messageChannel. port2]); 13 }
12 }),
13 unreached_rejection(t, 'Registration should succeed, but failed')
14 );
15 14
16 function onMessage(e) { 15 function onMessage(e) {
17 assert_equals(e.data, 'pass'); 16 assert_equals(e.data, 'pass');
18 t.done(); 17 service_worker_unregister_and_done(t, scope);
19 } 18 }
20 }); 19 });
21 } 20 }
22 21
23 function service_worker_unregister_and_register(test, url, scope, onregister) { 22 function service_worker_unregister_and_register(test, url, scope, onregister) {
24 var options = scope ? { scope: scope } : {}; 23 var options = scope ? { scope: scope } : {};
25 return navigator.serviceWorker.unregister(scope).then( 24 return navigator.serviceWorker.unregister(scope).then(
26 // FIXME: Wrap this with test.step_func once testharness.js is updated. 25 // FIXME: Wrap this with test.step_func once testharness.js is updated.
27 function() { 26 function() {
28 return navigator.serviceWorker.register(url, options); 27 return navigator.serviceWorker.register(url, options);
(...skipping 24 matching lines...) Expand all
53 frame.src = url; 52 frame.src = url;
54 frame.onload = function() { 53 frame.onload = function() {
55 f(frame); 54 f(frame);
56 }; 55 };
57 document.body.appendChild(frame); 56 document.body.appendChild(frame);
58 } 57 }
59 58
60 function normalizeURL(url) { 59 function normalizeURL(url) {
61 return new URL(url, document.location).toString().replace(/#.*$/, ''); 60 return new URL(url, document.location).toString().replace(/#.*$/, '');
62 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698