From d43b86b0229af8a53e02da32e9fec694a7fd2a87 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 9 Oct 2026 17:45:55 +0200 Subject: [PATCH] fix(web-app-keycloak): read the account page body before the console redirects The CSP spec opens /realms//account/, the account console SPA, which redirects to the login flow from JavaScript. The spec read response.text() only after the header and meta CSP checks, and once the redirect had committed Playwright 1.64 no longer holds the body. MediaWiki#0 (swarm) of main run 37903645290 failed all three attempts at playwright.spec.js:116 with "Response body is not available for a response that was navigated away from", while the same spec passed locally in under a second. The body is now read right after the status check, as Playwright's own message asks. The assertion on the canonical domain is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/web-app-keycloak/files/playwright/playwright.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-keycloak/files/playwright/playwright.spec.js b/roles/web-app-keycloak/files/playwright/playwright.spec.js index 1aac1d7279..facd0596e2 100644 --- a/roles/web-app-keycloak/files/playwright/playwright.spec.js +++ b/roles/web-app-keycloak/files/playwright/playwright.spec.js @@ -109,11 +109,11 @@ test("keycloak enforces Content-Security-Policy and exposes canonical domain fro const response = await gotoOnion(page, `${appBaseUrl}/realms/${realmName}/account/`); expect(response, "Expected Keycloak account page response").toBeTruthy(); expect(response.status(), "Expected Keycloak account page to respond successfully").toBeLessThan(400); + const documentHtml = await response.text(); const directives = assertCspResponseHeader(response, "keycloak account page"); await assertCspMetaParity(page, directives, "keycloak account page"); - const documentHtml = await response.text(); expect( documentHtml.includes(canonicalDomain) || (await page.content()).includes(canonicalDomain), `Expected canonical domain "${canonicalDomain}" (from applications lookup) to appear in the Keycloak UI`