diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/components/sessionstore/test/browser_586147.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/sessionstore/test/browser_586147.js')
-rw-r--r-- | browser/components/sessionstore/test/browser_586147.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_586147.js b/browser/components/sessionstore/test/browser_586147.js new file mode 100644 index 0000000000..aff6c4ce06 --- /dev/null +++ b/browser/components/sessionstore/test/browser_586147.js @@ -0,0 +1,52 @@ +/* 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/. */ + +function observeOneRestore(callback) { + let topic = "sessionstore-browser-state-restored"; + Services.obs.addObserver(function onRestore() { + Services.obs.removeObserver(onRestore, topic); + callback(); + }, topic); +} + +function test() { + waitForExplicitFinish(); + + // There should be one tab when we start the test + let [origTab] = gBrowser.visibleTabs; + let hiddenTab = BrowserTestUtils.addTab(gBrowser); + + is(gBrowser.visibleTabs.length, 2, "should have 2 tabs before hiding"); + gBrowser.showOnlyTheseTabs([origTab]); + is(gBrowser.visibleTabs.length, 1, "only 1 after hiding"); + ok(hiddenTab.hidden, "sanity check that it's hidden"); + + BrowserTestUtils.addTab(gBrowser); + let state = ss.getBrowserState(); + let stateObj = JSON.parse(state); + let tabs = stateObj.windows[0].tabs; + is(tabs.length, 3, "just checking that browser state is correct"); + ok(!tabs[0].hidden, "first tab is visible"); + ok(tabs[1].hidden, "second is hidden"); + ok(!tabs[2].hidden, "third is visible"); + + // Make the third tab hidden and then restore the modified state object + tabs[2].hidden = true; + + observeOneRestore(function () { + is(gBrowser.visibleTabs.length, 1, "only restored 1 visible tab"); + let restoredTabs = gBrowser.tabs; + + ok(!restoredTabs[0].hidden, "first is still visible"); + ok(restoredTabs[1].hidden, "second tab is still hidden"); + ok(restoredTabs[2].hidden, "third tab is now hidden"); + + // Restore the original state and clean up now that we're done + gBrowser.removeTab(gBrowser.tabs[1]); + gBrowser.removeTab(gBrowser.tabs[1]); + + finish(); + }); + ss.setBrowserState(JSON.stringify(stateObj)); +} |