From f35d83a07d31fb32baa693a59a2036a336d589c7 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Tue, 6 Oct 2015 13:36:42 -0700 Subject: [PATCH] Account for overridden XMLHttpRequest in rpc module --- lib/rpc.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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);