From 655f96ede4ccb7d95a6604342f1f004cdc02846e Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 9 Oct 2026 19:22:53 +0800 Subject: [PATCH] gui tests: usage-fold and account-mask no longer reload the Usage page the moment it opens, so WebKit has no first reads to cancel and report as page errors (#1350) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both tests opened the page in a new browser context, cleared their localStorage keys and reloaded at once. A new context's storage is already empty, and the reload lands while the page's first reads (agents/cli, agents/install, usage, upstream, update, whatsnew) are on their way. WebKit logs each fetch it cancels as "Fetch API cannot load … due to access control checks." with source "javascript", which Playwright's WebKit turns into a pageerror, and the tests' final assert.deepEqual(errors, []) failed. The app catches every one of those reads; nothing is wrong in the page. Instrumented runs show it: requestfailed "cancelled" for whatsnew/update and the two page errors within 70ms after the first reload, none after. Verified (Playwright 1.62.1, macOS arm64), WebKit "several accounts" (en+zh), 8 copies at once, 5 rounds: - before: 3 of 80 cases red, each with "Fetch API cannot load … due to access control checks" right after the first reload - after: 80 of 80 pass, no page error - usage-fold.test.cjs + account-mask.test.cjs, Chromium and WebKit, 10 runs: 100/100 pass (10 cases each run) --- internal/gui/tests/account-mask.test.cjs | 4 ++-- internal/gui/tests/usage-fold.test.cjs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/gui/tests/account-mask.test.cjs b/internal/gui/tests/account-mask.test.cjs index 67671a3b9..9ae79e133 100644 --- a/internal/gui/tests/account-mask.test.cjs +++ b/internal/gui/tests/account-mask.test.cjs @@ -63,9 +63,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await page.goto(url); return page; }; + // a new context's storage is empty: no reload to clear it, which + // would cancel the page's first reads, each a page error in WebKit (#1350) const page = await open("http://magpie.test/?view=usage"); - await page.evaluate(() => localStorage.removeItem("magpie.maskEmails")); - await page.reload(); await page.waitForSelector(".subscription-account .user"); const btn = page.locator("#usageMask"); assert.equal((await btn.textContent()).trim(), w.hide); diff --git a/internal/gui/tests/usage-fold.test.cjs b/internal/gui/tests/usage-fold.test.cjs index 246412b30..a436cfe00 100644 --- a/internal/gui/tests/usage-fold.test.cjs +++ b/internal/gui/tests/usage-fold.test.cjs @@ -84,9 +84,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await page.goto(url); return page; }; + // a new context's storage is empty: nothing to clear and reload. A + // reload at once lands while the page's first reads are on their way, + // and WebKit reports each one it cancels as a page error, "Fetch API + // cannot load … due to access control checks" (#1350) const page = await open("http://magpie.test/?view=usage"); - await page.evaluate(() => { localStorage.removeItem("magpie.usageOpen"); localStorage.removeItem("magpie.usageAccounts"); localStorage.removeItem("magpie.maskEmails"); }); - await page.reload(); await page.waitForSelector(".subscription-account .user", { state: "attached" }); let got = await cards(page);