[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torbutton/master] Bug 26100: Update xmlhttprequest calls after changes in xpcom interface



commit 91f1c5deae6fb8415e0c22a99d4c0c3eac7db7b5
Author: Igor Oliveira <igt0@xxxxxxxxxxxxxx>
Date:   Wed Feb 28 17:42:33 2018 -0300

    Bug 26100: Update xmlhttprequest calls after changes in xpcom interface
    
    The xmlhttprequest xpcom interface was deprecated in favor of the
    XMLHttpRequest.
---
 src/chrome/content/torbutton.js    | 12 +++++++-----
 src/components/torCheckService.js  |  5 ++---
 src/components/torbutton-logger.js |  4 +---
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 4b15c5f..cf39dc2 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -7,13 +7,14 @@
 // TODO: Double-check there are no strange exploits to defeat:
 //       http://kb.mozillazine.org/Links_to_local_pages_don%27t_work
 
-let { LoadContextInfo } = Cu.import('resource://gre/modules/LoadContextInfo.jsm', {});
 let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
 let { showDialog } = Cu.import("resource://torbutton/modules/utils.js", {});
 let { getLocale, unescapeTorString } = Cu.import("resource://torbutton/modules/utils.js", {});
 let SecurityPrefs = Cu.import("resource://torbutton/modules/security-prefs.js", {});
 let { bindPrefAndInit, observe } = Cu.import("resource://torbutton/modules/utils.js", {});
 
+Cu.importGlobalProperties(["XMLHttpRequest"]);
+
 const k_tb_last_browser_version_pref = "extensions.torbutton.lastBrowserVersion";
 const k_tb_browser_update_needed_pref = "extensions.torbutton.updateNeeded";
 const k_tb_last_update_check_pref = "extensions.torbutton.lastUpdateCheck";
@@ -733,9 +734,7 @@ function torbutton_do_async_versioncheck() {
   torbutton_log(3, "Checking version with socks port: "
           +m_tb_prefs.getIntPref("network.proxy.socks_port"));
   try {
-    var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
-                            .createInstance(Components.interfaces.nsIXMLHttpRequest);
-    //var req = new XMLHttpRequest(); Blocked by content policy
+    var req = new XMLHttpRequest();
     var url = m_tb_prefs.getCharPref("extensions.torbutton.versioncheck_url");
     req.open('GET', url, true);
     req.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
@@ -1130,6 +1129,9 @@ function torbutton_do_new_identity() {
   torbutton_log(3, "New Identity: Clearing Offline Cache");
 
   try {
+    const LoadContextInfo = Cc["@mozilla.org/load-context-info-factory;1"]
+      .getService(Ci.nsILoadContextInfoFactory);
+
     for (let contextInfo of [LoadContextInfo.default, LoadContextInfo.private]) {
       let appCacheStorage = Services.cache2.appCacheStorage(contextInfo, null);
       // The following call (asyncEvictStorage) is actually synchronous, either
@@ -2023,7 +2025,7 @@ let stopLanguagePromptObserver;
 function torbutton_new_window(event)
 {
     torbutton_log(3, "New window");
-    var browser = getBrowser();
+    var browser = window.gBrowser;
 
     if(!browser) {
       torbutton_log(5, "No browser for new window.");
diff --git a/src/components/torCheckService.js b/src/components/torCheckService.js
index 04708d4..19e13f4 100644
--- a/src/components/torCheckService.js
+++ b/src/components/torCheckService.js
@@ -77,9 +77,8 @@ TBTorCheckService.prototype =
 
   createCheckRequest: function(aAsync)
   {
-    let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
-                      .createInstance(Ci.nsIXMLHttpRequest);
-    //let req = new XMLHttpRequest(); Blocked by content policy
+    Cu.importGlobalProperties(["XMLHttpRequest"]);
+    let req = new XMLHttpRequest();
     let prefs =  Cc["@mozilla.org/preferences-service;1"]
                    .getService(Ci.nsIPrefBranch);
     let url = prefs.getCharPref("extensions.torbutton.test_url");
diff --git a/src/components/torbutton-logger.js b/src/components/torbutton-logger.js
index 620113f..18a5f1e 100644
--- a/src/components/torbutton-logger.js
+++ b/src/components/torbutton-logger.js
@@ -22,9 +22,7 @@ function TorbuttonLogger() {
         .getService(Components.interfaces.nsIPrefBranch);
 
     // Register observer
-    var pref_service = Components.classes["@mozilla.org/preferences-service;1"]
-        .getService(Components.interfaces.nsIPrefBranchInternal);
-    this._branch = pref_service.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
+    this._branch = this.prefs.QueryInterface(Components.interfaces.nsIPrefBranch);
     this._branch.addObserver("extensions.torbutton", this, false);
 
     this.loglevel = this.prefs.getIntPref("extensions.torbutton.loglevel");



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits