Bug 1115293 - Remove deprecated SpiderMonkey language extensions from about:permissions. r=Mossop
authorChris Peterson <cpeterson@mozilla.com>
Sat, 29 Nov 2014 23:46:55 -0800
changeset 247732 9096b9b4aa73d58742e88ced38f1d2018464f295
parent 247731 2efc03ac92f93ded5e78feca09b3e9188616ab61
child 247733 2fbdaa8a5ea77c689fe7003217866f1674a0292d
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMossop
bugs1115293
milestone37.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 1115293 - Remove deprecated SpiderMonkey language extensions from about:permissions. r=Mossop
browser/components/preferences/aboutPermissions.js
toolkit/forgetaboutsite/ForgetAboutSite.jsm
--- a/browser/components/preferences/aboutPermissions.js
+++ b/browser/components/preferences/aboutPermissions.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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";
+
 let Ci = Components.interfaces;
 let Cc = Components.classes;
 let Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/DownloadUtils.jsm");
 Cu.import("resource://gre/modules/NetUtil.jsm");
@@ -564,28 +566,27 @@ let AboutPermissions = {
         let uri = NetUtil.newURI(aHostname);
         this.addHost(uri.host);
       } catch (e) {
         // newURI will throw for add-ons logins stored in chrome:// URIs
       }
       itemCnt++;
     }, this);
 
-    let (enumerator = Services.perms.enumerator) {
-      while (enumerator.hasMoreElements()) {
-        if (itemCnt % this.LIST_BUILD_CHUNK == 0) {
-          yield true;
-        }
-        let permission = enumerator.getNext().QueryInterface(Ci.nsIPermission);
-        // Only include sites with exceptions set for supported permission types.
-        if (this._supportedPermissions.indexOf(permission.type) != -1) {
-          this.addHost(permission.host);
-        }
-        itemCnt++;
+    let enumerator = Services.perms.enumerator;
+    while (enumerator.hasMoreElements()) {
+      if (itemCnt % this.LIST_BUILD_CHUNK == 0) {
+        yield true;
       }
+      let permission = enumerator.getNext().QueryInterface(Ci.nsIPermission);
+      // Only include sites with exceptions set for supported permission types.
+      if (this._supportedPermissions.indexOf(permission.type) != -1) {
+        this.addHost(permission.host);
+      }
+      itemCnt++;
     }
 
     yield false;
   },
 
   /**
    * Creates a new Site and adds it to _sites if it's not already there.
    *
@@ -667,17 +668,18 @@ let AboutPermissions = {
   /**
    * Deletes sites for a host and all of its sub-domains. Removes these sites
    * from _sites and removes their corresponding elements from the DOM.
    *
    * @param aHost
    *        The host string corresponding to the site to delete.
    */
   deleteFromSitesList: function(aHost) {
-    for each (let site in this._sites) {
+    for (let host in this._sites) {
+      let site = this._sites[host];
       if (site.host.hasRootDomain(aHost)) {
         if (site == this._selectedSite) {
           // Replace site-specific interface with "All Sites" interface.
           this.sitesList.selectedItem = document.getElementById("all-sites-item");
         }
 
         this.sitesList.removeChild(site.listitem);
         delete this._sites[site.host];
--- a/toolkit/forgetaboutsite/ForgetAboutSite.jsm
+++ b/toolkit/forgetaboutsite/ForgetAboutSite.jsm
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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";
+
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/NetUtil.jsm");
 Components.utils.import("resource://gre/modules/Task.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
                                   "resource://gre/modules/PlacesUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
                                   "resource://gre/modules/Downloads.jsm");
@@ -43,60 +45,56 @@ const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 this.ForgetAboutSite = {
   removeDataFromDomain: function CRH_removeDataFromDomain(aDomain)
   {
     PlacesUtils.history.removePagesFromHost(aDomain, true);
 
     // Cache
-    let (cs = Cc["@mozilla.org/netwerk/cache-storage-service;1"].
-              getService(Ci.nsICacheStorageService)) {
-      // NOTE: there is no way to clear just that domain, so we clear out
-      //       everything)
-      try {
-        cs.clear();
-      } catch (ex) {
-        Cu.reportError("Exception thrown while clearing the cache: " +
-          ex.toString());
-      }
+    let cs = Cc["@mozilla.org/netwerk/cache-storage-service;1"].
+             getService(Ci.nsICacheStorageService);
+    // NOTE: there is no way to clear just that domain, so we clear out
+    //       everything)
+    try {
+      cs.clear();
+    } catch (ex) {
+      Cu.reportError("Exception thrown while clearing the cache: " +
+        ex.toString());
     }
 
     // Image Cache
-    let (imageCache = Cc["@mozilla.org/image/tools;1"].
-                      getService(Ci.imgITools).getImgCacheForDocument(null)) {
-      try {
-        imageCache.clearCache(false); // true=chrome, false=content
-      } catch (ex) {
-        Cu.reportError("Exception thrown while clearing the image cache: " +
-          ex.toString());
-      }
+    let imageCache = Cc["@mozilla.org/image/tools;1"].
+                     getService(Ci.imgITools).getImgCacheForDocument(null);
+    try {
+      imageCache.clearCache(false); // true=chrome, false=content
+    } catch (ex) {
+      Cu.reportError("Exception thrown while clearing the image cache: " +
+        ex.toString());
     }
 
     // Cookies
-    let (cm = Cc["@mozilla.org/cookiemanager;1"].
-              getService(Ci.nsICookieManager2)) {
-      let enumerator = cm.getCookiesFromHost(aDomain);
-      while (enumerator.hasMoreElements()) {
-        let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
-        cm.remove(cookie.host, cookie.name, cookie.path, false);
-      }
+    let cm = Cc["@mozilla.org/cookiemanager;1"].
+             getService(Ci.nsICookieManager2);
+    let enumerator = cm.getCookiesFromHost(aDomain);
+    while (enumerator.hasMoreElements()) {
+      let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
+      cm.remove(cookie.host, cookie.name, cookie.path, false);
     }
 
     // Plugin data
     const phInterface = Ci.nsIPluginHost;
     const FLAG_CLEAR_ALL = phInterface.FLAG_CLEAR_ALL;
-    let (ph = Cc["@mozilla.org/plugin/host;1"].getService(phInterface)) {
-      let tags = ph.getPluginTags();
-      for (let i = 0; i < tags.length; i++) {
-        try {
-          ph.clearSiteData(tags[i], aDomain, FLAG_CLEAR_ALL, -1);
-        } catch (e) {
-          // Ignore errors from the plugin
-        }
+    let ph = Cc["@mozilla.org/plugin/host;1"].getService(phInterface);
+    let tags = ph.getPluginTags();
+    for (let i = 0; i < tags.length; i++) {
+      try {
+        ph.clearSiteData(tags[i], aDomain, FLAG_CLEAR_ALL, -1);
+      } catch (e) {
+        // Ignore errors from the plugin
       }
     }
 
     // Downloads
     let useJSTransfer = false;
     try {
       // This method throws an exception if the old Download Manager is disabled.
       Services.downloads.activeDownloadCount;
@@ -107,30 +105,29 @@ this.ForgetAboutSite = {
     if (useJSTransfer) {
       Task.spawn(function() {
         let list = yield Downloads.getList(Downloads.ALL);
         list.removeFinished(download => hasRootDomain(
              NetUtil.newURI(download.source.url).host, aDomain));
       }).then(null, Cu.reportError);
     }
     else {
-      let (dm = Cc["@mozilla.org/download-manager;1"].
-                getService(Ci.nsIDownloadManager)) {
-        // Active downloads
-        for (let enumerator of [dm.activeDownloads, dm.activePrivateDownloads]) {
-          while (enumerator.hasMoreElements()) {
-            let dl = enumerator.getNext().QueryInterface(Ci.nsIDownload);
-            if (hasRootDomain(dl.source.host, aDomain)) {
-              dl.cancel();
-              dl.remove();
-            }
+      let dm = Cc["@mozilla.org/download-manager;1"].
+               getService(Ci.nsIDownloadManager);
+      // Active downloads
+      for (let enumerator of [dm.activeDownloads, dm.activePrivateDownloads]) {
+        while (enumerator.hasMoreElements()) {
+          let dl = enumerator.getNext().QueryInterface(Ci.nsIDownload);
+          if (hasRootDomain(dl.source.host, aDomain)) {
+            dl.cancel();
+            dl.remove();
           }
         }
 
-        function deleteAllLike(db) {
+        const deleteAllLike = function(db) {
           // NOTE: This is lossy, but we feel that it is OK to be lossy here and not
           //       invoke the cost of creating a URI for each download entry and
           //       ensure that the hostname matches.
           let stmt = db.createStatement(
             "DELETE FROM moz_downloads " +
             "WHERE source LIKE ?1 ESCAPE '/' " +
             "AND state NOT IN (?2, ?3, ?4)"
           );
@@ -155,62 +152,59 @@ this.ForgetAboutSite = {
         // observer topic
         let os = Cc["@mozilla.org/observer-service;1"].
                  getService(Ci.nsIObserverService);
         os.notifyObservers(null, "download-manager-remove-download", null);
       }
     }
 
     // Passwords
-    let (lm = Cc["@mozilla.org/login-manager;1"].
-              getService(Ci.nsILoginManager)) {
-      // Clear all passwords for domain
-      try {
-        let logins = lm.getAllLogins();
-        for (let i = 0; i < logins.length; i++)
-          if (hasRootDomain(logins[i].hostname, aDomain))
-            lm.removeLogin(logins[i]);
-      }
-      // XXXehsan: is there a better way to do this rather than this
-      // hacky comparison?
-      catch (ex if ex.message.indexOf("User canceled Master Password entry") != -1) { }
+    let lm = Cc["@mozilla.org/login-manager;1"].
+             getService(Ci.nsILoginManager);
+    // Clear all passwords for domain
+    try {
+      let logins = lm.getAllLogins();
+      for (let i = 0; i < logins.length; i++)
+        if (hasRootDomain(logins[i].hostname, aDomain))
+          lm.removeLogin(logins[i]);
+    }
+    // XXXehsan: is there a better way to do this rather than this
+    // hacky comparison?
+    catch (ex if ex.message.indexOf("User canceled Master Password entry") != -1) { }
 
-      // Clear any "do not save for this site" for this domain
-      let disabledHosts = lm.getAllDisabledHosts();
-      for (let i = 0; i < disabledHosts.length; i++)
-        if (hasRootDomain(disabledHosts[i], aDomain))
-          lm.setLoginSavingEnabled(disabledHosts, true);
-    }
+    // Clear any "do not save for this site" for this domain
+    let disabledHosts = lm.getAllDisabledHosts();
+    for (let i = 0; i < disabledHosts.length; i++)
+      if (hasRootDomain(disabledHosts[i], aDomain))
+        lm.setLoginSavingEnabled(disabledHosts, true);
 
     // Permissions
-    let (pm = Cc["@mozilla.org/permissionmanager;1"].
-              getService(Ci.nsIPermissionManager)) {
-      // Enumerate all of the permissions, and if one matches, remove it
-      let enumerator = pm.enumerator;
-      while (enumerator.hasMoreElements()) {
-        let perm = enumerator.getNext().QueryInterface(Ci.nsIPermission);
-        if (hasRootDomain(perm.host, aDomain))
-          pm.remove(perm.host, perm.type);
-      }
+    let pm = Cc["@mozilla.org/permissionmanager;1"].
+             getService(Ci.nsIPermissionManager);
+    // Enumerate all of the permissions, and if one matches, remove it
+    enumerator = pm.enumerator;
+    while (enumerator.hasMoreElements()) {
+      let perm = enumerator.getNext().QueryInterface(Ci.nsIPermission);
+      if (hasRootDomain(perm.host, aDomain))
+        pm.remove(perm.host, perm.type);
     }
 
     // Offline Storages
-    let (qm = Cc["@mozilla.org/dom/quota/manager;1"].
-              getService(Ci.nsIQuotaManager)) {
-      // delete data from both HTTP and HTTPS sites
-      let caUtils = {};
-      let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
-                         getService(Ci.mozIJSSubScriptLoader);
-      scriptLoader.loadSubScript("chrome://global/content/contentAreaUtils.js",
-                                 caUtils);
-      let httpURI = caUtils.makeURI("http://" + aDomain);
-      let httpsURI = caUtils.makeURI("https://" + aDomain);
-      qm.clearStoragesForURI(httpURI);
-      qm.clearStoragesForURI(httpsURI);
-    }
+    let qm = Cc["@mozilla.org/dom/quota/manager;1"].
+             getService(Ci.nsIQuotaManager);
+    // delete data from both HTTP and HTTPS sites
+    let caUtils = {};
+    let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
+                       getService(Ci.mozIJSSubScriptLoader);
+    scriptLoader.loadSubScript("chrome://global/content/contentAreaUtils.js",
+                               caUtils);
+    let httpURI = caUtils.makeURI("http://" + aDomain);
+    let httpsURI = caUtils.makeURI("https://" + aDomain);
+    qm.clearStoragesForURI(httpURI);
+    qm.clearStoragesForURI(httpsURI);
 
     function onContentPrefsRemovalFinished() {
       // Everybody else (including extensions)
       Services.obs.notifyObservers(null, "browser:purge-domain-data", aDomain);
     }
 
     // Content Preferences
     let cps2 = Cc["@mozilla.org/content-pref/service;1"].