Bug 1274461 - Part 1: undoCloseTab should preserve userContextId. r=mikedeboer
authorYoshi Huang <allstars.chh@mozilla.com>
Wed, 25 May 2016 16:19:57 +0800
changeset 341436 ba2c44ebb458ba9f62158643d54b34c64a5459fc
parent 341435 c9b085a46a531e115314ecfa86928f7dd4931a9e
child 341437 898dd582cd3668633fcc3a22cc6288a6643d2dcc
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1274461
milestone49.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 1274461 - Part 1: undoCloseTab should preserve userContextId. r=mikedeboer
browser/components/sessionstore/SessionStore.jsm
browser/components/sessionstore/test/browser_sessionStoreContainer.js
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -2160,17 +2160,17 @@ var SessionStoreInternal = {
       throw Components.Exception("Invalid index: not in the closed tabs", Cr.NS_ERROR_INVALID_ARG);
     }
 
     // fetch the data of closed tab, while removing it from the array
     let {state, pos} = this.removeClosedTabData(closedTabs, aIndex);
 
     // create a new tab
     let tabbrowser = aWindow.gBrowser;
-    let tab = tabbrowser.selectedTab = tabbrowser.addTab();
+    let tab = tabbrowser.selectedTab = tabbrowser.addTab(null, state);
 
     // restore tab content
     this.restoreTab(tab, state);
 
     // restore the tab's position
     tabbrowser.moveTabTo(tab, pos);
 
     // focus the tab's content area (bug 342432)
--- a/browser/components/sessionstore/test/browser_sessionStoreContainer.js
+++ b/browser/components/sessionstore/test/browser_sessionStoreContainer.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 add_task(function* () {
   for (let i = 0; i < 3; ++i) {
-    let tab = gBrowser.addTab("http://example.com/", {userContextId: i});
+    let tab = gBrowser.addTab("http://example.com/", { userContextId: i });
     let browser = tab.linkedBrowser;
 
     yield promiseBrowserLoaded(browser);
 
     let tab2 = gBrowser.duplicateTab(tab);
     Assert.equal(tab2.getAttribute("usercontextid"), i);
     let browser2 = tab2.linkedBrowser;
     yield promiseTabRestored(tab2)
@@ -21,29 +21,48 @@ add_task(function* () {
     });
 
     yield promiseRemoveTab(tab);
     yield promiseRemoveTab(tab2);
   }
 });
 
 add_task(function* () {
-  let tab = gBrowser.addTab("http://example.com/", {userContextId: 1});
+  let tab = gBrowser.addTab("http://example.com/", { userContextId: 1 });
   let browser = tab.linkedBrowser;
 
   yield promiseBrowserLoaded(browser);
 
   gBrowser.selectedTab = tab;
 
   let tab2 = gBrowser.duplicateTab(tab);
   let browser2 = tab2.linkedBrowser;
   yield promiseTabRestored(tab2)
 
-  yield ContentTask.spawn(browser2, { expectedId: 1}, function* (args) {
+  yield ContentTask.spawn(browser2, { expectedId: 1 }, function* (args) {
     Assert.equal(docShell.getOriginAttributes().userContextId,
                  args.expectedId,
                  "The docShell has the correct userContextId");
   });
 
   yield promiseRemoveTab(tab);
   yield promiseRemoveTab(tab2);
 });
 
+add_task(function* () {
+  let tab = gBrowser.addTab("http://example.com/", { userContextId: 1 });
+  let browser = tab.linkedBrowser;
+
+  yield promiseBrowserLoaded(browser);
+
+  gBrowser.removeTab(tab);
+
+  let tab2 = ss.undoCloseTab(window, 0);
+  Assert.equal(tab2.getAttribute("usercontextid"), 1);
+  yield promiseTabRestored(tab2);
+  yield ContentTask.spawn(tab2.linkedBrowser, { expectedId: 1 }, function* (args) {
+    Assert.equal(docShell.getOriginAttributes().userContextId,
+                 args.expectedId,
+                 "The docShell has the correct userContextId");
+  });
+
+  yield promiseRemoveTab(tab2);
+});