Truly independent web browser
Meta: Handle missing PDF.js decoder resources
sideshowbarker4ef7f7fe2495
diff --git a/Documentation/BuildInstructionsLadybird.md b/Documentation/BuildInstructionsLadybird.mdindex 10c0acab8f6..06ad197994e 100644--- a/Documentation/BuildInstructionsLadybird.md+++ b/Documentation/BuildInstructionsLadybird.md@@ -289,8 +289,9 @@ For other builds, use the version pinned in `vcpkg.json` and apply[`0001-ladybird-embed.patch`](../Meta/CMake/vcpkg/overlay-ports/pdfjs/0001-ladybird-embed.patch).Install the patched distribution under `<prefix>/share/pdfjs` and add that prefix to `CMAKE_PREFIX_PATH`,or set `PDFJS_DIR` directly to the directory containing `build/pdf.mjs` and `web/`.-If PDF.js is unavailable, PDF-dependent tests are skipped. Missing decoder files in a build configured-with PDF.js still cause the rendering test to fail.+If PDF.js is unavailable, PDF-dependent tests are skipped. In a build configured with PDF.js, the JBIG2+test checks that its Wasm decoder is present and valid, and renders an image with both Wasm enabled and+the JavaScript fallback forced.### Custom CMake build directorydiff --git a/Tests/LibWeb/Text/expected/PDF/jbig2-image.txt b/Tests/LibWeb/Text/expected/PDF/jbig2-image.txtindex e36a68587ac..b402cb0ed7d 100644--- a/Tests/LibWeb/Text/expected/PDF/jbig2-image.txt+++ b/Tests/LibWeb/Text/expected/PDF/jbig2-image.txt@@ -1,2 +1,3 @@+Valid Wasm decoder: trueWasm enabled: 64 black pixelsJavaScript fallback: 64 black pixelsdiff --git a/Tests/LibWeb/Text/input/PDF/jbig2-image.html b/Tests/LibWeb/Text/input/PDF/jbig2-image.htmlindex 0ba27164560..8e85c0e90c7 100644--- a/Tests/LibWeb/Text/input/PDF/jbig2-image.html+++ b/Tests/LibWeb/Text/input/PDF/jbig2-image.html@@ -2,6 +2,8 @@<script src="../include.js"></script><script>asyncTest(async done => {+ const wasm = await fetch("resource://ladybird/pdfjs/web/wasm/jbig2.wasm");+ println(`Valid Wasm decoder: ${wasm.ok && WebAssembly.validate(await wasm.arrayBuffer())}`);const { getDocument, GlobalWorkerOptions } = await import("resource://ladybird/pdfjs/build/pdf.mjs");GlobalWorkerOptions.workerSrc = "resource://ladybird/pdfjs/build/pdf.worker.mjs";// A single-page PDF containing an 8x8 black JBIG2 image with MMR-encoded pixels.diff --git a/UI/cmake/ResourceFiles.cmake b/UI/cmake/ResourceFiles.cmakeindex ee9cf9fe8a3..e820f734cc6 100644--- a/UI/cmake/ResourceFiles.cmake+++ b/UI/cmake/ResourceFiles.cmake@@ -112,6 +112,10 @@ function(copy_resource_set subdir)cmake_parse_arguments(PARSE_ARGV 1 "COPY" "" "TARGET;DESTINATION" "RESOURCES")set(inputs ${COPY_RESOURCES})+ if (NOT inputs)+ return()+ endif()+if (APPLE)target_sources(${COPY_TARGET} PRIVATE ${inputs})set_source_files_properties(${inputs} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/${subdir}")