test: verify lost launch replies and reload recovery in a scratch browser

This commit is contained in:
2026-10-20 15:44:23 +01:00
parent 44834e91f0
commit e4f48ecbb1
4 changed files with 148 additions and 0 deletions
+6
View File
@@ -1,5 +1,7 @@
// Invoked by the Go scratch-server test, never against the deployed service.
import assert from "node:assert/strict";
import { mkdir } from "node:fs/promises";
import { join } from "node:path";
import { launchChrome } from "./browser.mjs";
const url = process.argv[2];
@@ -12,6 +14,10 @@ try {
assert.equal(await page.evaluate("document.title"), "Safe report");
assert.equal(await page.evaluate("document.querySelector('#report').textContent"), "Readable report");
assert.equal(await page.evaluate("getComputedStyle(document.querySelector('#report')).color"), "rgb(12, 34, 56)");
if (process.env.PIPELINES_CAPTURE_DIR) {
await mkdir(process.env.PIPELINES_CAPTURE_DIR, { recursive: true });
await page.screenshot(join(process.env.PIPELINES_CAPTURE_DIR, "artifact-script-blocked.png"));
}
// The inline attack would change the title and call /attack if it ran. The
// server-side test also asserts that endpoint received no request.
console.log("Raw HTML report is readable; inline script blocked by response policy.");