Bug 792808 - Change pktApi.jsm to import and instantiate XHRs from global properties rather than using Cc.createInstance(Ci.nsIXMLHttpRequest); r=Gijs
authorThomas Wisniewski <wisniewskit@gmail.com>
Tue, 19 Sep 2017 12:18:20 -0400
changeset 404229 89ffff270fb7da538c09f3d38690e6da4bcfe616
parent 404228 56f9de9da69ae1fea95ae18be730b65f5386de59
child 404230 b4d46a5196fec93a482cbbd00cf5d4d7018f2206
push id99968
push userrgurzau@mozilla.com
push dateFri, 16 Feb 2018 22:14:56 +0000
treeherdermozilla-inbound@2e16779c96cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs792808
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 792808 - Change pktApi.jsm to import and instantiate XHRs from global properties rather than using Cc.createInstance(Ci.nsIXMLHttpRequest); r=Gijs MozReview-Commit-ID: 8jdzIb95MmB
browser/extensions/pocket/content/pktApi.jsm
--- a/browser/extensions/pocket/content/pktApi.jsm
+++ b/browser/extensions/pocket/content/pktApi.jsm
@@ -43,16 +43,17 @@
  */
 
 const Cm = Components.manager;
 this.EXPORTED_SYMBOLS = ["pktApi"];
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
+Cu.importGlobalProperties(["XMLHttpRequest"]);
 
 var pktApi = (function() {
 
     /**
      * Configuration
      */
 
     // Base url for all api calls
@@ -246,17 +247,17 @@ var pktApi = (function() {
             return false;
         }
 
         var url = baseAPIUrl + options.path;
         var data = options.data || {};
         data.locale_lang = Services.locale.getAppLocaleAsLangTag();
         data.consumer_key = oAuthConsumerKey;
 
-        var request = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Components.interfaces.nsIXMLHttpRequest);
+        var request = new XMLHttpRequest();
         request.open("POST", url, true);
         request.onreadystatechange = function(e) {
             if (request.readyState == 4) {
                 if (request.status === 200) {
                     // There could still be an error if the response is no valid json
                     // or does not have status = 1
                     var response = parseJSON(request.response);
                     if (options.success && response && response.status == 1) {