From 61e7bf76bb31ffd468aecf28b4d60be873517821 Mon Sep 17 00:00:00 2001 From: YrFnS Date: Wed, 18 Nov 2026 22:00:24 +0300 Subject: [PATCH 1/4] fix(newtab): frost statistic figures over custom wallpaper --- .../NewTabCustomization.component.test.ts | 115 +++++++++++++++++- .../features/newtab/components/NewTab.svelte | 29 ++++- 2 files changed, 142 insertions(+), 2 deletions(-) diff --git a/frame/src/app/browser/tests/NewTabCustomization.component.test.ts b/frame/src/app/browser/tests/NewTabCustomization.component.test.ts index f82dd4a26..7e61e9f4b 100644 --- a/frame/src/app/browser/tests/NewTabCustomization.component.test.ts +++ b/frame/src/app/browser/tests/NewTabCustomization.component.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, expect, test, vi } from "vitest"; import { render } from "vitest-browser-svelte"; -import { page } from "vitest/browser"; +import { page, userEvent } from "vitest/browser"; import { createRawSnippet } from "svelte"; import "$styles/global.css"; import { preferences } from "$domain/preferences"; @@ -110,6 +110,7 @@ afterEach(() => { preferences.dispose(); retryImage(); delete document.documentElement.dataset.theme; + delete document.documentElement.dataset.material; }); async function tab() { const { default: NewTab } = await loadNewTab(); @@ -186,6 +187,118 @@ test("a custom background uses one sized local image, no sky decode or frost, an expect(preferences.value("ui.newtab-dim")).toBe("false"); }); +test.each(["light", "dark"])( + "custom-image figures follow the native material in %s", + async (theme) => { + native.settings = { "ui.newtab-background": "image", "ui.newtab-image": digest }; + document.documentElement.dataset.theme = theme; + await preferences.init(); + const ntp = await tab(); + await expect + .poll(() => ntp.container.querySelector("img")?.naturalWidth ?? 0) + .toBeGreaterThan(0); + const figures = [...ntp.container.querySelectorAll(".figure")]; + expect(figures).toHaveLength(3); + const paint = document.createElement("canvas").getContext("2d")!; + for (const material of [ + null, + "none", + "vibrancy", + "liquid_glass", + "acrylic", + "mica", + "mica_alt", + ]) { + if (material === null) delete document.documentElement.dataset.material; + else document.documentElement.dataset.material = material; + const translucent = material !== null && material !== "none"; + for (const figure of figures) { + const style = getComputedStyle(figure); + expect(style.backdropFilter, material ?? "bootstrap").toBe( + translucent ? "blur(24px)" : "none", + ); + const alpha = () => { + paint.clearRect(0, 0, 1, 1); + paint.fillStyle = getComputedStyle(figure).backgroundColor; + paint.fillRect(0, 0, 1, 1); + return paint.getImageData(0, 0, 1, 1).data[3]!; + }; + if (translucent) { + await expect.poll(alpha).toBeLessThan(255); + expect(alpha()).toBeGreaterThan(0); + } else await expect.poll(alpha).toBe(255); + expect(style.transitionProperty).not.toContain("backdrop-filter"); + } + } + document.documentElement.dataset.material = "liquid_glass"; + const button = ntp.container.querySelector("button.figure")!; + await ntp.getByRole("textbox", { name: "Search" }).click(); + await userEvent.tab(); + await userEvent.tab(); + expect(document.activeElement).toBe(button); + expect(getComputedStyle(button).outlineStyle).toBe("solid"); + await page.elementLocator(ntp.container).screenshot({ + path: `../../../../../target/newtab/custom-figures-${theme}.png`, + }); + await preferences.set("ui.newtab-background", "sky"); + await expect.poll(() => ntp.container.querySelector(".sky")).not.toBeNull(); + for (const figure of figures) expect(getComputedStyle(figure).backdropFilter).toBe("none"); + }, +); + +test.each(["light", "dark"])( + "custom-image figures stay readable on extreme wallpaper in %s", + async (theme) => { + native.settings = { "ui.newtab-background": "image", "ui.newtab-image": digest }; + const wallpaper = theme === "dark" ? [255, 255, 255] : [0, 0, 0]; + native.media.mockReturnValue( + `data:image/svg+xml,${encodeURIComponent(``)}`, + ); + document.documentElement.dataset.theme = theme; + document.documentElement.dataset.material = "liquid_glass"; + await preferences.init(); + const ntp = await tab(); + await expect + .poll(() => ntp.container.querySelector("img")?.naturalWidth ?? 0) + .toBeGreaterThan(0); + const paint = document.createElement("canvas").getContext("2d")!; + const rgba = (color: string) => { + paint.clearRect(0, 0, 1, 1); + paint.fillStyle = color; + paint.fillRect(0, 0, 1, 1); + return [...paint.getImageData(0, 0, 1, 1).data]; + }; + const over = (front: number[], back: number[]) => { + const alpha = front[3]! / 255; + return front + .slice(0, 3) + .map((channel, index) => channel * alpha + back[index]! * (1 - alpha)); + }; + const luminance = (rgb: number[]) => { + const linear = rgb.map((channel) => { + const value = channel / 255; + return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4; + }); + return linear[0]! * 0.2126 + linear[1]! * 0.7152 + linear[2]! * 0.0722; + }; + const figures = [...ntp.container.querySelectorAll(".figure")]; + expect(figures).toHaveLength(3); + for (const figure of figures) { + for (const text of figure.querySelectorAll(".name, .value, .foot")) { + await expect + .poll(() => { + const background = over(rgba(getComputedStyle(figure).backgroundColor), wallpaper); + const foreground = over(rgba(getComputedStyle(text).color), background); + const first = luminance(background); + const second = luminance(foreground); + return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05); + }) + .toBeGreaterThanOrEqual(4.5); + } + } + }, +); + test("native image import commits only the admitted digest, and cancellation keeps the sky", async () => { await preferences.init(); const settings = await settingsScreen(); diff --git a/frame/src/features/newtab/components/NewTab.svelte b/frame/src/features/newtab/components/NewTab.svelte index 008fde65f..dfd381c65 100644 --- a/frame/src/features/newtab/components/NewTab.svelte +++ b/frame/src/features/newtab/components/NewTab.svelte @@ -897,7 +897,27 @@ } .custom .figure { - background: var(--color-surface); + background: var(--figure-surface, var(--color-surface)); + color: var(--color-label-secondary); + backdrop-filter: var(--figure-filter, none); + } + + .custom .figure .foot:not(.late) { + color: var(--color-label-secondary); + } + + /* Frost only the capsules; the wash keeps arbitrary wallpaper legible. */ + :global(:root:not([data-material="none"])[data-material]) .newtab.custom { + --figure-surface: color-mix(in srgb, var(--color-surface) 88%, transparent); + --figure-filter: blur(24px); + } + + .custom button.figure:hover { + background: color-mix( + in srgb, + var(--color-text) 9%, + var(--figure-surface, var(--color-surface)) + ); } /* A narrow pane keeps each figure to its icon and value on one row; the @@ -970,6 +990,13 @@ display: none; } + .custom .figure, + .custom button.figure:hover { + background: Canvas; + color: CanvasText; + backdrop-filter: none; + } + .name { fill: CanvasText; } From 45fa88e32b30e6a24d7007978e6d02cc0981ec3e Mon Sep 17 00:00:00 2001 From: crynta <3nnigma.dev@gmail.com> Date: Mon, 23 Nov 2026 03:30:19 +0100 Subject: [PATCH 2/4] fix(newtab): keep the figure wash without a live blur backdrop-filter costs GPU on the new tab, which draws the sky's frost from a pre-rendered image for that reason. The 88% surface wash alone keeps the figures readable over a custom wallpaper; the contrast tests compose it without a blur. --- .../app/browser/tests/NewTabCustomization.component.test.ts | 4 +--- frame/src/features/newtab/components/NewTab.svelte | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/frame/src/app/browser/tests/NewTabCustomization.component.test.ts b/frame/src/app/browser/tests/NewTabCustomization.component.test.ts index 7e61e9f4b..70eee72d4 100644 --- a/frame/src/app/browser/tests/NewTabCustomization.component.test.ts +++ b/frame/src/app/browser/tests/NewTabCustomization.component.test.ts @@ -214,9 +214,7 @@ test.each(["light", "dark"])( const translucent = material !== null && material !== "none"; for (const figure of figures) { const style = getComputedStyle(figure); - expect(style.backdropFilter, material ?? "bootstrap").toBe( - translucent ? "blur(24px)" : "none", - ); + expect(style.backdropFilter, material ?? "bootstrap").toBe("none"); const alpha = () => { paint.clearRect(0, 0, 1, 1); paint.fillStyle = getComputedStyle(figure).backgroundColor; diff --git a/frame/src/features/newtab/components/NewTab.svelte b/frame/src/features/newtab/components/NewTab.svelte index dfd381c65..cd0d7dfc1 100644 --- a/frame/src/features/newtab/components/NewTab.svelte +++ b/frame/src/features/newtab/components/NewTab.svelte @@ -899,17 +899,15 @@ .custom .figure { background: var(--figure-surface, var(--color-surface)); color: var(--color-label-secondary); - backdrop-filter: var(--figure-filter, none); } .custom .figure .foot:not(.late) { color: var(--color-label-secondary); } - /* Frost only the capsules; the wash keeps arbitrary wallpaper legible. */ + /* A wash, not a live blur: it keeps arbitrary wallpaper legible at no GPU cost. */ :global(:root:not([data-material="none"])[data-material]) .newtab.custom { --figure-surface: color-mix(in srgb, var(--color-surface) 88%, transparent); - --figure-filter: blur(24px); } .custom button.figure:hover { @@ -994,7 +992,6 @@ .custom button.figure:hover { background: Canvas; color: CanvasText; - backdrop-filter: none; } .name { From b7263bb3d99b3ee0dcbbfe92d1d561f0283ee1dc Mon Sep 17 00:00:00 2001 From: crynta <3nnigma.dev@gmail.com> Date: Mon, 23 Nov 2026 04:16:27 +0100 Subject: [PATCH 3/4] test(newtab): focus the figure button as the keyboard would in WebKit WebKit's Tab skips buttons unless full keyboard access is on, so two Tab presses from the search field never reached the figure on the hosted macOS runner. Focus it with focusVisible, as the other component tests do. --- .../browser/tests/NewTabCustomization.component.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/src/app/browser/tests/NewTabCustomization.component.test.ts b/frame/src/app/browser/tests/NewTabCustomization.component.test.ts index 70eee72d4..b2546949d 100644 --- a/frame/src/app/browser/tests/NewTabCustomization.component.test.ts +++ b/frame/src/app/browser/tests/NewTabCustomization.component.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, expect, test, vi } from "vitest"; import { render } from "vitest-browser-svelte"; -import { page, userEvent } from "vitest/browser"; +import { page } from "vitest/browser"; import { createRawSnippet } from "svelte"; import "$styles/global.css"; import { preferences } from "$domain/preferences"; @@ -230,10 +230,10 @@ test.each(["light", "dark"])( } document.documentElement.dataset.material = "liquid_glass"; const button = ntp.container.querySelector("button.figure")!; - await ntp.getByRole("textbox", { name: "Search" }).click(); - await userEvent.tab(); - await userEvent.tab(); + // WebKit's Tab skips buttons by default, so focus it as the keyboard would. + button.focus({ focusVisible: true } as FocusOptions); expect(document.activeElement).toBe(button); + expect(button.matches(":focus-visible")).toBe(true); expect(getComputedStyle(button).outlineStyle).toBe("solid"); await page.elementLocator(ntp.container).screenshot({ path: `../../../../../target/newtab/custom-figures-${theme}.png`, From 4dbf641b9f99933747b5bf087e1eb244fc0e2716 Mon Sep 17 00:00:00 2001 From: crynta <3nnigma.dev@gmail.com> Date: Mon, 23 Nov 2026 04:38:29 +0100 Subject: [PATCH 4/4] fix(newtab): raise the figure wash so overdue text keeps 4.5:1 contrast Over an undimmed white wallpaper in dark theme, the 88% wash left the overdue foot at about 4.3:1. At 92% it stays above 4.5:1 while the wallpaper still shows through. --- frame/src/features/newtab/components/NewTab.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/src/features/newtab/components/NewTab.svelte b/frame/src/features/newtab/components/NewTab.svelte index cd0d7dfc1..8b73830b7 100644 --- a/frame/src/features/newtab/components/NewTab.svelte +++ b/frame/src/features/newtab/components/NewTab.svelte @@ -907,7 +907,7 @@ /* A wash, not a live blur: it keeps arbitrary wallpaper legible at no GPU cost. */ :global(:root:not([data-material="none"])[data-material]) .newtab.custom { - --figure-surface: color-mix(in srgb, var(--color-surface) 88%, transparent); + --figure-surface: color-mix(in srgb, var(--color-surface) 92%, transparent); } .custom button.figure:hover {