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 /devtools/client/inspector/flexbox/test/head.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/inspector/flexbox/test/head.js')
-rw-r--r-- | devtools/client/inspector/flexbox/test/head.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/devtools/client/inspector/flexbox/test/head.js b/devtools/client/inspector/flexbox/test/head.js new file mode 100644 index 0000000000..269dcea904 --- /dev/null +++ b/devtools/client/inspector/flexbox/test/head.js @@ -0,0 +1,81 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint no-unused-vars: [2, {"vars": "local"}] */ + +"use strict"; + +// Import the inspector's head.js first (which itself imports shared-head.js). +Services.scriptloader.loadSubScript( + "chrome://mochitests/content/browser/devtools/client/inspector/test/head.js", + this +); + +const FLEXBOX_OPENED_PREF = "devtools.layout.flexbox.opened"; +const FLEX_CONTAINER_OPENED_PREF = "devtools.layout.flex-container.opened"; +const FLEX_ITEM_OPENED_PREF = "devtools.layout.flex-item.opened"; +const GRID_OPENED_PREF = "devtools.layout.grid.opened"; +const BOXMODEL_OPENED_PREF = "devtools.layout.boxmodel.opened"; + +// Make sure only the flexbox layout accordions are opened, and the others are closed. +Services.prefs.setBoolPref(FLEXBOX_OPENED_PREF, true); +Services.prefs.setBoolPref(FLEX_CONTAINER_OPENED_PREF, true); +Services.prefs.setBoolPref(FLEX_ITEM_OPENED_PREF, true); +Services.prefs.setBoolPref(BOXMODEL_OPENED_PREF, false); +Services.prefs.setBoolPref(GRID_OPENED_PREF, false); + +// Clear all set prefs. +registerCleanupFunction(() => { + Services.prefs.clearUserPref(FLEXBOX_OPENED_PREF); + Services.prefs.clearUserPref(FLEX_CONTAINER_OPENED_PREF); + Services.prefs.clearUserPref(FLEX_ITEM_OPENED_PREF); + Services.prefs.clearUserPref(BOXMODEL_OPENED_PREF); + Services.prefs.clearUserPref(GRID_OPENED_PREF); +}); + +/** + * Toggles ON the flexbox highlighter given the flexbox highlighter button from the + * layout panel. + * + * @param {DOMNode} button + * The flexbox highlighter toggle button in the flex container panel. + * @param {Inspector} inspector + * Inspector panel instance. + */ +async function toggleHighlighterON(button, inspector) { + info("Toggling ON the flexbox highlighter from the layout panel."); + const { waitForHighlighterTypeShown } = getHighlighterTestHelpers(inspector); + const onHighlighterShown = waitForHighlighterTypeShown( + inspector.highlighters.TYPES.FLEXBOX + ); + const { store } = inspector; + const onToggleChange = waitUntilState( + store, + state => state.flexbox.highlighted + ); + button.click(); + await Promise.all([onHighlighterShown, onToggleChange]); +} + +/** + * Toggles OFF the flexbox highlighter given the flexbox highlighter button from the + * layout panel. + * + * @param {DOMNode} button + * The flexbox highlighter toggle button in the flex container panel. + * @param {Inspector} inspector + * Inspector panel instance. + */ +async function toggleHighlighterOFF(button, inspector) { + info("Toggling OFF the flexbox highlighter from the layout panel."); + const { waitForHighlighterTypeHidden } = getHighlighterTestHelpers(inspector); + const onHighlighterHidden = waitForHighlighterTypeHidden( + inspector.highlighters.TYPES.FLEXBOX + ); + const { store } = inspector; + const onToggleChange = waitUntilState( + store, + state => !state.flexbox.highlighted + ); + button.click(); + await Promise.all([onHighlighterHidden, onToggleChange]); +} |