Bug 1804064 - Firefox View window should not be saved r=Gijs,kcochrane

* If Firefox view tab is the last selected tab when a window is closed it
should not be saved; the first tab should be used instead. This patch updates a test,
updates the title that is saved and the selected index

Differential Revision: https://phabricator.services.mozilla.com/D166362
This commit is contained in:
Sarah Clements
2023-01-11 11:59:19 +00:00
parent d873912229
commit 8f954f3b82
3 changed files with 28 additions and 24 deletions

View File

@@ -8,28 +8,32 @@ const CLOSED_URI = "https://www.example.com/";
add_task(async function test_TODO() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, CLOSED_URI);
Assert.equal(gBrowser.tabs[0].linkedBrowser.currentURI.filePath, "blank");
Assert.equal(gBrowser.tabs[1].linkedBrowser.currentURI.spec, CLOSED_URI);
Assert.ok(gBrowser.selectedTab == tab);
let state = ss.getCurrentState(true);
is(state.windows[0].selected, 2, "The selected tab is the second tab");
// SessionStore uses one-based indexes
Assert.equal(state.windows[0].selected, 2);
window.FirefoxViewHandler.openTab();
state = ss.getCurrentState(true);
is(
state.windows[0].selected,
3,
"The selected tab is Firefox view tab which is the third tab"
await EventUtils.synthesizeMouseAtCenter(
window.document.getElementById("firefox-view-button"),
{ type: "mousedown" },
window
);
Assert.ok(window.FirefoxViewHandler.tab.selected);
gBrowser.selectedTab = tab;
Assert.equal(gBrowser.tabs[2], window.FirefoxViewHandler.tab);
state = ss.getCurrentState(true);
// The FxView tab doesn't get recorded in the session state and when we restore we want
// to open the tab that was previously opened so we record the tab position minus one
is(state.windows[0].selected, 1, "The selected tab is the first tab");
// The FxView tab doesn't get recorded in the session state, but if it's the last selected tab when a window is closed
// we want to point to the first tab in the tab strip upon restore
Assert.equal(state.windows[0].selected, 1);
gBrowser.removeTab(window.FirefoxViewHandler.tab);
gBrowser.removeTab(gBrowser.selectedTab);
gBrowser.removeTab(tab);
});