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

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/support.js

Issue 238993003: ServiceWorker: "minimal" end-to-end sample as a W3C test (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Sync with github Created 6 years, 8 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
(Empty)
1 // Service Worker helpers for testharness.js-based tests.
2
3 // Use with unexpected event handlers or Promise rejection. Will
4 // fail the test with a name/message is present on the error.
5 // E.g.:
6 // onbadevent = fail(t, 'Should only see good events');
7 // Promise.then(...).catch(fail(t, 'Rejection is never fun'));
8 function fail(test, desc) {
9 desc = desc || 'Failure';
10 return test.step_func(function(reason) {
11 if (reason && 'name' in reason && 'message' in reason) {
12 assert_unreached(desc + ': ' + reason.name + ' - ' + reason.message) ;
13 } else if (reason && 'name' in reason) {
14 assert_unreached(desc + ': ' + reason.name);
15 } else {
16 assert_unreached(desc);
17 }
18 });
19 }
20
21 // Sends a message of {port, from} to the specified worker, and returns the
22 // port at the local end of the channel.
23 function sendMessagePort(worker, from) {
24 var messageChannel = new MessageChannel();
25 worker.postMessage({from:from, port:messageChannel.port2}, [messageChannel.p ort2]);
26 return messageChannel.port1;
27 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698