summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/contentTheme
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /browser/base/content/test/contentTheme
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/contentTheme')
-rw-r--r--browser/base/content/test/contentTheme/browser.ini3
-rw-r--r--browser/base/content/test/contentTheme/browser_contentTheme_in_process_tab.js87
2 files changed, 90 insertions, 0 deletions
diff --git a/browser/base/content/test/contentTheme/browser.ini b/browser/base/content/test/contentTheme/browser.ini
new file mode 100644
index 0000000000..a7c859a1b3
--- /dev/null
+++ b/browser/base/content/test/contentTheme/browser.ini
@@ -0,0 +1,3 @@
+[DEFAULT]
+
+[browser_contentTheme_in_process_tab.js]
diff --git a/browser/base/content/test/contentTheme/browser_contentTheme_in_process_tab.js b/browser/base/content/test/contentTheme/browser_contentTheme_in_process_tab.js
new file mode 100644
index 0000000000..4b150e57ce
--- /dev/null
+++ b/browser/base/content/test/contentTheme/browser_contentTheme_in_process_tab.js
@@ -0,0 +1,87 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Tests that tabs running in the parent process can hear about updates
+ * to lightweight themes via contentTheme.js.
+ *
+ * The test loads the History Sidebar document in a tab to avoid having
+ * to create a special parent-process page for the LightweightTheme
+ * JSWindow actors.
+ */
+add_task(async function test_in_process_tab() {
+ let win = await BrowserTestUtils.openNewBrowserWindow();
+ const IN_PROCESS_URI = "chrome://browser/content/places/historySidebar.xhtml";
+ const SIDEBAR_BGCOLOR = "rgb(255, 0, 0)";
+ // contentTheme.js will always convert the sidebar text color to rgba, so
+ // we need to compare against that.
+ const SIDEBAR_TEXT_COLOR = "rgba(0, 255, 0, 1)";
+
+ await BrowserTestUtils.withNewTab(
+ {
+ gBrowser: win.gBrowser,
+ url: IN_PROCESS_URI,
+ },
+ async browser => {
+ await SpecialPowers.spawn(
+ browser,
+ [SIDEBAR_BGCOLOR, SIDEBAR_TEXT_COLOR],
+ async (bgColor, textColor) => {
+ let style = content.document.documentElement.style;
+ Assert.notEqual(
+ style.getPropertyValue("--lwt-sidebar-background-color"),
+ bgColor
+ );
+ Assert.notEqual(
+ style.getPropertyValue("--lwt-sidebar-text-color"),
+ textColor
+ );
+ }
+ );
+
+ // Now cobble together a very simple theme that sets the sidebar background
+ // and text color.
+ let lwtData = {
+ theme: {
+ sidebar: SIDEBAR_BGCOLOR,
+ sidebar_text: SIDEBAR_TEXT_COLOR,
+ },
+ darkTheme: null,
+ window: win.docShell.outerWindowID,
+ };
+
+ Services.obs.notifyObservers(lwtData, "lightweight-theme-styling-update");
+
+ await SpecialPowers.spawn(
+ browser,
+ [SIDEBAR_BGCOLOR, SIDEBAR_TEXT_COLOR],
+ async (bgColor, textColor) => {
+ let style = content.document.documentElement.style;
+ Assert.equal(
+ style.getPropertyValue("--lwt-sidebar-background-color"),
+ bgColor,
+ "The sidebar background text color should have been set by " +
+ "contentTheme.js"
+ );
+ Assert.equal(
+ style.getPropertyValue("--lwt-sidebar-text-color"),
+ textColor,
+ "The sidebar background text color should have been set by " +
+ "contentTheme.js"
+ );
+ }
+ );
+ }
+ );
+
+ await BrowserTestUtils.closeWindow(win);
+
+ // There is a CSS transition happening on the navigation toolbar
+ // background-color before closing the window.
+ // Compositor animations on closed windows only stop after a GCMajor.
+ // (This is bug 1803387.)
+ // Force a GC immediately to avoid waiting forever for vsync to be disabled.
+ Cu.forceGC();
+});