summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/browser_aboutSessionRestore.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /browser/components/sessionstore/test/browser_aboutSessionRestore.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/components/sessionstore/test/browser_aboutSessionRestore.js')
-rw-r--r--browser/components/sessionstore/test/browser_aboutSessionRestore.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_aboutSessionRestore.js b/browser/components/sessionstore/test/browser_aboutSessionRestore.js
new file mode 100644
index 000000000..8ab91e4df
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_aboutSessionRestore.js
@@ -0,0 +1,55 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const CRASH_URL = "about:mozilla";
+const CRASH_FAVICON = "chrome://branding/content/icon32.png";
+const CRASH_SHENTRY = {url: CRASH_URL};
+const CRASH_TAB = {entries: [CRASH_SHENTRY], image: CRASH_FAVICON};
+const CRASH_STATE = {windows: [{tabs: [CRASH_TAB]}]};
+
+const TAB_URL = "about:sessionrestore";
+const TAB_FORMDATA = {url: TAB_URL, id: {sessionData: CRASH_STATE}};
+const TAB_SHENTRY = {url: TAB_URL};
+const TAB_STATE = {entries: [TAB_SHENTRY], formdata: TAB_FORMDATA};
+
+const FRAME_SCRIPT = "data:," +
+ "content.document.getElementById('errorTryAgain').click()";
+
+add_task(function* () {
+ // Prepare a blank tab.
+ let tab = gBrowser.addTab("about:blank");
+ let browser = tab.linkedBrowser;
+ yield promiseBrowserLoaded(browser);
+
+ // Fake a post-crash tab.
+ ss.setTabState(tab, JSON.stringify(TAB_STATE));
+ yield promiseTabRestored(tab);
+
+ ok(gBrowser.tabs.length > 1, "we have more than one tab");
+
+ let view = browser.contentDocument.getElementById("tabList").view;
+ ok(view.isContainer(0), "first entry is the window");
+ is(view.getCellProperties(1, { id: "title" }), "icon",
+ "second entry is the tab and has a favicon");
+
+ browser.messageManager.loadFrameScript(FRAME_SCRIPT, true);
+
+ // Wait until the new window was restored.
+ let win = yield waitForNewWindow();
+ yield BrowserTestUtils.closeWindow(win);
+
+ let [{tabs: [{entries: [{url}]}]}] = JSON.parse(ss.getClosedWindowData());
+ is(url, CRASH_URL, "session was restored correctly");
+ ss.forgetClosedWindow(0);
+});
+
+function waitForNewWindow() {
+ return new Promise(resolve => {
+ Services.obs.addObserver(function observe(win, topic) {
+ Services.obs.removeObserver(observe, topic);
+ resolve(win);
+ }, "browser-delayed-startup-finished", false);
+ });
+}