Bug 1483440 - Part 2 - Don't use purge-domain-data to clear session history for a domain. r=mikedeboer,baku
authorJohann Hofmann <jhofmann@mozilla.com>
Thu, 17 Jan 2019 17:41:23 +0000
changeset 454310 170f979a5f7d570780bb45872ce1ab4c8138ceec
parent 454309 6f9d7c3c98fa22919f7b5d45554ad2224a2cdc81
child 454311 4b57fb875b4293ad718447795925ecc6df31a0ae
push id35392
push userncsoregi@mozilla.com
push dateThu, 17 Jan 2019 21:53:28 +0000
treeherdermozilla-central@24982570fc83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer, baku
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 2 - Don't use purge-domain-data to clear session history for a domain. r=mikedeboer,baku Differential Revision: https://phabricator.services.mozilla.com/D16461
browser/components/sessionstore/ContentSessionStore.jsm
browser/components/sessionstore/SessionStore.jsm
browser/components/sessionstore/test/browser_394759_purge.js
browser/components/sessionstore/test/browser_464199.js
browser/components/sessionstore/test/browser_closed_objects_changed_notifications_tabs.js
browser/components/sessionstore/test/browser_sessionStorage.js
browser/components/sessionstore/test/content.js
toolkit/components/cleardata/ClearDataService.js
toolkit/components/cleardata/nsIClearDataService.idl
--- a/browser/components/sessionstore/ContentSessionStore.jsm
+++ b/browser/components/sessionstore/ContentSessionStore.jsm
@@ -436,23 +436,23 @@ class SessionStorageListener extends Han
     // a "storagechange" event. If however for some reason before we send these
     // changes we have to send over the entire sessions storage data, we just
     // reset these changes.
     this._changes = undefined;
 
     // The event listener waiting for MozSessionStorageChanged events.
     this._listener = null;
 
-    Services.obs.addObserver(this, "browser:purge-domain-data");
+    Services.obs.addObserver(this, "browser:purge-sessionStorage");
     this.stateChangeNotifier.addObserver(this);
     this.resetEventListener();
   }
 
   uninit() {
-    Services.obs.removeObserver(this, "browser:purge-domain-data");
+    Services.obs.removeObserver(this, "browser:purge-sessionStorage");
   }
 
   observe() {
     // Collect data on the next tick so that any other observer
     // that needs to purge data can do its work first.
     setTimeoutWithTarget(() => this.collect(), 0, this.mm.tabEventTarget);
   }
 
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -41,17 +41,17 @@ const MAX_CONCURRENT_TAB_RESTORES = 3;
 // pull the window back within the available screen area.
 const SCREEN_EDGE_SLOP = 8;
 
 // global notifications observed
 const OBSERVING = [
   "browser-window-before-show", "domwindowclosed",
   "quit-application-granted", "browser-lastwindow-close-granted",
   "quit-application", "browser:purge-session-history",
-  "browser:purge-domain-data",
+  "browser:purge-session-history-for-domain",
   "idle-daily", "clear-origin-attributes-data",
 ];
 
 // XUL Window properties to (re)store
 // Restored in restoreDimensions()
 const WINDOW_ATTRIBUTES = ["width", "height", "screenX", "screenY", "sizemode"];
 
 // Hideable window features to (re)store
@@ -781,17 +781,17 @@ var SessionStoreInternal = {
         break;
       case "quit-application":
         this.onQuitApplication(aData);
         break;
       case "browser:purge-session-history": // catch sanitization
         this.onPurgeSessionHistory();
         this._notifyOfClosedObjectsChange();
         break;
-      case "browser:purge-domain-data":
+      case "browser:purge-session-history-for-domain":
         this.onPurgeDomainData(aData);
         this._notifyOfClosedObjectsChange();
         break;
       case "nsPref:changed": // catch pref changes
         this.onPrefChange(aData);
         this._notifyOfClosedObjectsChange();
         break;
       case "idle-daily":
--- a/browser/components/sessionstore/test/browser_394759_purge.js
+++ b/browser/components/sessionstore/test/browser_394759_purge.js
@@ -3,21 +3,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 let {ForgetAboutSite} = ChromeUtils.import("resource://gre/modules/ForgetAboutSite.jsm", {});
 
 function promiseClearHistory() {
   return new Promise(resolve => {
     let observer = {
       observe(aSubject, aTopic, aData) {
-        Services.obs.removeObserver(this, "browser:purge-domain-data");
+        Services.obs.removeObserver(this, "browser:purge-session-history-for-domain");
         resolve();
       },
     };
-    Services.obs.addObserver(observer, "browser:purge-domain-data");
+    Services.obs.addObserver(observer, "browser:purge-session-history-for-domain");
   });
 }
 
 add_task(async function() {
   // utility functions
   function countClosedTabsByTitle(aClosedTabList, aTitle) {
     return aClosedTabList.filter(aData => aData.title == aTitle).length;
   }
--- a/browser/components/sessionstore/test/browser_464199.js
+++ b/browser/components/sessionstore/test/browser_464199.js
@@ -3,21 +3,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 let {ForgetAboutSite} = ChromeUtils.import("resource://gre/modules/ForgetAboutSite.jsm", {});
 
 function promiseClearHistory() {
   return new Promise(resolve => {
     let observer = {
       observe(aSubject, aTopic, aData) {
-        Services.obs.removeObserver(this, "browser:purge-domain-data");
+        Services.obs.removeObserver(this, "browser:purge-session-history-for-domain");
         resolve();
       },
     };
-    Services.obs.addObserver(observer, "browser:purge-domain-data");
+    Services.obs.addObserver(observer, "browser:purge-session-history-for-domain");
   });
 }
 
 add_task(async function() {
   /** Test for Bug 464199 **/
 
   const REMEMBER = Date.now(), FORGET = Math.random();
   let test_state = { windows: [{ "tabs": [{ "entries": [] }], _closedTabs: [
--- a/browser/components/sessionstore/test/browser_closed_objects_changed_notifications_tabs.js
+++ b/browser/components/sessionstore/test/browser_closed_objects_changed_notifications_tabs.js
@@ -93,21 +93,21 @@ add_task(async function test_closedObjec
   await awaitNotification(() => Services.obs.notifyObservers(null, "browser:purge-session-history"));
   assertNotificationCount(6);
 
   info("Opening and closing another tab.");
   await openAndCloseTab(win, "http://example.com/");
   assertNotificationCount(7);
 
   info("Purging domain data with no matches.");
-  Services.obs.notifyObservers(null, "browser:purge-domain-data", "mozilla.com");
+  Services.obs.notifyObservers(null, "browser:purge-session-history-for-domain", "mozilla.com");
   assertNotificationCount(7);
 
   info("Purging domain data with matches.");
-  await awaitNotification(() => Services.obs.notifyObservers(null, "browser:purge-domain-data", "example.com"));
+  await awaitNotification(() => Services.obs.notifyObservers(null, "browser:purge-session-history-for-domain", "example.com"));
   assertNotificationCount(8);
 
   info("Opening and closing another tab.");
   await openAndCloseTab(win, "http://example.com/");
   assertNotificationCount(9);
 
   await closeWindow(win);
   assertNotificationCount(10);
--- a/browser/components/sessionstore/test/browser_sessionStorage.js
+++ b/browser/components/sessionstore/test/browser_sessionStorage.js
@@ -195,10 +195,13 @@ add_task(async function respect_privacy_
   [{state: {storage}}] = JSON.parse(ss.getClosedTabData(window));
   is(storage["http://mochi.test:8888"].test, OUTER_VALUE,
     "http sessionStorage data has been saved");
   is(storage["https://example.com"].test, INNER_VALUE,
     "https sessionStorage data has been saved");
 });
 
 function purgeDomainData(browser, domain) {
-  return sendMessage(browser, "ss-test:purgeDomainData", domain);
+  return new Promise(resolve => {
+    Services.clearData.deleteDataFromHost(
+      domain, true, Services.clearData.CLEAR_SESSION_HISTORY, resolve);
+  });
 }
--- a/browser/components/sessionstore/test/content.js
+++ b/browser/components/sessionstore/test/content.js
@@ -49,21 +49,16 @@ if (sessionHistory) {
  * This frame script is only loaded for sessionstore mochitests. It enables us
  * to modify and query docShell data when running with multiple processes.
  */
 
 addEventListener("hashchange", function() {
   sendAsyncMessage("ss-test:hashchange");
 });
 
-addMessageListener("ss-test:purgeDomainData", function({data: domain}) {
-  Services.obs.notifyObservers(null, "browser:purge-domain-data", domain);
-  content.setTimeout(() => sendAsyncMessage("ss-test:purgeDomainData"));
-});
-
 addMessageListener("ss-test:getStyleSheets", function(msg) {
   let sheets = content.document.styleSheets;
   let titles = Array.map(sheets, ss => [ss.title, ss.disabled]);
   sendSyncMessage("ss-test:getStyleSheets", titles);
 });
 
 addMessageListener("ss-test:enableStyleSheetsForSet", function(msg) {
   let sheets = content.document.styleSheets;
--- a/toolkit/components/cleardata/ClearDataService.js
+++ b/toolkit/components/cleardata/ClearDataService.js
@@ -525,16 +525,23 @@ const HistoryCleaner = {
   },
 
   deleteAll() {
     return PlacesUtils.history.clear();
   },
 };
 
 const SessionHistoryCleaner = {
+  deleteByHost(aHost, aOriginAttributes) {
+    return new Promise(aResolve => {
+      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));
       aResolve();
     });
   },
 
   deleteAll() {
--- a/toolkit/components/cleardata/nsIClearDataService.idl
+++ b/toolkit/components/cleardata/nsIClearDataService.idl
@@ -209,18 +209,18 @@ interface nsIClearDataService : nsISuppo
    */
   const uint32_t CLEAR_DOM_STORAGES = CLEAR_APPCACHE | CLEAR_DOM_QUOTA |
     CLEAR_DOM_PUSH_NOTIFICATIONS | CLEAR_REPORTS;
 
   /**
    * Helper flag for forget about site
    */
   const uint32_t CLEAR_FORGET_ABOUT_SITE =
-    CLEAR_HISTORY | CLEAR_NETWORK_CACHE | CLEAR_IMAGE_CACHE | CLEAR_COOKIES |
-    CLEAR_EME | CLEAR_PLUGIN_DATA | CLEAR_DOWNLOADS | CLEAR_PASSWORDS |
+    CLEAR_HISTORY | CLEAR_SESSION_HISTORY | CLEAR_NETWORK_CACHE | CLEAR_IMAGE_CACHE |
+    CLEAR_COOKIES | CLEAR_EME | CLEAR_PLUGIN_DATA | CLEAR_DOWNLOADS | CLEAR_PASSWORDS |
     CLEAR_PERMISSIONS | CLEAR_DOM_STORAGES | CLEAR_CONTENT_PREFERENCES |
     CLEAR_PREDICTOR_NETWORK_DATA | CLEAR_DOM_PUSH_NOTIFICATIONS |
     CLEAR_SECURITY_SETTINGS | CLEAR_REPORTS;
 };
 
 /**
  * This is a companion interface for
  * nsIClearDataService::deleteDataFromPrincipal().