Bug 1483440 - Part 3 - Use purge-localStorage instead of purge-domain-data to clean up localStorage. r=baku
authorJohann Hofmann <jhofmann@mozilla.com>
Thu, 17 Jan 2019 17:41:28 +0000
changeset 514296 4b57fb875b4293ad718447795925ecc6df31a0ae
parent 514295 170f979a5f7d570780bb45872ce1ab4c8138ceec
child 514297 cb1a55c678c1bad3e9e6634f7222186ece14e4b3
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1483440
milestone66.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 1483440 - Part 3 - Use purge-localStorage instead of purge-domain-data to clean up localStorage. r=baku Differential Revision: https://phabricator.services.mozilla.com/D16462
browser/modules/SiteDataManager.jsm
toolkit/components/cleardata/ClearDataService.js
--- a/browser/modules/SiteDataManager.jsm
+++ b/browser/modules/SiteDataManager.jsm
@@ -337,18 +337,19 @@ var SiteDataManager = {
     await this._getQuotaUsage();
     this._updateAppCache();
 
     let unknownHost = "";
     let promises = [];
     for (let host of hosts) {
       let site = this._sites.get(host);
       if (site) {
-        // Clear localstorage.
-        Services.obs.notifyObservers(null, "browser:purge-domain-data", host);
+        // Clear localStorage & sessionStorage
+        Services.obs.notifyObservers(null, "extension:purge-localStorage", host);
+        Services.obs.notifyObservers(null, "extension:purge-sessionStorage", host);
         this._removePermission(site);
         this._removeAppCache(site);
         this._removeCookies(site);
         promises.push(ServiceWorkerCleanUp.removeFromHost(host));
         promises.push(this._removeQuotaUsage(site));
       } else {
         unknownHost = host;
         break;
--- a/toolkit/components/cleardata/ClearDataService.js
+++ b/toolkit/components/cleardata/ClearDataService.js
@@ -289,17 +289,21 @@ const AppCacheCleaner = {
   },
 };
 
 const QuotaCleaner = {
   deleteByPrincipal(aPrincipal) {
     // localStorage: The legacy LocalStorage implementation that will
     // eventually be removed depends on this observer notification to clear by
     // principal.
-    Services.obs.notifyObservers(null, "browser:purge-domain-data",
+    Services.obs.notifyObservers(null, "extension:purge-localStorage",
+                                 aPrincipal.URI.host);
+
+    // Clear sessionStorage
+    Services.obs.notifyObservers(null, "browser:purge-sessionStorage",
                                  aPrincipal.URI.host);
 
     // ServiceWorkers: they must be removed before cleaning QuotaManager.
     return ServiceWorkerCleanUp.removeFromPrincipal(aPrincipal)
       .then(_ => /* exceptionThrown = */ false, _ => /* exceptionThrown = */ true)
       .then(exceptionThrown => {
         // QuotaManager: In the event of a failure, we call reject to propagate
         // the error upwards.
@@ -315,17 +319,20 @@ const QuotaCleaner = {
         });
       });
   },
 
   deleteByHost(aHost, aOriginAttributes) {
     // localStorage: The legacy LocalStorage implementation that will
     // eventually be removed depends on this observer notification to clear by
     // host.  Some other subsystems like Reporting headers depend on this too.
-    Services.obs.notifyObservers(null, "browser:purge-domain-data", aHost);
+    Services.obs.notifyObservers(null, "extension:purge-localStorage", aHost);
+
+    // Clear sessionStorage
+    Services.obs.notifyObservers(null, "browser:purge-sessionStorage", aHost);
 
     let exceptionThrown = false;
 
     // ServiceWorkers: they must be removed before cleaning QuotaManager.
     return Promise.all([
       ServiceWorkerCleanUp.removeFromHost("http://" + aHost).catch(_ => { exceptionThrown = true; }),
       ServiceWorkerCleanUp.removeFromHost("https://" + aHost).catch(_ => { exceptionThrown = true; }),
     ]).then(() => {
@@ -419,16 +426,19 @@ const QuotaCleaner = {
 
     return Promise.all(promises);
   },
 
   deleteAll() {
     // localStorage
     Services.obs.notifyObservers(null, "extension:purge-localStorage");
 
+    // sessionStorage
+    Services.obs.notifyObservers(null, "browser:purge-sessionStorage");
+
     // ServiceWorkers
     return ServiceWorkerCleanUp.removeAll()
       .then(_ => /* exceptionThrown = */ false, _ => /* exceptionThrown = */ true)
       .then(exceptionThrown => {
         // QuotaManager: In the event of a failure, we call reject to propagate
         // the error upwards.
         return new Promise((aResolve, aReject) => {
           Services.qms.getUsage(aRequest => {
@@ -527,16 +537,17 @@ const HistoryCleaner = {
   deleteAll() {
     return PlacesUtils.history.clear();
   },
 };
 
 const SessionHistoryCleaner = {
   deleteByHost(aHost, aOriginAttributes) {
     return new Promise(aResolve => {
+      Services.obs.notifyObservers(null, "browser:purge-sessionStorage", aHost);
       Services.obs.notifyObservers(null, "browser:purge-session-history-for-domain", aHost);
       aResolve();
     });
   },
 
   deleteByRange(aFrom, aTo) {
     return new Promise(aResolve => {
       Services.obs.notifyObservers(null, "browser:purge-session-history", String(aFrom));