1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 07:08:08 +02:00
pdf.js/test
Jonas Jenwald 2643570364 [api-minor] Re-factor how Node.js packages/polyfills are loaded (issue 17245)
*Please note:* This removes top level await from the GENERIC builds of the PDF.js library.

Despite top level await being supported in all modern browsers/environments, note [the MDN compatibility data](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#browser_compatibility), it seems that many frameworks and build-tools unfortunately have trouble with it.
Hence, in order to reduce the influx of support requests regarding top level await it thus seems that we'll have to try and fix this.

Given that top level await is only needed for Node.js environments, to load packages/polyfills, we re-factor things to limit the asynchronicity to that environment.
The "best" solution, with the least likelihood of causing future problems, would probably be to await the load of Node.js packages/polyfills e.g. at the top of the `getDocument`-function. Unfortunately that doesn't work though, since that's a *synchronous* function that we cannot change without breaking "the world".

Hence we instead await the load of Node.js packages/polyfills together with the `PDFWorker` initialization, since that's the *first point* of asynchronicity during initialization/loading of a PDF document. The reason that this works is that the Node.js packages/polyfills are only needed during fetching of the PDF document respectively during rendering, neither of which can happen *until* the worker has been initialized.
Hopefully this won't cause any future problems, since looking at the history of the PDF.js project I don't believe that we've (thus far) ever needed a Node.js dependency at an earlier point.
This new pattern for accessing Node.js packages/polyfills will also require some care during development *and* importantly reviewing, to ensure that no new top level await is added in the main code-base.
2024-05-06 23:20:03 +02:00
..
chromium Enable the import/no-commonjs ESLint plugin rule 2023-10-14 12:49:17 +02:00
font Convert the TTX driver code to promises 2024-04-05 13:34:54 +02:00
fuzz [api-minor] Remove the image-related error message prefixes 2024-04-20 12:51:45 +02:00
images [Editor] Support svg images in the stamp annotation 2023-07-07 15:59:13 +02:00
integration Merge pull request #18041 from timvandermeij/integration-tests-timeout-freetext 2024-05-06 20:00:03 +02:00
pdfs Merge pull request #18035 from calixteman/rm_max_group_size 2024-05-01 20:14:28 +02:00
resources Enable the declaration-block-no-redundant-longhand-properties Stylelint rule 2023-03-25 10:08:27 +01:00
stats Enable the import/no-commonjs ESLint plugin rule 2023-10-14 12:49:17 +02:00
types Format json files in using prettier 2024-01-16 19:40:25 +01:00
unit [api-minor] Re-factor how Node.js packages/polyfills are loaded (issue 17245) 2024-05-06 23:20:03 +02:00
.eslintrc Prevent duplicate names in unit/integration tests 2024-02-11 11:45:09 +01:00
.gitignore Ignore test snapshots directory. 2013-03-15 11:24:08 -07:00
add_test.mjs [ESM] Convert *most* of test-folder to use standard modules 2023-07-08 13:13:04 +02:00
annotation_layer_builder_overrides.css Use CSS nesting in the annotationLayer 2023-10-27 18:46:47 +02:00
downloadutils.mjs Modernize the rewriteWebArchiveUrl test helper function 2023-12-17 21:53:50 +01:00
draw_layer_test.css [Editor] Add a way to extract the outlines of a union of rectangles 2023-11-20 18:45:19 +01:00
driver.js [api-minor] Replace the PromiseCapability with Promise.withResolvers() 2024-04-01 11:42:37 +02:00
integration-boot.mjs When zooming the scrollbar can disappear and then no scrollend is triggered 2024-03-15 15:37:06 +01:00
test.mjs Remove the rimraf dependency in favor of the built-in Node.js fs.rmSync in the test folder 2024-04-14 16:41:59 +02:00
test_manifest.json Remove the limit used to decided if a group canvas must be upscaled or not 2024-05-01 18:01:54 +02:00
test_slave.html [api-minor] Move to Fluent for the localization (bug 1858715) 2023-10-19 11:20:41 +02:00
testutils.mjs Remove the rimraf dependency in favor of the built-in Node.js fs.rmSync in the test folder 2024-04-14 16:41:59 +02:00
text_layer_test.css Use CSS nesting in the textLayer 2023-10-27 17:38:01 +02:00
webserver.mjs Improve the webserver's constructor 2024-02-17 16:22:10 +01:00
xfa_layer_builder_overrides.css Remove unnecessary alpha-value from CSS rgb colors 2023-10-06 09:50:03 +02:00