diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/client/inspector/compatibility/test/browser/browser_compatibility_settings.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/client/inspector/compatibility/test/browser/browser_compatibility_settings.js | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/devtools/client/inspector/compatibility/test/browser/browser_compatibility_settings.js b/devtools/client/inspector/compatibility/test/browser/browser_compatibility_settings.js new file mode 100644 index 0000000000..36e4d57735 --- /dev/null +++ b/devtools/client/inspector/compatibility/test/browser/browser_compatibility_settings.js @@ -0,0 +1,113 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test whether settings page works. + +const TEST_URI = ` + <style> + body { + text-size-adjust: none; + } + div { + text-size-adjust: none; + } + </style> + <body><div></div></body> +`; + +const { + COMPATIBILITY_UPDATE_TARGET_BROWSERS_COMPLETE, +} = require("resource://devtools/client/inspector/compatibility/actions/index.js"); + +add_task(async function () { + registerCleanupFunction(() => { + Services.prefs.clearUserPref( + "devtools.inspector.compatibility.target-browsers" + ); + }); + + await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + const { inspector, panel } = await openCompatibilityView(); + const { store } = inspector; + + info("Check initial state"); + ok( + panel.querySelector(`.compatibility-browser-icon__image[src*="firefox"]`), + "Firefox browsers are the target" + ); + + info("Make Firefox browsers out of target"); + await updateTargetBrowsers(panel, store, id => !id.includes("firefox")); + ok( + !panel.querySelector(`.compatibility-browser-icon__image[src*="firefox"]`), + "Firefox browsers are not the target" + ); + + info("Make all browsers out of target"); + await updateTargetBrowsers(panel, store, () => false); + ok( + !panel.querySelector(".compatibility-browser-icon__image"), + "No browsers are the target" + ); + + info("Make Firefox browsers target"); + await updateTargetBrowsers(panel, store, id => id.includes("firefox")); + ok( + panel.querySelector(`.compatibility-browser-icon__image[src*="firefox"]`), + "Firefox browsers are the target now" + ); +}); + +async function updateTargetBrowsers(panel, store, isTargetBrowserFunc) { + info("Open settings pane"); + const settingsButton = panel.querySelector(".compatibility-footer__button"); + settingsButton.click(); + await waitUntil(() => panel.querySelector(".compatibility-settings")); + + const browsers = [ + ...new Set( + Array.from(panel.querySelectorAll("[data-id]")).map(el => + el.getAttribute("data-id") + ) + ), + ]; + Assert.deepEqual( + // Filter out IE, to be removed in an upcoming browser compat data sync. + // TODO: Remove the filter once D150961 lands. see Bug 1778009 + browsers.filter(browser => browser != "ie"), + [ + "chrome", + "chrome_android", + "edge", + "firefox", + "firefox_android", + "safari", + "safari_ios", + ], + "The expected browsers are displayed" + ); + + info("Change target browsers"); + const settingsPane = panel.querySelector(".compatibility-settings"); + for (const checkbox of settingsPane.querySelectorAll( + ".compatibility-settings__target-browsers-item input" + )) { + if (checkbox.checked !== isTargetBrowserFunc(checkbox.id)) { + // Need to click to toggle since the input is designed as controlled component. + checkbox.click(); + } + } + + info("Close settings pane"); + const onUpdated = waitForDispatch( + store, + COMPATIBILITY_UPDATE_TARGET_BROWSERS_COMPLETE + ); + const closeButton = settingsPane.querySelector( + ".compatibility-settings__header-button" + ); + closeButton.click(); + await onUpdated; +} |