OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // --------------------------------------------------------------------------- | 5 // --------------------------------------------------------------------------- |
6 // Support for JS interoperability | 6 // Support for JS interoperability |
7 // --------------------------------------------------------------------------- | 7 // --------------------------------------------------------------------------- |
8 function SendPortSync() { | 8 function SendPortSync() { |
9 } | 9 } |
10 | 10 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 window.addEventListener(source, listener, false); | 217 window.addEventListener(source, listener, false); |
218 dispatchEvent(target, [source, serialized]); | 218 dispatchEvent(target, [source, serialized]); |
219 window.removeEventListener(source, listener, false); | 219 window.removeEventListener(source, listener, false); |
220 return deserialize(result); | 220 return deserialize(result); |
221 } | 221 } |
222 })(); | 222 })(); |
223 | 223 |
224 (function() { | 224 (function() { |
225 // Proxy support for js.dart. | 225 // Proxy support for js.dart. |
226 | 226 |
227 var globalContext = window; | 227 // We don't use 'window' because we might be in a web worker, but we don't |
| 228 // use 'self' because not all browsers support it |
| 229 var globalContext = function() { return this; }(); |
228 | 230 |
229 // Table for local objects and functions that are proxied. | 231 // Table for local objects and functions that are proxied. |
230 function ProxiedObjectTable() { | 232 function ProxiedObjectTable() { |
231 // Name for debugging. | 233 // Name for debugging. |
232 this.name = 'js-ref'; | 234 this.name = 'js-ref'; |
233 | 235 |
234 // Table from IDs to JS objects. | 236 // Table from IDs to JS objects. |
235 this.map = {}; | 237 this.map = {}; |
236 | 238 |
237 // Generator for new IDs. | 239 // Generator for new IDs. |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 port.receive(f); | 532 port.receive(f); |
531 window.registerPort(name, port.toSendPort()); | 533 window.registerPort(name, port.toSendPort()); |
532 } | 534 } |
533 | 535 |
534 makeGlobalPort('dart-js-context', context); | 536 makeGlobalPort('dart-js-context', context); |
535 makeGlobalPort('dart-js-create', construct); | 537 makeGlobalPort('dart-js-create', construct); |
536 makeGlobalPort('dart-js-instanceof', proxyInstanceof); | 538 makeGlobalPort('dart-js-instanceof', proxyInstanceof); |
537 makeGlobalPort('dart-js-delete-property', proxyDeleteProperty); | 539 makeGlobalPort('dart-js-delete-property', proxyDeleteProperty); |
538 makeGlobalPort('dart-js-convert', proxyConvert); | 540 makeGlobalPort('dart-js-convert', proxyConvert); |
539 })(); | 541 })(); |
OLD | NEW |