Commit 91f1c5de authored by Igor Oliveira's avatar Igor Oliveira Committed by Arthur Edelstein
Browse files

Bug 26100: Update xmlhttprequest calls after changes in xpcom interface

The xmlhttprequest xpcom interface was deprecated in favor of the
XMLHttpRequest.
parent 3047f3fc
......@@ -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.");
......
......@@ -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");
......
......@@ -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");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment