tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 4b2c560c91239356425452245e6a61604cb0863a
parent 21a17d3c04ec26281a0244a378b8006d7b3401a9
Author: Jonathan Sudiaman <jsudiaman@mozilla.com>
Date:   Thu, 16 Oct 2025 14:42:07 +0000

Bug 1990329 - Add test coverage for adding inactive (restored) tabs into a new split view. r=sessionstore-reviewers,sclements,sfoster

Differential Revision: https://phabricator.services.mozilla.com/D268386

Diffstat:
Mbrowser/components/sessionstore/test/marionette/manifest.toml | 2++
Abrowser/components/sessionstore/test/marionette/test_restore_split_view.py | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+), 0 deletions(-)

diff --git a/browser/components/sessionstore/test/marionette/manifest.toml b/browser/components/sessionstore/test/marionette/manifest.toml @@ -18,6 +18,8 @@ skip-if = ["os == 'linux' && os_version == '24.04' && processor == 'x86_64' && d ["test_restore_sidebar_automatic.py"] +["test_restore_split_view.py"] + ["test_restore_windows_after_close_last_tabs.py"] skip-if = ["os == 'mac'"] diff --git a/browser/components/sessionstore/test/marionette/test_restore_split_view.py b/browser/components/sessionstore/test/marionette/test_restore_split_view.py @@ -0,0 +1,97 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 0.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/0.0/. + +import os +import sys + +# add this directory to the path +sys.path.append(os.path.dirname(__file__)) + +from session_store_test_case import SessionStoreTestCase + + +def inline(title): + return f"data:text/html;charset=utf-8,<html><head><title>{title}</title></head><body></body></html>" + + +class TestSessionRestoreSplitView(SessionStoreTestCase): + """ + Test the interactions between Session Restore and Split View. + """ + + def setUp(self): + super().setUp( + startup_page=1, + include_private=False, + restore_on_demand=True, + test_windows=set( + [ + ( + inline("Tab 1"), + inline("Tab 2"), + inline("Tab 3"), + ), + ] + ), + ) + + def test_add_inactive_tabs_to_split_view(self): + """ + When we restart with some tabs, we defer loading and setting up those + tabs until they become active. + + Ensure that adding these tabs to a split view triggers that. + """ + self.assertEqual( + len(self.marionette.chrome_window_handles), + 1, + msg="Should have 1 window open.", + ) + + # There are currently three tabs open. + # Switch to the first one, and then restart. + self.marionette.execute_script("gBrowser.selectTabAtIndex(0)") + self.marionette.restart() + self.marionette.set_context("chrome") + + # After restart: + # Tab 1 is active. + # Tab 2 & Tab 3 are inactive, and haven't been activated yet. + self.assertEqual( + self.marionette.execute_script("return gBrowser.tabs.length"), + 3, + msg="Should have 3 tabs open.", + ) + self.assertEqual( + self.marionette.execute_script( + "return gBrowser.tabContainer.selectedIndex" + ), + 0, + msg="First tab should be selected.", + ) + + # Create a split view with the inactive tabs (Tab 2 & Tab 3). + # Select Tab 2 to activate the split view. + # Wait for both tabs in the split view to finish restoring. + self.marionette.execute_async_script( + """ + let [resolve] = arguments; + gBrowser.addTabSplitView([gBrowser.tabs[1], gBrowser.tabs[2]]); + let promiseTabsRestored = new Promise(resolve => { + let tabsRemaining = 2; + function handleTabRestored() { + if (!--tabsRemaining) { + gBrowser.tabContainer.removeEventListener( + "SSTabRestored", + handleTabRestored + ); + resolve(); + } + } + gBrowser.tabContainer.addEventListener("SSTabRestored", handleTabRestored); + }); + gBrowser.selectTabAtIndex(1); + promiseTabsRestored.then(resolve); + """ + )