Account for overridden XMLHttpRequest in rpc module

This commit is contained in:
Scott Kyle 2015-10-06 13:36:42 -07:00
parent cb4fea97d4
commit f35d83a07d
1 changed files with 10 additions and 1 deletions

View File

@ -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);