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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 case 'dart': | 116 case 'dart': |
117 var isolateId = x[2]; | 117 var isolateId = x[2]; |
118 var portId = x[3]; | 118 var portId = x[3]; |
119 return new DartSendPortSync(isolateId, portId); | 119 return new DartSendPortSync(isolateId, portId); |
120 default: | 120 default: |
121 throw 'Illegal SendPortSync type: $tag'; | 121 throw 'Illegal SendPortSync type: $tag'; |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 function deserializeList(x) { | 125 function deserializeList(x) { |
126 var length = x[1]; | |
127 var values = x[2]; | 126 var values = x[2]; |
| 127 var length = values.length; |
128 var result = new Array(length); | 128 var result = new Array(length); |
129 for (var i = 0; i < length; i++) { | 129 for (var i = 0; i < length; i++) { |
130 result[i] = deserializeHelper(values[i]); | 130 result[i] = deserializeHelper(values[i]); |
131 } | 131 } |
132 return result; | 132 return result; |
133 } | 133 } |
134 | 134 |
135 window.registerPort = function(name, port) { | 135 window.registerPort = function(name, port) { |
136 var stringified = JSON.stringify(serialize(port)); | 136 var stringified = JSON.stringify(serialize(port)); |
137 window.localStorage['dart-port:' + name] = stringified; | 137 window.localStorage['dart-port:' + name] = stringified; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 var result = null; | 209 var result = null; |
210 var listener = function (e) { | 210 var listener = function (e) { |
211 result = JSON.parse(e.data); | 211 result = JSON.parse(e.data); |
212 }; | 212 }; |
213 window.addEventListener(source, listener, false); | 213 window.addEventListener(source, listener, false); |
214 dispatchEvent(target, [source, serialized]); | 214 dispatchEvent(target, [source, serialized]); |
215 window.removeEventListener(source, listener, false); | 215 window.removeEventListener(source, listener, false); |
216 return deserialize(result); | 216 return deserialize(result); |
217 } | 217 } |
218 })(); | 218 })(); |
OLD | NEW |