Bug 1278149 - split browser_sessionStoreContainer.js. r=mikedeboer
authorYoshi Huang <allstars.chh@mozilla.com>
Mon, 06 Jun 2016 10:59:30 +0800
changeset 300793 851259fb3bc45b0ef5c54c390fb953ec0789096d
parent 300792 6ff433eee86b1f64f9ee0955ced57cb215e82dc5
child 300794 c88f2cb8e4fae6764f559c0e43a93edd518102d2
push id19582
push usercbook@mozilla.com
push dateTue, 07 Jun 2016 13:51:05 +0000
treeherderfx-team@5c76c7484b9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1278149
milestone50.0a1
Bug 1278149 - split browser_sessionStoreContainer.js. r=mikedeboer
browser/components/sessionstore/test/browser.ini
browser/components/sessionstore/test/browser_sessionStoreContainer.js
browser/components/sessionstore/test/browser_windowStateContainer.js
--- a/browser/components/sessionstore/test/browser.ini
+++ b/browser/components/sessionstore/test/browser.ini
@@ -222,9 +222,10 @@ skip-if = os == "mac"
 [browser_multiple_navigateAndRestore.js]
 run-if = e10s
 [browser_async_window_flushing.js]
 [browser_forget_async_closings.js]
 [browser_newtab_userTypedValue.js]
 [browser_parentProcessRestoreHash.js]
 run-if = e10s
 [browser_sessionStoreContainer.js]
+[browser_windowStateContainer.js]
 [browser_1234021.js]
--- a/browser/components/sessionstore/test/browser_sessionStoreContainer.js
+++ b/browser/components/sessionstore/test/browser_sessionStoreContainer.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-requestLongerTimeout(3);
+"use strict";
 
 add_task(function* () {
   for (let i = 0; i < 3; ++i) {
     let tab = gBrowser.addTab("http://example.com/", { userContextId: i });
     let browser = tab.linkedBrowser;
 
     yield promiseBrowserLoaded(browser);
 
@@ -64,123 +64,8 @@ add_task(function* () {
     Assert.equal(docShell.getOriginAttributes().userContextId,
                  args.expectedId,
                  "The docShell has the correct userContextId");
   });
 
   yield promiseRemoveTab(tab2);
 });
 
-add_task(function* () {
-  let win = window.openDialog(location, "_blank", "chrome,all,dialog=no");
-  yield promiseWindowLoaded(win);
-
-  // Create 4 tabs with different userContextId.
-  for (let userContextId = 1; userContextId < 5; userContextId++) {
-    let tab = win.gBrowser.addTab("http://example.com/", {userContextId});
-    yield promiseBrowserLoaded(tab.linkedBrowser);
-    yield TabStateFlusher.flush(tab.linkedBrowser);
-  }
-
-  // Move the default tab of window to the end.
-  // We want the 1st tab to have non-default userContextId, so later when we
-  // restore into win2 we can test restore into an existing tab with different
-  // userContextId.
-  win.gBrowser.moveTabTo(win.gBrowser.tabs[0], win.gBrowser.tabs.length - 1);
-
-  let winState = JSON.parse(ss.getWindowState(win));
-
-  for (let i = 0; i < 4; i++) {
-    Assert.equal(winState.windows[0].tabs[i].userContextId, i + 1,
-                 "1st Window: tabs[" + i + "].userContextId should exist.");
-  }
-
-  let win2 = window.openDialog(location, "_blank", "chrome,all,dialog=no");
-  yield promiseWindowLoaded(win2);
-
-  // Create tabs with different userContextId, but this time we create them with
-  // fewer tabs and with different order with win.
-  for (let userContextId = 3; userContextId > 0; userContextId--) {
-    let tab = win2.gBrowser.addTab("http://example.com/", {userContextId});
-    yield promiseBrowserLoaded(tab.linkedBrowser);
-    yield TabStateFlusher.flush(tab.linkedBrowser);
-  }
-
-  ss.setWindowState(win2, JSON.stringify(winState), true);
-
-  for (let i = 0; i < 4; i++) {
-    let browser = win2.gBrowser.tabs[i].linkedBrowser;
-    yield ContentTask.spawn(browser, { expectedId: i + 1 }, function* (args) {
-      Assert.equal(docShell.getOriginAttributes().userContextId,
-                   args.expectedId,
-                   "The docShell has the correct userContextId");
-
-      Assert.equal(content.document.nodePrincipal.originAttributes.userContextId,
-                   args.expectedId,
-                   "The document has the correct userContextId");
-    });
-  }
-
-  // Test the last tab, which doesn't have userContextId.
-  let browser = win2.gBrowser.tabs[4].linkedBrowser;
-  yield ContentTask.spawn(browser, { expectedId: 0 }, function* (args) {
-    Assert.equal(docShell.getOriginAttributes().userContextId,
-                 args.expectedId,
-                 "The docShell has the correct userContextId");
-
-    Assert.equal(content.document.nodePrincipal.originAttributes.userContextId,
-                 args.expectedId,
-                 "The document has the correct userContextId");
-  });
-
-  yield BrowserTestUtils.closeWindow(win);
-  yield BrowserTestUtils.closeWindow(win2);
-});
-
-add_task(function* () {
-  let win = window.openDialog(location, "_blank", "chrome,all,dialog=no");
-  yield promiseWindowLoaded(win);
-
-  let tab = win.gBrowser.addTab("http://example.com/", { userContextId: 1 });
-  yield promiseBrowserLoaded(tab.linkedBrowser);
-  yield TabStateFlusher.flush(tab.linkedBrowser);
-
-  // win should have 1 default tab, and 1 container tab.
-  Assert.equal(win.gBrowser.tabs.length, 2, "win should have 2 tabs");
-
-  let winState = JSON.parse(ss.getWindowState(win));
-
-  for (let i = 0; i < 2; i++) {
-    Assert.equal(winState.windows[0].tabs[i].userContextId, i,
-                 "1st Window: tabs[" + i + "].userContextId should be " + i);
-  }
-
-  let win2 = window.openDialog(location, "_blank", "chrome,all,dialog=no");
-  yield promiseWindowLoaded(win2);
-
-  let tab2 = win2.gBrowser.addTab("http://example.com/", { userContextId : 1 });
-  yield promiseBrowserLoaded(tab2.linkedBrowser);
-  yield TabStateFlusher.flush(tab2.linkedBrowser);
-
-  // Move the first normal tab to end, so the first tab of win2 will be a
-  // container tab.
-  win2.gBrowser.moveTabTo(win2.gBrowser.tabs[0], win2.gBrowser.tabs.length - 1);
-  yield TabStateFlusher.flush(win2.gBrowser.tabs[0].linkedBrowser);
-
-  ss.setWindowState(win2, JSON.stringify(winState), true);
-
-  for (let i = 0; i < 2; i++) {
-    let browser = win2.gBrowser.tabs[i].linkedBrowser;
-    yield ContentTask.spawn(browser, { expectedId: i }, function* (args) {
-      Assert.equal(docShell.getOriginAttributes().userContextId,
-                   args.expectedId,
-                   "The docShell has the correct userContextId");
-
-      Assert.equal(content.document.nodePrincipal.originAttributes.userContextId,
-                   args.expectedId,
-                   "The document has the correct userContextId");
-    });
-  }
-
-  yield BrowserTestUtils.closeWindow(win);
-  yield BrowserTestUtils.closeWindow(win2);
-});
-
new file mode 100644
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_windowStateContainer.js
@@ -0,0 +1,119 @@
+"use strict";
+
+requestLongerTimeout(2);
+
+add_task(function* () {
+  let win = window.openDialog(location, "_blank", "chrome,all,dialog=no");
+  yield promiseWindowLoaded(win);
+
+  // Create 4 tabs with different userContextId.
+  for (let userContextId = 1; userContextId < 5; userContextId++) {
+    let tab = win.gBrowser.addTab("http://example.com/", {userContextId});
+    yield promiseBrowserLoaded(tab.linkedBrowser);
+    yield TabStateFlusher.flush(tab.linkedBrowser);
+  }
+
+  // Move the default tab of window to the end.
+  // We want the 1st tab to have non-default userContextId, so later when we
+  // restore into win2 we can test restore into an existing tab with different
+  // userContextId.
+  win.gBrowser.moveTabTo(win.gBrowser.tabs[0], win.gBrowser.tabs.length - 1);
+
+  let winState = JSON.parse(ss.getWindowState(win));
+
+  for (let i = 0; i < 4; i++) {
+    Assert.equal(winState.windows[0].tabs[i].userContextId, i + 1,
+                 "1st Window: tabs[" + i + "].userContextId should exist.");
+  }
+
+  let win2 = window.openDialog(location, "_blank", "chrome,all,dialog=no");
+  yield promiseWindowLoaded(win2);
+
+  // Create tabs with different userContextId, but this time we create them with
+  // fewer tabs and with different order with win.
+  for (let userContextId = 3; userContextId > 0; userContextId--) {
+    let tab = win2.gBrowser.addTab("http://example.com/", {userContextId});
+    yield promiseBrowserLoaded(tab.linkedBrowser);
+    yield TabStateFlusher.flush(tab.linkedBrowser);
+  }
+
+  ss.setWindowState(win2, JSON.stringify(winState), true);
+
+  for (let i = 0; i < 4; i++) {
+    let browser = win2.gBrowser.tabs[i].linkedBrowser;
+    yield ContentTask.spawn(browser, { expectedId: i + 1 }, function* (args) {
+      Assert.equal(docShell.getOriginAttributes().userContextId,
+                   args.expectedId,
+                   "The docShell has the correct userContextId");
+
+      Assert.equal(content.document.nodePrincipal.originAttributes.userContextId,
+                   args.expectedId,
+                   "The document has the correct userContextId");
+    });
+  }
+
+  // Test the last tab, which doesn't have userContextId.
+  let browser = win2.gBrowser.tabs[4].linkedBrowser;
+  yield ContentTask.spawn(browser, { expectedId: 0 }, function* (args) {
+    Assert.equal(docShell.getOriginAttributes().userContextId,
+                 args.expectedId,
+                 "The docShell has the correct userContextId");
+
+    Assert.equal(content.document.nodePrincipal.originAttributes.userContextId,
+                 args.expectedId,
+                 "The document has the correct userContextId");
+  });
+
+  yield BrowserTestUtils.closeWindow(win);
+  yield BrowserTestUtils.closeWindow(win2);
+});
+
+add_task(function* () {
+  let win = window.openDialog(location, "_blank", "chrome,all,dialog=no");
+  yield promiseWindowLoaded(win);
+
+  let tab = win.gBrowser.addTab("http://example.com/", { userContextId: 1 });
+  yield promiseBrowserLoaded(tab.linkedBrowser);
+  yield TabStateFlusher.flush(tab.linkedBrowser);
+
+  // win should have 1 default tab, and 1 container tab.
+  Assert.equal(win.gBrowser.tabs.length, 2, "win should have 2 tabs");
+
+  let winState = JSON.parse(ss.getWindowState(win));
+
+  for (let i = 0; i < 2; i++) {
+    Assert.equal(winState.windows[0].tabs[i].userContextId, i,
+                 "1st Window: tabs[" + i + "].userContextId should be " + i);
+  }
+
+  let win2 = window.openDialog(location, "_blank", "chrome,all,dialog=no");
+  yield promiseWindowLoaded(win2);
+
+  let tab2 = win2.gBrowser.addTab("http://example.com/", { userContextId : 1 });
+  yield promiseBrowserLoaded(tab2.linkedBrowser);
+  yield TabStateFlusher.flush(tab2.linkedBrowser);
+
+  // Move the first normal tab to end, so the first tab of win2 will be a
+  // container tab.
+  win2.gBrowser.moveTabTo(win2.gBrowser.tabs[0], win2.gBrowser.tabs.length - 1);
+  yield TabStateFlusher.flush(win2.gBrowser.tabs[0].linkedBrowser);
+
+  ss.setWindowState(win2, JSON.stringify(winState), true);
+
+  for (let i = 0; i < 2; i++) {
+    let browser = win2.gBrowser.tabs[i].linkedBrowser;
+    yield ContentTask.spawn(browser, { expectedId: i }, function* (args) {
+      Assert.equal(docShell.getOriginAttributes().userContextId,
+                   args.expectedId,
+                   "The docShell has the correct userContextId");
+
+      Assert.equal(content.document.nodePrincipal.originAttributes.userContextId,
+                   args.expectedId,
+                   "The document has the correct userContextId");
+    });
+  }
+
+  yield BrowserTestUtils.closeWindow(win);
+  yield BrowserTestUtils.closeWindow(win2);
+});
+