From 85fbfa5c0ce7201a7ea19255a381c34a65d26416 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 27 Oct 2026 14:22:49 +0000 Subject: [PATCH 1/4] test(service-print): render the print page under the console's default CSP on both placements Claude-Session: https://claude.ai/code/session_01FEkQ5kpFFUuQY5FA7FCdwY Co-authored-by: Claude --- .../service-print/src/chromium-driver.test.ts | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/services/service-print/src/chromium-driver.test.ts b/packages/services/service-print/src/chromium-driver.test.ts index 9bda5c2f4e4..55cef1c03c9 100644 --- a/packages/services/service-print/src/chromium-driver.test.ts +++ b/packages/services/service-print/src/chromium-driver.test.ts @@ -39,6 +39,15 @@ import type { PrintSessionCookie } from './principal-session.js'; * host's CJK font, every code point mapped; with Chromium's fonts narrowed to a * Latin-only fontconfig, none did. * + * ## Under the console's CSP + * + * The console serves every page with a Content Security Policy whose + * `script-src` carries no `'unsafe-eval'` by default (it is added only for the + * `kind:'react'` page tier, `consoleContentSecurityPolicy` in + * `packages/cli/src/utils/console.ts`). The fixture serves the same print page + * under that directive too, so a ready wait that evaluates a string in the page + * fails here with the EvalError a default deployment answers. + * * ## Which Chromium * * `OS_TEST_PRINT_CHROMIUM_PATH`, else Playwright's provisioned browser @@ -82,12 +91,17 @@ const COOKIE: PrintSessionCookie = { }; const CJK_TEXT = '发票客户名称上海示例有限公司合计金额'; const RECORD_PATH = '/_console/apps/showcase/invoice/record/inv_1'; +/** The same record page, served under the console's default CSP. */ +const CSP_RECORD_PATH = '/_console/apps/showcase/invoice/record/inv_csp'; +const CSP_NONCE = 'print-fixture-nonce'; +/** The console's default `script-src` (no `'unsafe-eval'`), with the rest of its policy's script-relevant directives. */ +const CONSOLE_DEFAULT_CSP = `default-src 'self'; script-src 'self' 'nonce-${CSP_NONCE}' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'`; -function printPageHtml(): string { +function printPageHtml(nonce?: string): string { return `
-