Bug 792808 - Change dom/system to import and instantiate XHRs from global properties rather than using Cc.createInstance(Ci.nsIXMLHttpRequest); r?jdm draft
authorThomas Wisniewski <wisniewskit@gmail.com>
Tue, 19 Sep 2017 11:47:37 -0400
changeset 756141 e1cd3155089d5356448fb51d2406a3483aaaa5a5
parent 756140 23fa9ff1e3833231c1f6a451ba5186139f6bcfd2
child 756142 ed3ba4b507e4220e59db80bb3204d7baecae5819
push id99394
push userwisniewskit@gmail.com
push dateFri, 16 Feb 2018 14:37:01 +0000
reviewersjdm
bugs792808
milestone60.0a1
Bug 792808 - Change dom/system to import and instantiate XHRs from global properties rather than using Cc.createInstance(Ci.nsIXMLHttpRequest); r?jdm MozReview-Commit-ID: AhiiiVUoGSW
dom/system/NetworkGeolocationProvider.js
--- a/dom/system/NetworkGeolocationProvider.js
+++ b/dom/system/NetworkGeolocationProvider.js
@@ -2,16 +2,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
+Cu.importGlobalProperties(["XMLHttpRequest"]);
+
 const POSITION_UNAVAILABLE = Ci.nsIDOMGeoPositionError.POSITION_UNAVAILABLE;
 
 var gLoggingEnabled = false;
 
 /*
    The gLocationRequestTimeout controls how long we wait on receiving an update
    from the Wifi subsystem.  If this timer fires, we believe the Wifi scan has
    had a problem and we no longer can use Wifi to position the user this time
@@ -365,19 +367,17 @@ WifiGeoPositionProvider.prototype = {
       this.listener.update(gCachedRequest.location);
       return;
     }
 
     // From here on, do a network geolocation request //
     let url = Services.urlFormatter.formatURLPref("geo.wifi.uri");
     LOG("Sending request");
 
-    let xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
-                        .createInstance(Ci.nsIXMLHttpRequest);
-
+    let xhr = new XMLHttpRequest();
     try {
       xhr.open("POST", url, true);
       xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS;
     } catch (e) {
       this.listener.notifyError(POSITION_UNAVAILABLE);
       return;
     }
     xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");