diff --git a/lib/.eslintrc b/lib/.eslintrc index 5e03e21c..fb4738fd 100644 --- a/lib/.eslintrc +++ b/lib/.eslintrc @@ -6,6 +6,9 @@ "browser": true, "es6": true, }, + "globals": { + "global": true + }, "rules": { "comma-dangle": 0, "no-unused-vars": 1, diff --git a/lib/rpc.js b/lib/rpc.js index 7a0a1d8d..c92d287b 100644 --- a/lib/rpc.js +++ b/lib/rpc.js @@ -5,16 +5,16 @@ let constants = require('./constants'); let DEVICE_HOST = 'localhost:8082'; let {keys, objectTypes, propTypes} = constants; +let XMLHttpRequest = global.originalXMLHttpRequest || global.XMLHttpRequest; let typeConverters = {}; -let XMLHttpRequest = window.XMLHttpRequest; let sessionId; // Check if XMLHttpRequest has been overridden, and get the native one if that's the case. -if (XMLHttpRequest.__proto__ != window.XMLHttpRequestEventTarget) { - let override = XMLHttpRequest; - delete window.XMLHttpRequest; - XMLHttpRequest = window.XMLHttpRequest; - window.XMLHttpRequest = override; +if (XMLHttpRequest.__proto__ != global.XMLHttpRequestEventTarget) { + let fakeXMLHttpRequest = XMLHttpRequest; + delete global.XMLHttpRequest; + XMLHttpRequest = global.XMLHttpRequest; + global.XMLHttpRequest = fakeXMLHttpRequest; } module.exports = {