Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: client/dart.js

Issue 10700102: Make the new JS interop test pass on Dartium. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dart.js
===================================================================
--- client/dart.js (revision 9387)
+++ client/dart.js (working copy)
@@ -65,10 +65,11 @@
// TODO(kasperl): Hide these serialization methods so they
// do not clutter up the global scope.
function _serialize(message) {
- if (message == null ||
- typeof(message) == 'string' ||
- typeof(message) == 'number' ||
- typeof(message) == 'boolean') {
+ if (message == null) {
+ return null; // Convert undefined to null.
+ } else if (typeof(message) == 'string' ||
+ typeof(message) == 'number' ||
+ typeof(message) == 'boolean') {
return message;
} else if (message instanceof SendPortSync) {
return [ 'sendport', message.receivePort.id ];
@@ -117,3 +118,15 @@
var stringified = JSON.stringify(_serialize(port));
window.localStorage['dart-port:' + name] = stringified;
}
+
+if (navigator.webkitStartDart) {
+ window.addEventListener('js-sync-message', function(event) {
+ var data = JSON.parse(event.data);
+ var deserialized = _deserialize(data.message);
+ var result = ReceivePortSync.map[data.id].callback(deserialized);
+ var string = JSON.stringify(_serialize(result));
+ var event = document.createEvent('TextEvent');
+ event.initTextEvent('js-result', false, false, window, string);
+ window.dispatchEvent(event);
+ }, false);
+}
« no previous file with comments | « no previous file | lib/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698