Files
computer-playbook/roles/web-app-dashboard/files/playwright/test-iframe-sync.js
kevinveenbirkenbachandClaude Opus 4.8 edb96e9ae3 feat(dashboard): make keycloak-js login work over Tor onion
Chromium never treats plaintext .onion origins as a secure context, so
keycloak-js (PKCE via crypto.subtle) could not run. A custom Playwright
browser fixture launches Firefox with the Tor-Browser prefs
(dom.securecontext.allowlist_onions, origin/mixed-content handling) for
onion targets and keeps Chromium for clearnet; all dashboard specs share
it via the register pattern.

keycloak-js is now vendored from the deployment's own CDN as an ES
module (jsdelivr is unreachable over Tor) with CORS opened on the CDN
proxy. Personas and the oidc-login spec wait for adapter readiness and
navbar settle before driving login/logout, which the async code->token
exchange needs over Tor latency.

Verified: full deploy matrix green (onion 14/14 twice, clearnet pass).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-10 01:55:16 +02:00

32 lines
1.2 KiB
JavaScript

const { test, expect } = require("./fixtures/onion-test");
const { resolveTimeout } = require("./timeouts");
const { gotoOnion } = require("./personas");
exports.register = function (shared) {
test("dashboard iframe sync JavaScript responds to iframeLocationChange events", async ({ page }) => {
shared.skipUnlessServiceEnabled("cdn");
shared.skipUnlessServiceEnabled("matomo");
await gotoOnion(page,"/");
await shared.waitForDashboardReady(page);
const iframeTargetUrl = `${shared.env.matomoBaseUrl}/?playwright-iframe-sync=1`;
const messagePayload = { href: iframeTargetUrl, origin: new URL(iframeTargetUrl).origin };
await expect
.poll(async () => {
await page.evaluate(({ href, origin }) => {
window.dispatchEvent(new MessageEvent("message", {
origin,
data: { type: "iframeLocationChange", href },
}));
}, messagePayload);
return page.evaluate(() => new URL(window.location.href).searchParams.get("iframe"));
}, {
timeout: resolveTimeout(15_000),
message: "Expected dashboard iframe sync JavaScript to update the iframe query parameter",
})
.toBe(iframeTargetUrl);
});
};