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

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

Issue 238993003: ServiceWorker: "minimal" end-to-end sample as a W3C test (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add 'parsed' to observed states 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 6
7 navigator.serviceWorker.register(url).then( 7 navigator.serviceWorker.register(url).then(
8 t.step_func(function(worker) { 8 t.step_func(function(worker) {
9 var messageChannel = new MessageChannel(); 9 var messageChannel = new MessageChannel();
10 messageChannel.port1.onmessage = t.step_func(onMessage); 10 messageChannel.port1.onmessage = t.step_func(onMessage);
11 worker.postMessage({port:messageChannel.port2}, [messageChannel. port2]); 11 worker.postMessage({port:messageChannel.port2}, [messageChannel. port2]);
12 }), 12 }),
13 t.step_func(function(reason) { 13 t.step_func(function(reason) {
14 assert_unreached('Registration should succeed, but failed: ' + r eason.name); 14 assert_unreached('Registration should succeed, but failed: ' + r eason.name);
15 })); 15 }));
16 16
17 function onMessage(e) { 17 function onMessage(e) {
18 assert_equals(e.data, 'pass'); 18 assert_equals(e.data, 'pass');
19 t.done(); 19 t.done();
20 } 20 }
21 }); 21 });
22 } 22 }
23
24 // FIXME: Replace this with test.unreached_func(desc) once testharness.js is upd ated
25 // Use with unexpected event handlers or Promise rejection.
26 // E.g.:
27 // onbadevent = fail(t, 'Should only see good events');
28 // Promise.then(...).catch(fail(t, 'Rejection is never fun'));
29 function unreached_func(test, desc) {
30 return test.step_func(function() {
31 assert_unreached(desc);
32 });
33 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698