diff --git a/lib/rpc.js b/lib/rpc.js index df5c10bf..e68b37c9 100644 --- a/lib/rpc.js +++ b/lib/rpc.js @@ -3,6 +3,15 @@ let DEVICE_HOST = 'localhost:8082'; let typeConverters = {}; +let XMLHttpRequest = window.XMLHttpRequest; + +// 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; +} exports.registerTypeConverter = registerTypeConverter; @@ -79,7 +88,7 @@ function convert(realmId, info) { function sendRequest(command, data) { let body = JSON.stringify(data); - let request = new XMLHttpRequestOriginal(); + let request = new XMLHttpRequest(); let url = 'http://' + DEVICE_HOST + '/' + command; request.open('POST', url, false);