Bug 1399147 - fix session.getRecentlyClosed to match documented api, r?rpl draft
authorShane Caraveo <scaraveo@mozilla.com>
Tue, 24 Jul 2018 16:06:46 -0300
changeset 822096 9ef28804cc7bea6f8091dd52dd933881b0b79b00
parent 819645 8dab948a10f073a46f13f55f94d1f6514c7360ac
push id117291
push usermixedpuppy@gmail.com
push dateTue, 24 Jul 2018 19:07:15 +0000
reviewersrpl
bugs1399147
milestone63.0a1
Bug 1399147 - fix session.getRecentlyClosed to match documented api, r?rpl MozReview-Commit-ID: 6vsijgbQasn
browser/components/extensions/parent/ext-sessions.js
--- a/browser/components/extensions/parent/ext-sessions.js
+++ b/browser/components/extensions/parent/ext-sessions.js
@@ -12,28 +12,32 @@ ChromeUtils.defineModuleGetter(this, "Ad
 ChromeUtils.defineModuleGetter(this, "SessionStore",
                                "resource:///modules/sessionstore/SessionStore.jsm");
 
 const SS_ON_CLOSED_OBJECTS_CHANGED = "sessionstore-closed-objects-changed";
 
 const getRecentlyClosed = (maxResults, extension) => {
   let recentlyClosed = [];
 
+  // SessionStore sessions are longer lived, we need to limit
+  // data for extensions to the session since startup.
+  let startupTime = Services.startup.getStartupInfo().process;
+
   // Get closed windows
   let closedWindowData = SessionStore.getClosedWindowData(false);
-  for (let window of closedWindowData) {
+  for (let window of closedWindowData.filter(w => w.closedAt >= startupTime)) {
     recentlyClosed.push({
       lastModified: window.closedAt,
       window: Window.convertFromSessionStoreClosedData(extension, window)});
   }
 
   // Get closed tabs
   for (let window of windowTracker.browserWindows()) {
     let closedTabData = SessionStore.getClosedTabData(window, false);
-    for (let tab of closedTabData) {
+    for (let tab of closedTabData.filter(t => t.closedAt >= startupTime)) {
       recentlyClosed.push({
         lastModified: tab.closedAt,
         tab: Tab.convertFromSessionStoreClosedData(extension, tab, window)});
     }
   }
 
   // Sort windows and tabs
   recentlyClosed.sort((a, b) => b.lastModified - a.lastModified);