Bug 687332: Fix toolkit/. r=rs
authorKyle Huey <khuey@kylehuey.com>
Thu, 29 Sep 2011 12:06:36 -0400
changeset 77816 867d159c15084534ff7f54cfd12119b165068600
parent 77815 4640b44402ac66676aeab8744dd938c56dee4d14
child 77817 1f8c38d6e4bf5519fc6e0a33452d8c813da64b63
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersrs
bugs687332
milestone10.0a1
Bug 687332: Fix toolkit/. r=rs
toolkit/components/url-classifier/content/xml-fetcher.js
toolkit/mozapps/extensions/AddonRepository.jsm
toolkit/mozapps/extensions/AddonUpdateChecker.jsm
toolkit/mozapps/extensions/LightweightThemeManager.jsm
toolkit/mozapps/extensions/nsBlocklistService.js
toolkit/mozapps/update/nsUpdateService.js
--- a/toolkit/components/url-classifier/content/xml-fetcher.js
+++ b/toolkit/components/url-classifier/content/xml-fetcher.js
@@ -98,25 +98,24 @@ PROT_XMLFetcher.prototype = {
     this._request.open("GET", page, asynchronous);
     this._request.channel.notificationCallbacks = this;
 
     if (this._stripCookies)
       new PROT_CookieStripper(this._request.channel);
 
     // Create a closure
     var self = this;
-    this._request.onreadystatechange = function() {
+    this._request.addEventListener("readystatechange", function() {
       self.readyStateChange(self);
-    }
+    }, false);
 
     this._request.send(null);
   },
 
   cancel: function() {
-    this._request.onreadystatechange = null;
     this._request.abort();
     this._request = null;
   },
 
   /**
    * Called periodically by the request to indicate some state change. 4
    * means content has been received.
    */
--- a/toolkit/mozapps/extensions/AddonRepository.jsm
+++ b/toolkit/mozapps/extensions/AddonRepository.jsm
@@ -1171,18 +1171,20 @@ var AddonRepository = {
 
     this._request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
                     createInstance(Ci.nsIXMLHttpRequest);
     this._request.mozBackgroundRequest = true;
     this._request.open("GET", aURI, true);
     this._request.overrideMimeType("text/xml");
 
     let self = this;
-    this._request.onerror = function(aEvent) { self._reportFailure(); };
-    this._request.onload = function(aEvent) {
+    this._request.addEventListener("error", function(aEvent) {
+      self._reportFailure();
+    }, false);
+    this._request.addEventListener("load", function(aEvent) {
       let request = aEvent.target;
       let responseXML = request.responseXML;
 
       if (!responseXML || responseXML.documentElement.namespaceURI == XMLURI_PARSE_ERROR ||
           (request.status != 200 && request.status != 0)) {
         self._reportFailure();
         return;
       }
@@ -1191,17 +1193,17 @@ var AddonRepository = {
       let elements = documentElement.getElementsByTagName("addon");
       let totalResults = elements.length;
       let parsedTotalResults = parseInt(documentElement.getAttribute("total_results"));
       // Parsed value of total results only makes sense if >= elements.length
       if (parsedTotalResults >= totalResults)
         totalResults = parsedTotalResults;
 
       aHandleResults(elements, totalResults);
-    };
+    }, false);
     this._request.send(null);
   },
 
   // Gets the id's of local add-ons, and the sourceURI's of local installs,
   // passing the results to aCallback
   _getLocalAddonIds: function(aCallback) {
     let self = this;
     let localAddonIds = {ids: null, sourceURIs: null};
--- a/toolkit/mozapps/extensions/AddonUpdateChecker.jsm
+++ b/toolkit/mozapps/extensions/AddonUpdateChecker.jsm
@@ -446,18 +446,18 @@ function UpdateParser(aId, aType, aUpdat
   try {
     this.request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
                    createInstance(Ci.nsIXMLHttpRequest);
     this.request.open("GET", aUrl, true);
     this.request.channel.notificationCallbacks = new BadCertHandler(!requireBuiltIn);
     this.request.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
     this.request.overrideMimeType("text/xml");
     var self = this;
-    this.request.onload = function(event) { self.onLoad() };
-    this.request.onerror = function(event) { self.onError() };
+    this.request.addEventListener("load", function(event) { self.onLoad() }, false);
+    this.request.addEventListener("error", function(event) { self.onError() }, false);
     this.request.send(null);
   }
   catch (e) {
     ERROR("Failed to request update manifest", e);
   }
 }
 
 UpdateParser.prototype = {
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
@@ -222,30 +222,30 @@ var LightweightThemeManager = {
     var req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
                 .createInstance(Ci.nsIXMLHttpRequest);
 
     req.mozBackgroundRequest = true;
     req.overrideMimeType("text/plain");
     req.open("GET", theme.updateURL, true);
 
     var self = this;
-    req.onload = function () {
+    req.addEventListener("load", function () {
       if (req.status != 200)
         return;
 
       let newData = self.parseTheme(req.responseText, theme.updateURL);
       if (!newData ||
           newData.id != theme.id ||
           _version(newData) == _version(theme))
         return;
 
       var currentTheme = self.currentTheme;
       if (currentTheme && currentTheme.id == theme.id)
         self.currentTheme = newData;
-    };
+    }, false);
 
     req.send(null);
   },
 
   /**
    * Switches to a new lightweight theme.
    *
    * @param  aData
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/nsBlocklistService.js
@@ -541,18 +541,18 @@ Blocklist.prototype = {
                   createInstance(Ci.nsIXMLHttpRequest);
     request.open("GET", uri.spec, true);
     request.channel.notificationCallbacks = new gCertUtils.BadCertHandler();
     request.overrideMimeType("text/xml");
     request.setRequestHeader("Cache-Control", "no-cache");
     request.QueryInterface(Components.interfaces.nsIJSXMLHttpRequest);
 
     var self = this;
-    request.onerror = function(event) { self.onXMLError(event); };
-    request.onload  = function(event) { self.onXMLLoad(event);  };
+    request.addEventListener("error", function(event) { self.onXMLError(event); }, false);
+    request.addEventListener("load", function(event) { self.onXMLLoad(event);  }, false);
     request.send(null);
 
     // When the blocklist loads we need to compare it to the current copy so
     // make sure we have loaded it.
     if (!this._addonEntries)
       this._loadBlocklist();
   },
 
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -2150,19 +2150,19 @@ Checker.prototype = {
     this._request.open("GET", url, true);
     var allowNonBuiltIn = !getPref("getBoolPref",
                                    PREF_APP_UPDATE_CERT_REQUIREBUILTIN, true);
     this._request.channel.notificationCallbacks = new gCertUtils.BadCertHandler(allowNonBuiltIn);
     this._request.overrideMimeType("text/xml");
     this._request.setRequestHeader("Cache-Control", "no-cache");
 
     var self = this;
-    this._request.onerror     = function(event) { self.onError(event);    };
-    this._request.onload      = function(event) { self.onLoad(event);     };
-    this._request.onprogress  = function(event) { self.onProgress(event); };
+    this._request.addEventListener("error", function(event) { self.onError(event); } ,false);
+    this._request.addEventListener("load", function(event) { self.onLoad(event); }, false);
+    this._request.addEventListener("progress", function(event) { self.onProgress(event); }, false);
 
     LOG("Checker:checkForUpdates - sending request to: " + url);
     this._request.send(null);
 
     this._callback = listener;
   },
 
   /**