Skip to content
Browse files

[Emulator Bridge] Only cache the device window and route onmessage to it

  • Loading branch information...
1 parent 86276ae commit a1cf471503e4f1f44dfbd7082b0b84a3a5b0f156 @zhizhangchen committed Apr 16, 2013
Showing with 13 additions and 8 deletions.
  1. +13 −8 lib/ripple/emulatorBridge.js
View
21 lib/ripple/emulatorBridge.js
@@ -69,9 +69,19 @@ function _marshalScreen(win) {
module.exports = {
link: function (win, doc) {
- _win = win;
- _doc = doc;
- _xhr = win.XMLHttpRequest;
+ // Only cache the device window and route onmessage to it
+ if (win.parent.parent === win.parent &&
+ win.frameElement.getAttribute('id') === 'document') {
+ _win = win;
+ _doc = doc;
+ _xhr = win.XMLHttpRequest;
+
+ window.onmessage = function (e) {
+ if (typeof win.onmessage === 'function') {
+ win.onmessage(e);
+ }
+ };
+ }
require('ripple/widgetConfig').initialize();
@@ -83,11 +93,6 @@ module.exports = {
marshal(window.tinyHippos, "tinyHippos");
marshal(window.XMLHttpRequest, "XMLHttpRequest");
- window.onmessage = function (e) {
- if (typeof win.onmessage === 'function') {
- win.onmessage(e);
- }
- };
if (currentPlatform.initialize) {
currentPlatform.initialize(win);

0 comments on commit a1cf471

Please sign in to comment.
Something went wrong with that request. Please try again.