summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/browser_739531.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /browser/components/sessionstore/test/browser_739531.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/sessionstore/test/browser_739531.js')
-rw-r--r--browser/components/sessionstore/test/browser_739531.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_739531.js b/browser/components/sessionstore/test/browser_739531.js
new file mode 100644
index 0000000000..da82c45991
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_739531.js
@@ -0,0 +1,55 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// This test ensures that attempts made to save/restore ("duplicate") pages
+// using designmode AND make changes to document structure (remove body)
+// don't result in uncaught errors and a broken browser state.
+
+function test() {
+ waitForExplicitFinish();
+
+ let testURL =
+ "http://mochi.test:8888/browser/" +
+ "browser/components/sessionstore/test/browser_739531_sample.html";
+
+ let loadCount = 0;
+ let tab = BrowserTestUtils.addTab(gBrowser, testURL);
+
+ let removeFunc;
+ removeFunc = BrowserTestUtils.addContentEventListener(
+ tab.linkedBrowser,
+ "load",
+ function onLoad(aEvent) {
+ // make sure both the page and the frame are loaded
+ if (++loadCount < 2) {
+ return;
+ }
+ removeFunc();
+
+ // executeSoon to allow the JS to execute on the page
+ executeSoon(function() {
+ let tab2;
+ let caughtError = false;
+ try {
+ tab2 = ss.duplicateTab(window, tab);
+ } catch (e) {
+ caughtError = true;
+ info(e);
+ }
+
+ is(gBrowser.tabs.length, 3, "there should be 3 tabs");
+
+ ok(!caughtError, "duplicateTab didn't throw");
+
+ // if the test fails, we don't want to try to close a tab that doesn't exist
+ if (tab2) {
+ gBrowser.removeTab(tab2);
+ }
+ gBrowser.removeTab(tab);
+
+ finish();
+ });
+ },
+ true
+ );
+}