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)

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)
This commit is contained in:
yetone
2026-10-09 19:24:16 +08:00
parent ee14595ff3
commit 655f96ede4
2 changed files with 6 additions and 4 deletions
+2 -2
View File
@@ -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);
+4 -2
View File
@@ -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);