OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Bootstrap support for Dart scripts on the page as this script. | 5 // Bootstrap support for Dart scripts on the page as this script. |
6 if (navigator.webkitStartDart) { | 6 if (navigator.webkitStartDart) { |
7 if (!navigator.webkitStartDart()) { | 7 if (!navigator.webkitStartDart()) { |
8 document.body.innerHTML = 'This build has expired. Please download a new Da
rtium at http://www.dartlang.org/dartium/index.html'; | 8 document.body.innerHTML = 'This build has expired. Please download a new Da
rtium at http://www.dartlang.org/dartium/index.html'; |
9 } | 9 } |
10 } else { | 10 } else { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 return message; | 55 return message; |
56 } else if (message instanceof Array) { | 56 } else if (message instanceof Array) { |
57 var values = new Array(message.length); | 57 var values = new Array(message.length); |
58 for (var i = 0; i < message.length; i++) { | 58 for (var i = 0; i < message.length; i++) { |
59 values[i] = serialize(message[i]); | 59 values[i] = serialize(message[i]); |
60 } | 60 } |
61 return [ 'list', message.length, values ]; | 61 return [ 'list', message.length, values ]; |
62 } else if (message instanceof LocalSendPortSync) { | 62 } else if (message instanceof LocalSendPortSync) { |
63 return [ 'sendport', 'nativejs', message.receivePort.id ]; | 63 return [ 'sendport', 'nativejs', message.receivePort.id ]; |
64 } else if (message instanceof DartSendPortSync) { | 64 } else if (message instanceof DartSendPortSync) { |
65 return [ 'sendport', 'dart', message.receivePort.isolateId, | 65 return [ 'sendport', 'dart', message.isolateId, message.portId ]; |
66 message.receivePort.portId ]; | |
67 } else { | 66 } else { |
68 var id = 0; | 67 var id = 0; |
69 var keys = Object.getOwnPropertyNames(message); | 68 var keys = Object.getOwnPropertyNames(message); |
70 var values = new Array(keys.length); | 69 var values = new Array(keys.length); |
71 for (var i = 0; i < keys.length; i++) { | 70 for (var i = 0; i < keys.length; i++) { |
72 values[i] = serialize(message[keys[i]]); | 71 values[i] = serialize(message[keys[i]]); |
73 } | 72 } |
74 return [ 'map', id, keys, values ]; | 73 return [ 'map', id, keys, values ]; |
75 } | 74 } |
76 } | 75 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 var result = null; | 208 var result = null; |
210 var listener = function (e) { | 209 var listener = function (e) { |
211 result = JSON.parse(e.data); | 210 result = JSON.parse(e.data); |
212 }; | 211 }; |
213 window.addEventListener(source, listener, false); | 212 window.addEventListener(source, listener, false); |
214 dispatchEvent(target, [source, serialized]); | 213 dispatchEvent(target, [source, serialized]); |
215 window.removeEventListener(source, listener, false); | 214 window.removeEventListener(source, listener, false); |
216 return deserialize(result); | 215 return deserialize(result); |
217 } | 216 } |
218 })(); | 217 })(); |
OLD | NEW |