Backed out changeset 9838e2ffe509 (bug 1961190) for causing xpcshell failures @test_sidebar_state.js. CLOSED TREE
This commit is contained in:
@@ -170,31 +170,6 @@ export const SidebarManager = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Has the new sidebar launcher already been visible and "used" in this profile?
|
||||
*/
|
||||
get hasSidebarLauncherBeenVisible() {
|
||||
// Its possible sidebar.revamp was enabled previously, but we can effectively reset if its currently false
|
||||
if (!lazy.sidebarRevampEnabled) {
|
||||
return false;
|
||||
}
|
||||
if (lazy.verticalTabsEnabled) {
|
||||
return true;
|
||||
}
|
||||
// this pref tells us a sidebar panel has been opened, so it implies the launcher has
|
||||
// been visible, but can't reliably indicate that the launcher has *not* been visible.
|
||||
if (Services.prefs.getBoolPref("sidebar.new-sidebar.has-used", false)) {
|
||||
return true;
|
||||
}
|
||||
// check if the launcher has ever been visible (in this session) in any of our open windows,
|
||||
for (let w of lazy.BrowserWindowTracker.getOrderedWindows()) {
|
||||
if (w.SidebarController.launcherEverVisible) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Prepopulates default tools for new sidebar users and appends any new tools defined
|
||||
* on the sidebar.newTool.migration pref branch to the sidebar.main.tools pref.
|
||||
|
||||
@@ -44,6 +44,7 @@ const SIDEBAR_MAXIMUM_WIDTH = "75vw";
|
||||
|
||||
const LEGACY_USED_PREF = "sidebar.old-sidebar.has-used";
|
||||
const REVAMP_USED_PREF = "sidebar.new-sidebar.has-used";
|
||||
const DEFAULT_LAUNCHER_VISIBLE_PREF = "sidebar.revamp.defaultLauncherVisible";
|
||||
|
||||
/**
|
||||
* A reactive data store for the sidebar's UI state. Similar to Lit's
|
||||
@@ -56,7 +57,6 @@ export class SidebarState {
|
||||
#props = {
|
||||
...SidebarState.defaultProperties,
|
||||
};
|
||||
#launcherEverVisible = false;
|
||||
|
||||
/** @type {SidebarStateProps} */
|
||||
static defaultProperties = Object.freeze({
|
||||
@@ -158,19 +158,9 @@ export class SidebarState {
|
||||
*/
|
||||
loadInitialState(props) {
|
||||
// Override any initial launcher visible state when the pref is defined
|
||||
// and the new sidebar has not been made visible yet
|
||||
if (props.hasOwnProperty("hidden")) {
|
||||
props.launcherVisible = !props.hidden;
|
||||
delete props.hidden;
|
||||
}
|
||||
|
||||
const hasSidebarLauncherBeenVisible =
|
||||
this.#controller.SidebarManager.hasSidebarLauncherBeenVisible;
|
||||
|
||||
// We override a falsey launcherVisible property with the default value if
|
||||
// its not been visible before.
|
||||
if (!props.launcherVisible && !hasSidebarLauncherBeenVisible) {
|
||||
if (Services.prefs.prefHasUserValue(DEFAULT_LAUNCHER_VISIBLE_PREF)) {
|
||||
props.launcherVisible = this.defaultLauncherVisible;
|
||||
delete props.hidden;
|
||||
}
|
||||
for (const [key, value] of Object.entries(props)) {
|
||||
if (value === undefined) {
|
||||
@@ -190,6 +180,9 @@ export class SidebarState {
|
||||
case "expanded":
|
||||
this.launcherExpanded = value;
|
||||
break;
|
||||
case "hidden":
|
||||
this.launcherVisible = !value;
|
||||
break;
|
||||
case "panelOpen":
|
||||
// we need to know if we have a command value before finalizing panelOpen
|
||||
break;
|
||||
@@ -299,10 +292,6 @@ export class SidebarState {
|
||||
return this.#props.launcherVisible;
|
||||
}
|
||||
|
||||
get launcherEverVisible() {
|
||||
return this.#launcherEverVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the launcher `visible` and `expanded` states
|
||||
*
|
||||
@@ -339,9 +328,6 @@ export class SidebarState {
|
||||
return;
|
||||
}
|
||||
this.#props.launcherVisible = visible;
|
||||
if (visible) {
|
||||
this.#launcherEverVisible = true;
|
||||
}
|
||||
this.#launcherContainerEl.hidden = !visible;
|
||||
this.#updateTabbrowser(visible);
|
||||
this.#sidebarBoxEl.style.paddingInlineStart =
|
||||
|
||||
@@ -968,10 +968,6 @@ var SidebarController = {
|
||||
return this._state?.launcherVisible;
|
||||
},
|
||||
|
||||
get launcherEverVisible() {
|
||||
return this._state?.launcherEverVisible;
|
||||
},
|
||||
|
||||
get title() {
|
||||
return this._title.value;
|
||||
},
|
||||
|
||||
@@ -7,16 +7,12 @@ from marionette_harness import MarionetteTestCase
|
||||
|
||||
default_visible_pref = "sidebar.revamp.defaultLauncherVisible"
|
||||
|
||||
initial_prefs = {
|
||||
"sidebar.revamp": False,
|
||||
default_visible_pref: False,
|
||||
# Set browser restore previous session pref
|
||||
# we'll need to examine behavior using restored sidebar properties
|
||||
"browser.startup.page": 3,
|
||||
}
|
||||
|
||||
|
||||
class TestDefaultLauncherVisible(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.marionette.set_pref("sidebar.revamp", True)
|
||||
self.marionette.set_context("chrome")
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
@@ -25,21 +21,17 @@ class TestDefaultLauncherVisible(MarionetteTestCase):
|
||||
finally:
|
||||
super().tearDown()
|
||||
|
||||
def _close_last_tab(self):
|
||||
# "self.marionette.close" cannot be used because it doesn't
|
||||
# allow closing the very last tab.
|
||||
self.marionette.execute_script("window.close()")
|
||||
|
||||
def restart_with_prefs(self, prefs):
|
||||
# set the prefs then restart the browser
|
||||
self.marionette.set_prefs(prefs)
|
||||
self.marionette.restart()
|
||||
|
||||
# Restore the context as used before the restart
|
||||
# We need to quit the browser and restart with the prefs already set
|
||||
# in order to examine the startup behavior
|
||||
for name, value in prefs.items():
|
||||
if value is None:
|
||||
self.marionette.clear_pref(name)
|
||||
else:
|
||||
self.marionette.set_pref(name, value)
|
||||
self.marionette.restart(clean=False, in_app=True)
|
||||
self.marionette.set_context("chrome")
|
||||
|
||||
self.wait_for_startup_idle_promise()
|
||||
|
||||
def is_launcher_visible(self):
|
||||
hidden = self.marionette.execute_script(
|
||||
"""
|
||||
@@ -49,154 +41,62 @@ class TestDefaultLauncherVisible(MarionetteTestCase):
|
||||
)
|
||||
return not hidden
|
||||
|
||||
def is_button_visible(self):
|
||||
visible = self.marionette.execute_script(
|
||||
def is_launcher_hidden(self):
|
||||
hidden = self.marionette.execute_script(
|
||||
"""
|
||||
const window = BrowserWindowTracker.getTopWindow();
|
||||
const placement = window.CustomizableUI.getPlacementOfWidget('sidebar-button');
|
||||
if (!placement) {
|
||||
return false;
|
||||
}
|
||||
const node = window.document.getElementById("sidebar-button");
|
||||
return node && !node.hidden;
|
||||
return window.SidebarController.sidebarContainer.hidden;
|
||||
"""
|
||||
)
|
||||
return visible
|
||||
return hidden
|
||||
|
||||
def click_toolbar_button(self):
|
||||
# Click the button to show the launcher
|
||||
def test_default_visible_pref(self):
|
||||
# By default when sidebar.revamp is enabled, the launcher should be initially visible
|
||||
Wait(self.marionette).until(
|
||||
lambda _: self.is_launcher_visible(),
|
||||
message="Sidebar launcher should be initially visible",
|
||||
)
|
||||
|
||||
# Flip the default and make the launcher initially hidden
|
||||
self.restart_with_prefs(
|
||||
{
|
||||
default_visible_pref: False,
|
||||
"sidebar.backupState": None,
|
||||
}
|
||||
)
|
||||
|
||||
Wait(self.marionette).until(
|
||||
lambda _: self.is_launcher_hidden(),
|
||||
message="Launcher should be hidden after restart",
|
||||
)
|
||||
|
||||
# Ensure user actions override the default - click the toolbar button to show the launcher
|
||||
self.marionette.execute_script(
|
||||
"""
|
||||
const window = BrowserWindowTracker.getTopWindow();
|
||||
return window.document.getElementById("sidebar-button").click()
|
||||
"""
|
||||
)
|
||||
|
||||
def wait_for_startup_idle_promise(self):
|
||||
self.marionette.set_context("chrome")
|
||||
self.marionette.execute_async_script(
|
||||
"""
|
||||
let resolve = arguments[0];
|
||||
let { BrowserInitState } = ChromeUtils.importESModule("resource:///modules/BrowserGlue.sys.mjs");
|
||||
BrowserInitState.startupIdleTaskPromise.then(resolve);
|
||||
"""
|
||||
)
|
||||
|
||||
def test_first_use_default_visible_pref_false(self):
|
||||
# We flip sidebar.revamp to true, with defaultLauncherVisible=false for a profile
|
||||
# that has never enabled or seen the sidebar launcher.
|
||||
|
||||
self.wait_for_startup_idle_promise()
|
||||
|
||||
self.assertFalse(
|
||||
self.is_launcher_visible(),
|
||||
"Sidebar launcher is hidden",
|
||||
)
|
||||
self.assertFalse(
|
||||
self.is_button_visible(),
|
||||
"Sidebar toolbar button is hidden",
|
||||
)
|
||||
|
||||
# Mimic an update which enables sidebar.revamp for the first time
|
||||
# ,with defaultLauncherVisible false
|
||||
self.restart_with_prefs(
|
||||
{
|
||||
"sidebar.revamp": True,
|
||||
"browser.startup.page": 3,
|
||||
default_visible_pref: False,
|
||||
}
|
||||
)
|
||||
|
||||
Wait(self.marionette).until(
|
||||
lambda _: self.is_button_visible(),
|
||||
message="Sidebar button should be visible",
|
||||
)
|
||||
self.assertFalse(
|
||||
self.is_launcher_visible(),
|
||||
"Sidebar launcher remains hidden because defaultLauncherVisible=false",
|
||||
)
|
||||
# Click the button and verify that sticks
|
||||
self.click_toolbar_button()
|
||||
|
||||
Wait(self.marionette).until(
|
||||
lambda _: self.is_launcher_visible(),
|
||||
message="Sidebar button should be visible",
|
||||
)
|
||||
self.marionette.restart()
|
||||
self.marionette.set_context("chrome")
|
||||
self.wait_for_startup_idle_promise()
|
||||
|
||||
self.assertTrue(
|
||||
self.is_launcher_visible(),
|
||||
"Sidebar launcher remains visible because user un-hid it in the resumed session",
|
||||
"Sidebar launcher is visible again",
|
||||
)
|
||||
|
||||
def test_new_sidebar_enabled_default_visible_pref_false(self):
|
||||
# Set up the profile with session restore and new sidebar enabled
|
||||
self.restart_with_prefs(
|
||||
{
|
||||
"sidebar.revamp": True,
|
||||
"browser.startup.page": 3,
|
||||
default_visible_pref: False,
|
||||
}
|
||||
)
|
||||
|
||||
self.marionette.restart(clean=False, in_app=True)
|
||||
# Check the default pref is overriden and the launcher remains visible
|
||||
self.assertFalse(
|
||||
self.is_launcher_visible(),
|
||||
"Sidebar launcher is hidden",
|
||||
)
|
||||
self.assertTrue(
|
||||
self.is_button_visible(),
|
||||
"Sidebar toolbar button is visible",
|
||||
)
|
||||
|
||||
# Mimic an update which enables sidebar.revamp with defaultLauncherVisible true
|
||||
# The restart with session restore enabled while the launcher is visible should persist
|
||||
# the launcherVisible=true and we don't want to override that
|
||||
self.restart_with_prefs(
|
||||
{
|
||||
"sidebar.revamp": True,
|
||||
"browser.startup.page": 3,
|
||||
default_visible_pref: True,
|
||||
}
|
||||
)
|
||||
|
||||
Wait(self.marionette).until(
|
||||
lambda _: self.is_button_visible(),
|
||||
message="Sidebar button is still visible",
|
||||
)
|
||||
|
||||
self.assertTrue(
|
||||
self.is_launcher_visible(),
|
||||
"Sidebar launcher is still visible",
|
||||
)
|
||||
|
||||
# Click the button and verify that sticks
|
||||
self.click_toolbar_button()
|
||||
|
||||
Wait(self.marionette).until(
|
||||
lambda _: not self.is_launcher_visible(),
|
||||
message="Sidebar launcher should be hidden",
|
||||
)
|
||||
self.marionette.restart()
|
||||
self.marionette.set_context("chrome")
|
||||
self.wait_for_startup_idle_promise()
|
||||
|
||||
self.assertFalse(
|
||||
self.is_launcher_visible(),
|
||||
"Sidebar launcher remains hidden on restart",
|
||||
"Sidebar launcher is still visible after restart",
|
||||
)
|
||||
|
||||
def test_vertical_tabs_default_hidden(self):
|
||||
# Verify that starting with verticalTabs enabled and default visibility false results in a visible
|
||||
# launcher with the vertical tabstrip
|
||||
self.restart_with_prefs(
|
||||
{
|
||||
"sidebar.revamp": True,
|
||||
"sidebar.verticalTabs": True,
|
||||
default_visible_pref: False,
|
||||
}
|
||||
)
|
||||
self.marionette.quit()
|
||||
self.marionette.start_session()
|
||||
self.marionette.set_pref("sidebar.revamp", True)
|
||||
self.marionette.set_pref("sidebar.verticalTabs", True)
|
||||
self.marionette.set_pref(default_visible_pref, False)
|
||||
self.marionette.set_context("chrome")
|
||||
|
||||
Wait(self.marionette).until(
|
||||
lambda _: self.is_launcher_visible(),
|
||||
@@ -213,6 +113,6 @@ class TestDefaultLauncherVisible(MarionetteTestCase):
|
||||
# switch to 'hide-sidebar' visibility mode and confirm the launcher becomes hidden
|
||||
self.marionette.set_pref("sidebar.visibility", "hide-sidebar")
|
||||
Wait(self.marionette).until(
|
||||
lambda _: not self.is_launcher_visible(),
|
||||
lambda _: self.is_launcher_hidden(),
|
||||
message="Sidebar launcher should become hidden when hide-sidebar visibility is set and defaultLauncherVisible is false",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user