This reverts commit411c9338c6. 문제: #55(b4895894)가 main run 376의 FE-GATE-030(browser file/storage 제거 드릴)을 깨서 411c9338(#64)로 통째로 되돌렸다. #55의 검사기 진단과 시험 빈틈 고침 12커밋이 main에 없다. 고른 방법: 되돌림을 되돌려 #55를 그대로 다시 넣고, 드릴을 깬 원인은 다음 커밋에서 따로 고친다. 리뷰어가 이 커밋이 #55와 같은지 트리로 볼 수 있다. 이 커밋의 트리는b4895894트리에 그 뒤 main에 들어온 #63·#65만 더한 것이다(git diffb4895894<이 커밋>: docs/ledger 두 파일, cross-context-invalidation adapter 한 파일과 시험 두 파일). 버린 대안: #55 커밋 12개 cherry-pick.71606ff1merge의 충돌 해소분을 다시 풀어야 하고 결과 트리를 b4895894와 대조하기 어렵다. 위험·한계: 이 커밋만으로는 main 단계의 FE-GATE-030이 run 376처럼 실패한다(같은 트리 내용). PR 단계 게이트는 돈다. 검증: 다음 커밋 본문에 적는다. 그 커밋의 새 단언을 이 커밋의 검사기에 돌리면 실패한다(RED). Refs: #55, #64
168 lines
6.4 KiB
TypeScript
168 lines
6.4 KiB
TypeScript
import { fileURLToPath } from "node:url";
|
|
|
|
import {
|
|
expect,
|
|
test,
|
|
type Page,
|
|
} from "../support/browser/strict-browser-test.ts";
|
|
import { KO_MESSAGES } from "../../src/presentation/i18n/catalog.ts";
|
|
|
|
/**
|
|
* 1106/08-03. `scrollbar-gutter: stable` (base.css, 1105/15-05) keeps a
|
|
* classic scrollbar's strip on the right even when the page does not scroll.
|
|
* Only the root background paints that strip; the page and every fixed box,
|
|
* the modal `::backdrop` included, end at its left edge. The goldens run with
|
|
* Playwright's `--hide-scrollbars`, so this spec starts Chromium with the
|
|
* scrollbar most Windows and Linux desktops draw and reads the drawn pixels.
|
|
* Hit testing is no evidence here: the strip answers `null` either way.
|
|
*/
|
|
test.use({
|
|
launchOptions: {
|
|
// `test.use` replaces the config's launchOptions whole: the font pin
|
|
// from playwright.visual.config.ts is repeated.
|
|
env: {
|
|
...process.env,
|
|
FONTCONFIG_FILE: fileURLToPath(new URL("./fonts.conf", import.meta.url)),
|
|
},
|
|
ignoreDefaultArgs: ["--hide-scrollbars"],
|
|
},
|
|
});
|
|
|
|
type Colour = readonly number[];
|
|
type Strip = Readonly<{ x: number; width: number }>;
|
|
|
|
/**
|
|
* The largest channel difference the gutter may show against the strip
|
|
* beside it. The drawer's shadow (`--shadow-dialog`, 70 px blur) still
|
|
* darkens the strip beside the gutter by about 3 levels; rounding adds 1 or
|
|
* 2. In the light theme a gutter the scrim does not cover
|
|
* (the page surface against 55% of the content colour over it) differs by
|
|
* about 120.
|
|
*/
|
|
const SAME_COLOUR = 12;
|
|
|
|
/** The mean colour of each strip, from one screenshot of the band. */
|
|
async function stripColours(
|
|
page: Page,
|
|
band: Readonly<{ y: number; height: number }>,
|
|
strips: readonly Strip[],
|
|
): Promise<Colour[]> {
|
|
const left = Math.min(...strips.map((strip) => strip.x));
|
|
const right = Math.max(...strips.map((strip) => strip.x + strip.width));
|
|
const png = await page.screenshot({
|
|
animations: "disabled",
|
|
clip: { x: left, y: band.y, width: right - left, height: band.height },
|
|
scale: "css",
|
|
});
|
|
// Decoded in a blank page, so the page under test runs nothing extra.
|
|
const decoder = await page.context().newPage();
|
|
try {
|
|
return await decoder.evaluate(
|
|
async ({ base64, offsets }) => {
|
|
const bytes = Uint8Array.from(atob(base64), (character) =>
|
|
character.charCodeAt(0),
|
|
);
|
|
const bitmap = await createImageBitmap(
|
|
new Blob([bytes], { type: "image/png" }),
|
|
);
|
|
const canvas = new OffscreenCanvas(bitmap.width, bitmap.height);
|
|
// Read back once per strip: without the hint Chromium warns on the
|
|
// console of this tab, which the strict fixture watches (1112/03-05).
|
|
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
if (context === null) throw new Error("no 2d canvas context");
|
|
context.drawImage(bitmap, 0, 0);
|
|
return offsets.map(({ x, width }) => {
|
|
const { data } = context.getImageData(x, 0, width, bitmap.height);
|
|
const sums = [0, 0, 0];
|
|
for (let index = 0; index < data.length; index += 4) {
|
|
for (let channel = 0; channel < 3; channel += 1) {
|
|
sums[channel] += data[index + channel];
|
|
}
|
|
}
|
|
return sums.map((sum) => Math.round(sum / (data.length / 4)));
|
|
});
|
|
},
|
|
{
|
|
base64: png.toString("base64"),
|
|
offsets: strips.map((strip) => ({ x: strip.x - left, width: strip.width })),
|
|
},
|
|
);
|
|
} finally {
|
|
await decoder.close();
|
|
}
|
|
}
|
|
|
|
async function expectGutterLikeBeside(
|
|
page: Page,
|
|
geometry: Readonly<{
|
|
band: Readonly<{ y: number; height: number }>;
|
|
beside: Strip;
|
|
gutter: Strip;
|
|
}>,
|
|
what: string,
|
|
) {
|
|
const [beside, gutter] = await stripColours(page, geometry.band, [
|
|
geometry.beside,
|
|
geometry.gutter,
|
|
]);
|
|
const difference = Math.max(
|
|
...gutter.map((value, channel) => Math.abs(value - beside[channel])),
|
|
);
|
|
// On failure, tells a rule that did not match from a colour not drawn.
|
|
const root = await page.evaluate(() => {
|
|
const style = getComputedStyle(document.documentElement);
|
|
return `${style.backgroundColor} / ${style.backgroundImage}, open dialogs ${document.querySelectorAll(".ui-dialog[open]").length}`;
|
|
});
|
|
expect(
|
|
difference,
|
|
`${what}: gutter rgb(${gutter.join(" ")}), beside it rgb(${beside.join(" ")}); root background ${root}`,
|
|
).toBeLessThanOrEqual(SAME_COLOUR);
|
|
}
|
|
|
|
test("the open drawer's scrim covers the classic scrollbar gutter on a page that does not scroll", async ({
|
|
page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
await page.goto("/not-found");
|
|
await expect(page.getByRole("heading", { level: 1 })).toHaveText(
|
|
KO_MESSAGES["page.notFound.title"],
|
|
);
|
|
|
|
const layout = await page.evaluate(() => ({
|
|
windowWidth: window.innerWidth,
|
|
windowHeight: window.innerHeight,
|
|
// With the gutter empty, documentElement.clientWidth is the window
|
|
// width (08-R2); the page's own box ends at the gutter.
|
|
pageRight: Math.round(document.body.getBoundingClientRect().right),
|
|
scrolls:
|
|
document.documentElement.scrollHeight >
|
|
document.documentElement.clientHeight,
|
|
}));
|
|
expect(layout.scrolls, "a page that scrolls draws its scrollbar in the gutter").toBe(
|
|
false,
|
|
);
|
|
expect(
|
|
layout.windowWidth - layout.pageRight,
|
|
"Chromium without --hide-scrollbars reserves a classic scrollbar's gutter",
|
|
).toBeGreaterThanOrEqual(10);
|
|
|
|
// A band at mid-height. The strip beside the gutter lies in the page's own
|
|
// padding, 5 px in from its edge so the scrim's 2 px blur stays inside it;
|
|
// the gutter strip keeps 3 px off both of its edges.
|
|
const geometry = {
|
|
band: { y: Math.round(layout.windowHeight / 2) - 20, height: 40 },
|
|
beside: { x: layout.pageRight - 10, width: 5 },
|
|
gutter: { x: layout.pageRight + 3, width: layout.windowWidth - layout.pageRight - 6 },
|
|
};
|
|
await expectGutterLikeBeside(page, geometry, "closed, the gutter shows the page surface");
|
|
|
|
const menu = page.getByRole("button", { name: KO_MESSAGES["shell.menu"], exact: true });
|
|
await menu.click();
|
|
await expect(page.locator(".ui-drawer")).toHaveJSProperty("open", true);
|
|
await expectGutterLikeBeside(page, geometry, "open, the scrim reaches the window edge");
|
|
|
|
await page.keyboard.press("Escape");
|
|
await expect(page.locator(".ui-drawer")).toHaveJSProperty("open", false);
|
|
await expectGutterLikeBeside(page, geometry, "closed again, the gutter shows the page surface");
|
|
});
|