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

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

Issue 1210633002: Update navigator.services API to use the new services.onconnect event [1/3]. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@serviceport-part3
Patch Set: rebase Created 5 years, 5 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 // Helper method that waits for a {success: <boolean>, result: any} reply on 1 // Helper method that waits for a {success: <boolean>, result: any} reply on
2 // a port and returns a promise that resolves (if success is true) or rejects 2 // a port and returns a promise that resolves (if success is true) or rejects
3 // the promise with the value of the result attribute. 3 // the promise with the value of the result attribute.
4 function reply_as_promise(t, port) { 4 function reply_as_promise(t, port) {
5 return new Promise(function(resolve, reject) { 5 return new Promise(function(resolve, reject) {
6 var got_reply = false; 6 var got_reply = false;
7 port.onmessage = t.step_func(function(event) { 7 port.onmessage = t.step_func(function(event) {
8 assert_false(got_reply); 8 assert_false(got_reply);
9 assert_true('success' in event.data); 9 assert_true('success' in event.data);
10 assert_true('result' in event.data); 10 assert_true('result' in event.data);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 navigator.services.onmessage = function(event) { 79 navigator.services.onmessage = function(event) {
80 channel.port2.postMessage(event.data, event.ports); 80 channel.port2.postMessage(event.data, event.ports);
81 }; 81 };
82 channel.port1.targetURL = port.targetURL; 82 channel.port1.targetURL = port.targetURL;
83 channel.port1.name = port.name; 83 channel.port1.name = port.name;
84 channel.port1.data = port.data; 84 channel.port1.data = port.data;
85 return channel.port1; 85 return channel.port1;
86 } 86 }
87 ); 87 );
88 } 88 }
89
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698