| Index: trunk/src/chrome/renderer/resources/extensions/miscellaneous_bindings.js
|
| ===================================================================
|
| --- trunk/src/chrome/renderer/resources/extensions/miscellaneous_bindings.js (revision 203729)
|
| +++ trunk/src/chrome/renderer/resources/extensions/miscellaneous_bindings.js (working copy)
|
| @@ -8,6 +8,7 @@
|
| // content scripts only.
|
|
|
| require('json_schema');
|
| + var json = require('json');
|
| var lastError = require('lastError');
|
| var miscNatives = requireNative('miscellaneous_bindings');
|
| var chrome = requireNative('chrome').GetChrome();
|
| @@ -54,7 +55,10 @@
|
| // Sends a message asynchronously to the context on the other end of this
|
| // port.
|
| PortImpl.prototype.postMessage = function(msg) {
|
| - PostMessage(this.portId_, msg);
|
| + // json.stringify doesn't support a root object which is undefined.
|
| + if (msg === undefined)
|
| + msg = null;
|
| + PostMessage(this.portId_, json.stringify(msg));
|
| };
|
|
|
| // Disconnects the port from the other end.
|
| @@ -262,8 +266,12 @@
|
| // Called by native code when a message has been sent to the given port.
|
| chromeHidden.Port.dispatchOnMessage = function(msg, portId) {
|
| var port = ports[portId];
|
| - if (port)
|
| + if (port) {
|
| + if (msg) {
|
| + msg = json.parse(msg);
|
| + }
|
| port.onMessage.dispatch(msg, port);
|
| + }
|
| };
|
|
|
| // Shared implementation used by tabs.sendMessage and runtime.sendMessage.
|
|
|