test(browser): strict 검사를 공용 watcher로 빼 같은 context의 다른 탭도 본다
frontend-quality-gates / merge / static checks (pull_request) Successful in 1m13s
frontend-quality-gates / merge / tests (pull_request) Failing after 11m34s
frontend-quality-gates / merge / browser tests (pull_request) Successful in 5m32s
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Skipped
frontend-quality-gates / main / self-tests and removal drills (pull_request) Skipped
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Skipped
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Skipped
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Skipped
frontend-quality-gates / external-vulnerability-provider (pull_request) Skipped
frontend-quality-gates / external-provenance-provider (pull_request) Skipped
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Skipped
frontend-quality-gates / deploy-promoted-release (pull_request) Skipped
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Skipped
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Skipped
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Skipped
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Skipped
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Skipped
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Skipped
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Skipped
frontend-quality-gates / merge / static checks (pull_request) Successful in 1m13s
frontend-quality-gates / merge / tests (pull_request) Failing after 11m34s
frontend-quality-gates / merge / browser tests (pull_request) Successful in 5m32s
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Skipped
frontend-quality-gates / main / self-tests and removal drills (pull_request) Skipped
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Skipped
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Skipped
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Skipped
frontend-quality-gates / external-vulnerability-provider (pull_request) Skipped
frontend-quality-gates / external-provenance-provider (pull_request) Skipped
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Skipped
frontend-quality-gates / deploy-promoted-release (pull_request) Skipped
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Skipped
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Skipped
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Skipped
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Skipped
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Skipped
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Skipped
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Skipped
문제: strict fixture는 fixture의 `page` 하나에만 콘솔·pageerror·
requestfailed listener를 붙였다. 다른 탭을 여는 capability 시험 7곳
(cross-context invalidation, OPFS, IndexedDB)의 두 번째 탭은 아무도 보지
않았다. SW recovery 시험은 자기 context를 쓰며 fixture와 다른 손 사본
(WebKit 문구 무시 없음)으로 검사했다.
고친 것: 검사 본문을 `watchBrowserFailures(page, { preloads })`로 뺀다.
fixture는 자기 page(preload 검사 포함)와, 같은 context에서 열리는 모든 탭에
같은 함수를 붙인다(탭이 열릴 때 동기로 붙여 spec이 이동하기 전이다). SW
recovery는 회복된 load 전에 같은 함수를 붙인다. 손 사본은 지운다.
fixture의 기록을 읽는 `preload-use.spec.ts`에 둘째 탭의 console.error가
기록되는지 보는 시험을 더한다.
위험·한계: 둘째 탭의 preload 사용은 보지 않는다(첫 page만). SW recovery도
preload를 보지 않는다. 그 context는 같은 origin을 두 번 열어, WebKit이 회복된
load의 script를 캐시에서 주며 추적기의 route를 지나쳐 모든 preload가
미사용으로 읽혔다(16건).
검증: desktop — 옛 fixture에서 둘째 탭 시험이 세 엔진 모두 실패(RED),
고친 fixture에서 preload-use·SW recovery 통과, capability 세 spec은
FE-GATE-008에서 본다.
Refs: 1112/03-05
This commit is contained in:
@@ -298,6 +298,25 @@ recordedTest.describe("the strict fixture's console check", () => {
|
||||
);
|
||||
});
|
||||
|
||||
// 1112/03-05. The fixture watched its own page only, so a console error in
|
||||
// a second tab of the same context (the cross-tab capability specs) passed.
|
||||
recordedTest.describe("the strict fixture's other tabs", () => {
|
||||
recordedTest.use({
|
||||
fixtureReports: { lines: [/^console:error:\[preload-use\] second tab$/u] },
|
||||
});
|
||||
|
||||
recordedTest(
|
||||
"records a console error in another tab of the context",
|
||||
async ({ page }) => {
|
||||
await openHome(page);
|
||||
const second = await page.context().newPage();
|
||||
await openHome(second);
|
||||
|
||||
await second.evaluate(() => console.error("[preload-use] second tab"));
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* 1105/11-01. The verdict every other spec gets: a recorded failure fails the
|
||||
* test. The record is proven above; this proves the verdict.
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import path from "node:path";
|
||||
|
||||
import { expect, test, type Page } from "../support/browser/strict-browser-test.ts";
|
||||
import {
|
||||
expect,
|
||||
test,
|
||||
watchBrowserFailures,
|
||||
type Page,
|
||||
} from "../support/browser/strict-browser-test.ts";
|
||||
import {
|
||||
prepareServiceWorkerBuilds,
|
||||
removeServiceWorkerBuilds,
|
||||
@@ -91,7 +96,7 @@ test("a REMOVE_REGISTRATION release unregisters a worker that blocks boot", asyn
|
||||
const server = await startBuildServer(builds.dist);
|
||||
// The broken phase fails requests on purpose, so this test drives its own
|
||||
// context instead of the strict `page` fixture and checks the recovered
|
||||
// load for browser errors itself.
|
||||
// load for browser errors with the fixture's own watcher (1112/03-05).
|
||||
const context = await browser.newContext();
|
||||
try {
|
||||
const page = await context.newPage();
|
||||
@@ -133,22 +138,16 @@ test("a REMOVE_REGISTRATION release unregisters a worker that blocks boot", asyn
|
||||
)
|
||||
.toBe(true);
|
||||
|
||||
const failures: string[] = [];
|
||||
page.on("console", (message) => {
|
||||
if (["error", "warning"].includes(message.type())) {
|
||||
failures.push(`console:${message.type()}:${message.text()}`);
|
||||
}
|
||||
});
|
||||
page.on("pageerror", (error) => failures.push(`pageerror:${error.name}`));
|
||||
page.on("requestfailed", (request) =>
|
||||
failures.push(`requestfailed:${new URL(request.url()).pathname}`),
|
||||
);
|
||||
// No preload check here: this context loaded the origin twice already,
|
||||
// and WebKit answers the recovered load's scripts from its cache, past
|
||||
// the tracker's route, so every preload reads as unused (16 in a run).
|
||||
const recovered = await watchBrowserFailures(page);
|
||||
await page.goto(`${server.origin}/`);
|
||||
expect(await startOutcome(page)).toEqual({ kind: "DISABLED" });
|
||||
expect(
|
||||
await page.evaluate(() => navigator.serviceWorker.controller === null),
|
||||
).toBe(true);
|
||||
expect(failures).toEqual([]);
|
||||
expect(await recovered.stop()).toEqual([]);
|
||||
} finally {
|
||||
await context.close();
|
||||
await server.close();
|
||||
|
||||
@@ -20,6 +20,48 @@ function ignoredConsole(message: ConsoleMessage) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1112/03-05. Records a page's browser failures as `console:…`, `pageerror:…`
|
||||
* and `requestfailed:…` lines, with the same rules the strict fixture judges
|
||||
* by. The fixture watches its `page` and every other tab opened in the same
|
||||
* context; a spec that drives a context of its own watches its pages with
|
||||
* this. `preloads` also checks that every modulepreload ran (preload-use.ts)
|
||||
* in the documents open when `stop` runs; attach it before the navigation
|
||||
* that loads them.
|
||||
*/
|
||||
export async function watchBrowserFailures(
|
||||
page: Page,
|
||||
options: Readonly<{ preloads?: boolean }> = {},
|
||||
): Promise<Readonly<{ stop(): Promise<string[]> }>> {
|
||||
const failures: string[] = [];
|
||||
const onConsole = (message: ConsoleMessage) => {
|
||||
if (["error", "warning"].includes(message.type()) && !ignoredConsole(message)) {
|
||||
failures.push(`console:${message.type()}:${message.text()}`);
|
||||
}
|
||||
};
|
||||
const onPageError = (error: Error) => {
|
||||
failures.push(`pageerror:${error.name}`);
|
||||
};
|
||||
const onRequestFailed = (request: import("@playwright/test").Request) => {
|
||||
failures.push(
|
||||
`requestfailed:${request.method()}:${new URL(request.url()).pathname}:${request.failure()?.errorText ?? "unknown"}`,
|
||||
);
|
||||
};
|
||||
page.on("console", onConsole);
|
||||
page.on("pageerror", onPageError);
|
||||
page.on("requestfailed", onRequestFailed);
|
||||
const preloads = options.preloads ? await trackPreloadUse(page) : null;
|
||||
return Object.freeze({
|
||||
async stop() {
|
||||
if (preloads) failures.push(...(await preloads.check()).failures);
|
||||
page.off("console", onConsole);
|
||||
page.off("pageerror", onPageError);
|
||||
page.off("requestfailed", onRequestFailed);
|
||||
return [...failures];
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 1105/11-01. What the strict `page` fixture does with every failure it
|
||||
* recorded, once the test has ended.
|
||||
@@ -62,32 +104,19 @@ export const test = base.extend<{
|
||||
);
|
||||
},
|
||||
page: async ({ page, browserFailureVerdict }, use) => {
|
||||
const preloads = await trackPreloadUse(page);
|
||||
const failures: string[] = [];
|
||||
const onConsole = (message: ConsoleMessage) => {
|
||||
if (
|
||||
["error", "warning"].includes(message.type()) &&
|
||||
!ignoredConsole(message)
|
||||
) {
|
||||
failures.push(`console:${message.type()}:${message.text()}`);
|
||||
}
|
||||
const watched = [await watchBrowserFailures(page, { preloads: true })];
|
||||
// 1112/03-05. A second tab of the same context (the cross-tab specs)
|
||||
// went unwatched. Its listeners are attached as the tab opens, before
|
||||
// the spec can navigate it; preload use is checked on the first page only.
|
||||
const pending: Promise<void>[] = [];
|
||||
const onPage = (opened: Page) => {
|
||||
pending.push(watchBrowserFailures(opened).then((watcher) => void watched.push(watcher)));
|
||||
};
|
||||
const onPageError = (error: Error) => {
|
||||
failures.push(`pageerror:${error.name}`);
|
||||
};
|
||||
const onRequestFailed = (request: import("@playwright/test").Request) => {
|
||||
failures.push(
|
||||
`requestfailed:${request.method()}:${new URL(request.url()).pathname}:${request.failure()?.errorText ?? "unknown"}`,
|
||||
);
|
||||
};
|
||||
page.on("console", onConsole);
|
||||
page.on("pageerror", onPageError);
|
||||
page.on("requestfailed", onRequestFailed);
|
||||
page.context().on("page", onPage);
|
||||
await use(page);
|
||||
failures.push(...(await preloads.check()).failures);
|
||||
page.off("console", onConsole);
|
||||
page.off("pageerror", onPageError);
|
||||
page.off("requestfailed", onRequestFailed);
|
||||
page.context().off("page", onPage);
|
||||
await Promise.all(pending);
|
||||
const failures = (await Promise.all(watched.map((watcher) => watcher.stop()))).flat();
|
||||
browserFailureVerdict.judge(failures);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -66,7 +66,9 @@ async function stripColours(
|
||||
new Blob([bytes], { type: "image/png" }),
|
||||
);
|
||||
const canvas = new OffscreenCanvas(bitmap.width, bitmap.height);
|
||||
const context = canvas.getContext("2d");
|
||||
// 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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user