OLD | NEW |
---|---|
1 try { | |
2 importScripts("/js-test-resources/js-test.js"); | |
jsbell
2015/01/30 17:58:10
Can we do this instead:
if ('importScripts' in se
Yuki
2015/02/02 07:51:12
Done.
| |
3 } catch (e) {} | |
4 | |
1 self.onmessage = function(e) { | 5 self.onmessage = function(e) { |
2 navigator.connect(e.data.connect) | 6 navigator.connect(e.data.connect) |
3 .then(function(port) { | 7 .then(function(port) { |
4 e.data.port.postMessage({success: true, result: port}, [port]); | 8 e.data.port.postMessage({success: true, result: port}, [port]); |
5 }) | 9 }) |
6 .catch(function(error) { | 10 .catch(function(error) { |
7 // Not all errors can be serialized as a SerializedScriptValue, so | 11 // Not all errors can be serialized as a SerializedScriptValue, so |
8 // convert to JSON and parse to get just the bits that certainly can. | 12 // convert to JSON and parse to get just the bits that certainly can. |
9 e.data.port.postMessage( | 13 e.data.port.postMessage( |
10 {success: false, result: JSON.parse(JSON.stringify(error))}); | 14 {success: false, result: JSON.parse(stringifyDOMObject(error))}); |
11 }); | 15 }); |
12 }; | 16 }; |
OLD | NEW |