Fix PDF viewer crash on older macOS WebKit (#730)

This commit is contained in:
Gregory Schier authored and GitHub committed 2026-10-06 20:50:07 -07:00
1 parent 7890281db3
commit b4417add33
6 files changed
+352 -7

No files matched your search

+7 -3
View File
@@ -93,9 +93,13 @@ test.each(["http://tauri.localhost", "tauri://localhost"])(
const pdfjsDir = path.dirname(reactPdfRequire.resolve("pdfjs-dist/package.json"));
const installed = JSON.parse(await readFile(path.join(pdfjsDir, "package.json"), "utf8"));
expect(version).toBe(installed.version);
expect(Buffer.from(worker.source)).toEqual(
await readFile(path.join(pdfjsDir, "build/pdf.worker.min.mjs")),
);
// The worker is bundled with the polyfills older WebKit needs, ahead of PDF.js itself.
const source = Buffer.from(worker.source).toString("utf8");
const escapedVersion = installed.version.replaceAll(".", "\\.");
expect(source).toMatch(new RegExp(`["'\`]${escapedVersion}["'\`]`));
const polyfillAt = source.indexOf("getOrInsertComputed callback is not a function");
expect(polyfillAt).toBeGreaterThanOrEqual(0);
expect(polyfillAt).toBeLessThan(source.indexOf("pdfjs_internal_editor_"));
},
30_000,
);