summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/browser_unrestored_crashedTabs.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_unrestored_crashedTabs.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_unrestored_crashedTabs.js')
-rw-r--r--browser/components/sessionstore/test/browser_unrestored_crashedTabs.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_unrestored_crashedTabs.js b/browser/components/sessionstore/test/browser_unrestored_crashedTabs.js
new file mode 100644
index 000000000..e46348e59
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_unrestored_crashedTabs.js
@@ -0,0 +1,69 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Tests that if we have tabs that are still in the "click to
+ * restore" state, that if their browsers crash, that we don't
+ * show the crashed state for those tabs (since selecting them
+ * should restore them anyway).
+ */
+
+const PREF = "browser.sessionstore.restore_on_demand";
+const PAGE = "data:text/html,<html><body>A%20regular,%20everyday,%20normal%20page.";
+
+add_task(function* test() {
+ yield pushPrefs([PREF, true]);
+
+ yield BrowserTestUtils.withNewTab({
+ gBrowser,
+ url: PAGE,
+ }, function*(browser) {
+ yield TabStateFlusher.flush(browser);
+
+ // We'll create a second "pending" tab. This is the one we'll
+ // ensure doesn't go to about:tabcrashed. We start it non-remote
+ // since this is how SessionStore creates all browsers before
+ // they are restored.
+ let unrestoredTab = gBrowser.addTab("about:blank", {
+ skipAnimation: true,
+ forceNotRemote: true,
+ });
+
+ let state = {
+ entries: [{url: PAGE}],
+ };
+
+ ss.setTabState(unrestoredTab, JSON.stringify(state));
+
+ ok(!unrestoredTab.hasAttribute("crashed"), "tab is not crashed");
+ ok(unrestoredTab.hasAttribute("pending"), "tab is pending");
+
+ // Now crash the selected browser.
+ yield BrowserTestUtils.crashBrowser(browser);
+
+ ok(!unrestoredTab.hasAttribute("crashed"), "tab is still not crashed");
+ ok(unrestoredTab.hasAttribute("pending"), "tab is still pending");
+
+ // Selecting the tab should now restore it.
+ gBrowser.selectedTab = unrestoredTab;
+ yield promiseTabRestored(unrestoredTab);
+
+ ok(!unrestoredTab.hasAttribute("crashed"), "tab is still not crashed");
+ ok(!unrestoredTab.hasAttribute("pending"), "tab is no longer pending");
+
+ // The original tab should still be crashed
+ let originalTab = gBrowser.getTabForBrowser(browser);
+ ok(originalTab.hasAttribute("crashed"), "original tab is crashed");
+ ok(!originalTab.isRemoteBrowser, "Should not be remote");
+
+ // We'd better be able to restore it still.
+ gBrowser.selectedTab = originalTab;
+ SessionStore.reviveCrashedTab(originalTab);
+ yield promiseTabRestored(originalTab);
+
+ // Clean up.
+ yield BrowserTestUtils.removeTab(unrestoredTab);
+ });
+});