Account for overridden XMLHttpRequest in rpc module
This commit is contained in:
parent
cb4fea97d4
commit
f35d83a07d
11
lib/rpc.js
11
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);
|
||||
|
|
Loading…
Reference in New Issue