Skip to content

Commit

Permalink
[Emulator Bridge] Only cache the device window and route onmessage to it
Browse files Browse the repository at this point in the history
  • Loading branch information
zhizhangchen committed Apr 16, 2013
1 parent 86276ae commit a1cf471
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/ripple/emulatorBridge.js
Expand Up @@ -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();

Expand All @@ -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);
Expand Down

0 comments on commit a1cf471

Please sign in to comment.