| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |