OLD | NEW |
1 if ("importScripts" in self) { | 1 if ("importScripts" in self) { |
2 importScripts("/resources/testharness-helpers.js"); | 2 importScripts("/resources/testharness-helpers.js"); |
3 importScripts("test-helpers.js"); | 3 importScripts("test-helpers.js"); |
4 } | 4 } |
5 | 5 |
6 self.onmessage = function(e) { | 6 self.onmessage = function(e) { |
7 var service = e.data.connect; | 7 var service = e.data.connect; |
8 first_to_resolve([wrap_in_port(navigator.services.connect(service)), navigator
.connect(service)]) | 8 wrap_in_port(navigator.services.connect(service, e.data.options)) |
9 .then(function(port) { | 9 .then(function(port) { |
10 e.data.port.postMessage({success: true, result: port}, [port]); | 10 e.data.port.postMessage({ |
| 11 success: true, |
| 12 result: { |
| 13 port: port, |
| 14 targetURL: port.targetURL, |
| 15 name: port.name, |
| 16 data: port.data |
| 17 } |
| 18 }, [port]); |
11 }) | 19 }) |
12 .catch(function(error) { | 20 .catch(function(error) { |
13 // Not all errors can be serialized as a SerializedScriptValue, so | 21 // Not all errors can be serialized as a SerializedScriptValue, so |
14 // convert to JSON and parse to get just the bits that certainly can. | 22 // convert to JSON and parse to get just the bits that certainly can. |
15 e.data.port.postMessage( | 23 e.data.port.postMessage( |
16 {success: false, result: JSON.parse(stringifyDOMObject(error))}); | 24 {success: false, result: JSON.parse(stringifyDOMObject(error))}); |
17 }); | 25 }); |
18 }; | 26 }; |
OLD | NEW |