Bug 1930220 - Assert nothing changes in the toolbar upon browser restarts r=mconley,webdriver-reviewers,whimboo
To help catch bugs such as Bug 1919721, assert the toolbar is unchanged and widgets are in the correct order on browser restart. Differential Revision: https://phabricator.services.mozilla.com/D233749
This commit is contained in:
@@ -5010,6 +5010,17 @@ export var CustomizableUI = {
|
|||||||
// We need to clone this, as we don't want to let consumers muck with placements
|
// We need to clone this, as we don't want to let consumers muck with placements
|
||||||
return [...gPlacements.get(aArea)];
|
return [...gPlacements.get(aArea)];
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Get an array of all the widget IDs in the default placements for an area.
|
||||||
|
* Modifying the array will not affect CustomizableUI.
|
||||||
|
*
|
||||||
|
* @param aArea the ID of the area whose default placements you want to obtain.
|
||||||
|
* @return an array containing the widget IDs that are in the default placements for that area.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
getDefaultPlacementsForArea(aArea) {
|
||||||
|
return [...gAreas.get(aArea).get("defaultPlacements")];
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Get an array of widget wrappers for all the widgets in an area. This is
|
* Get an array of widget wrappers for all the widgets in an area. This is
|
||||||
* the same as calling getWidgetIdsInArea and .map() ing the result through
|
* the same as calling getWidgetIdsInArea and .map() ing the result through
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ DIRS += [
|
|||||||
"content",
|
"content",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
MARIONETTE_MANIFESTS += ["test/marionette/manifest.toml"]
|
||||||
BROWSER_CHROME_MANIFESTS += ["test/browser.toml", "test/browserSidebarRevamp.toml"]
|
BROWSER_CHROME_MANIFESTS += ["test/browser.toml", "test/browserSidebarRevamp.toml"]
|
||||||
XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.toml"]
|
XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.toml"]
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[DEFAULT]
|
||||||
|
tags = "local"
|
||||||
|
|
||||||
|
["test_assert_no_toolbar_changes.py"]
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# 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/.
|
||||||
|
|
||||||
|
from marionette_harness import MarionetteTestCase
|
||||||
|
|
||||||
|
|
||||||
|
class TestNoToolbarChanges(MarionetteTestCase):
|
||||||
|
"""
|
||||||
|
Test that toolbar widgets remain in the same order over several restarts of the browser
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
self.marionette.set_context("chrome")
|
||||||
|
|
||||||
|
def get_area_widgets(self, area):
|
||||||
|
return self.marionette.execute_script(
|
||||||
|
f"return CustomizableUI.getWidgetIdsInArea(CustomizableUI.{area}).map(id => id.includes('spring') ? 'spring' : id)"
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_area_default_placements(self, area):
|
||||||
|
return self.marionette.execute_script(
|
||||||
|
f"return CustomizableUI.getDefaultPlacementsForArea(CustomizableUI.{area})"
|
||||||
|
)
|
||||||
|
|
||||||
|
def check_toolbar_placements(self):
|
||||||
|
self.assertEqual(
|
||||||
|
self.get_area_widgets("AREA_TABSTRIP"),
|
||||||
|
self.get_area_default_placements("AREA_TABSTRIP"),
|
||||||
|
msg="AREA_TABSTRIP placements are as expected",
|
||||||
|
)
|
||||||
|
navbarPlacements = self.get_area_default_placements("AREA_NAVBAR")
|
||||||
|
navbarPlacements.append("unified-extensions-button")
|
||||||
|
self.assertEqual(
|
||||||
|
self.get_area_widgets("AREA_NAVBAR"),
|
||||||
|
navbarPlacements,
|
||||||
|
msg="AREA_NAVBAR placements are as expected",
|
||||||
|
)
|
||||||
|
bookmarkPlacements = self.get_area_default_placements("AREA_BOOKMARKS")
|
||||||
|
bookmarkPlacements.insert(0, "import-button")
|
||||||
|
self.assertEqual(
|
||||||
|
self.get_area_widgets("AREA_BOOKMARKS"),
|
||||||
|
bookmarkPlacements,
|
||||||
|
msg="AREA_BOOKMARKS placements are as expected",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
self.get_area_widgets("AREA_ADDONS"),
|
||||||
|
self.get_area_default_placements("AREA_ADDONS"),
|
||||||
|
msg="AREA_ADDONS placements are as expected",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
self.get_area_widgets("AREA_FIXED_OVERFLOW_PANEL"),
|
||||||
|
self.get_area_default_placements("AREA_FIXED_OVERFLOW_PANEL"),
|
||||||
|
msg="AREA_FIXED_OVERFLOW_PANEL placements are as expected",
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_no_toolbar_changes(self):
|
||||||
|
self.check_toolbar_placements()
|
||||||
|
self.marionette.restart()
|
||||||
|
self.check_toolbar_placements()
|
||||||
|
self.marionette.restart()
|
||||||
|
self.check_toolbar_placements()
|
||||||
|
self.marionette.restart()
|
||||||
|
self.check_toolbar_placements()
|
||||||
|
self.marionette.restart()
|
||||||
|
self.check_toolbar_placements()
|
||||||
|
self.marionette.restart()
|
||||||
|
self.check_toolbar_placements()
|
||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
["include:../../../../../browser/components/backup/tests/marionette/manifest.toml"]
|
["include:../../../../../browser/components/backup/tests/marionette/manifest.toml"]
|
||||||
|
|
||||||
|
["include:../../../../../browser/components/customizableui/test/marionette/manifest.toml"]
|
||||||
|
|
||||||
["include:../../../../../browser/components/migration/tests/marionette/manifest.toml"]
|
["include:../../../../../browser/components/migration/tests/marionette/manifest.toml"]
|
||||||
|
|
||||||
["include:../../../../../browser/components/places/tests/marionette/manifest.toml"]
|
["include:../../../../../browser/components/places/tests/marionette/manifest.toml"]
|
||||||
|
|||||||
Reference in New Issue
Block a user