🐛 Fix internal error crash when attempting to download a font resource that returns 404

This commit is contained in:
Belén Albeza
2025-09-29 15:38:40 +02:00
parent 979b4276ca
commit 60f45d1fd7
3 changed files with 404 additions and 8 deletions

View File

@@ -1,16 +1,12 @@
import { test, expect } from "@playwright/test";
import { WorkspacePage } from "../pages/WorkspacePage";
import { WasmWorkspacePage } from "../pages/WasmWorkspacePage";
test.beforeEach(async ({ page }) => {
await WorkspacePage.init(page);
await WorkspacePage.mockConfigFlags(page, [
"enable-feature-render-wasm",
"enable-render-wasm-dpr",
]);
await WasmWorkspacePage.init(page);
});
test("BUG 10867 - Crash when loading comments", async ({ page }) => {
const workspacePage = new WorkspacePage(page);
const workspacePage = new WasmWorkspacePage(page);
await workspacePage.setupEmptyFile();
await workspacePage.goToWorkspace();
@@ -19,3 +15,45 @@ test("BUG 10867 - Crash when loading comments", async ({ page }) => {
workspacePage.rightSidebar.getByText("Show all comments"),
).toBeVisible();
});
test("BUG 12164 - Crash when trying to fetch a missing font", async ({
page,
}) => {
// mock fetching a missing font
// FIXME: this is very hacky. I suspect something might be going on with
// beicon, fetch or http/send and the way we handle requests failures that
// make Plawyright stop execution of the JS thread immediately.
await page.addInitScript(() => {
// Override fetch specifically for the failing font route
const originalFetch = window.fetch;
window.fetch = (url, options) => {
if (url.includes("/internal/gfonts/font/crimsonpro")) {
console.log("Intercepting font request:", url);
// Return a rejected promise that we handle
return Promise.reject(new Error("Font not found (mocked)"));
}
return originalFetch.call(window, url, options);
};
});
const workspacePage = new WasmWorkspacePage(page);
await workspacePage.setupEmptyFile();
await workspacePage.mockGetFile("render-wasm/get-file-12164.json");
// FIXME: remove this once we fix the issue of downloading emoji fonts that are
// not needed.
await workspacePage.mockGoogleFont(
"noto",
"render-wasm/assets/notosansjpsubset.ttf",
);
await workspacePage.goToWorkspace({
id: "2b7f0188-51a1-8193-8006-e05bad874e2e",
pageId: "2b7f0188-51a1-8193-8006-e05bad87b74d",
});
await workspacePage.waitForFirstRender({ hideUI: false });
await expect(
workspacePage.page.getByText("Internal Error"),
).not.toBeVisible();
});