From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../client/shared/test/browser_theme_switching.js | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 devtools/client/shared/test/browser_theme_switching.js (limited to 'devtools/client/shared/test/browser_theme_switching.js') diff --git a/devtools/client/shared/test/browser_theme_switching.js b/devtools/client/shared/test/browser_theme_switching.js new file mode 100644 index 0000000000..642938e9af --- /dev/null +++ b/devtools/client/shared/test/browser_theme_switching.js @@ -0,0 +1,58 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task(async function () { + await pushPref("devtools.theme", "light"); + + // For some reason, mochitest spawn a very special default tab, + // whose WindowGlobal is still the initial about:blank document. + // This seems to be specific to mochitest, this doesn't reproduce + // in regular firefox run. Even having about:blank as home page, + // force loading another final about:blank document (which isn't the initial one) + // + // To workaround this, force opening a dedicated test tab + const tab = await addTab("data:text/html;charset=utf-8,Test page"); + + const toolbox = await gDevTools.showToolboxForTab(tab); + const doc = toolbox.doc; + const root = doc.documentElement; + + const platform = root.getAttribute("platform"); + const expectedPlatform = getPlatform(); + is(platform, expectedPlatform, ":root[platform] is correct"); + + const theme = Services.prefs.getCharPref("devtools.theme"); + const className = "theme-" + theme; + ok( + root.classList.contains(className), + ":root has " + className + " class (current theme)" + ); + + const sheetsInDOM = Array.from( + doc.querySelectorAll("link[rel='stylesheet']"), + l => l.href + ); + + const sheetsFromTheme = gDevTools.getThemeDefinition(theme).stylesheets; + info("Checking for existence of " + sheetsInDOM.length + " sheets"); + for (const themeSheet of sheetsFromTheme) { + ok( + sheetsInDOM.some(s => s.includes(themeSheet)), + "There is a stylesheet for " + themeSheet + ); + } + + await toolbox.destroy(); +}); + +function getPlatform() { + const { OS } = Services.appinfo; + if (OS == "WINNT") { + return "win"; + } else if (OS == "Darwin") { + return "mac"; + } + return "linux"; +} -- cgit v1.2.3