Commit Graph

18054 Commits

Author SHA1 Message Date
Tim van der Meij
2bae8af96a
Fix intermittent problems on Windows in the XFA search integration test
The current test fails intermittently only on Windows for unknown
reasons: the code is correct and on Linux it always passes. However, we
have already spent quite a lot of time on this test, so rather than
spending even more time on it I figured we should look at what behavior
the test is trying to check and find an alternative way to do it that
can't trigger this intermittent issue anymore.

This commit changes the test to use a term that only exists once in the
entire document so we cannot accidentally highlight another match
anymore. This doesn't change anything about the behavior that this test
aims to check: we still test searching in the XFA layer, we still test
that the original term is matched case-insensitively and we still test
that that match is actually highlighted. Note that the only objective of
the test is confirming that the search functionality covers the XFA
layer, so the exact phrase/match is not the interesting bit.
2023-10-15 15:02:41 +02:00
Tim van der Meij
a9a1195582
Merge pull request #17123 from Snuffleupagus/eslint-globals
Update the ESLint `globals` list (PR 17055 follow-up)
2023-10-15 12:06:54 +02:00
Jonas Jenwald
93f24dd5d7 Remove the ESLint "amd" environment (PR 17055 follow-up)
Please see https://eslint.org/docs/latest/use/configure/language-options#specifying-environments
2023-10-15 11:50:57 +02:00
Jonas Jenwald
d5acbbccd3 Update the ESLint globals list (PR 17055 follow-up)
Given that we only use standard `import`/`export` statements now, after recent PRs, the "exports" global is unused.
Instead we add "__non_webpack_import__" to the `globals` to avoid having to sprinkle disable statements throughout the code.

Finally, the way that `globals` are defined has changed in ESLint and we should thus explicitly specify them as "readonly"; please find additional details at https://eslint.org/docs/latest/use/configure/language-options#specifying-globals
2023-10-15 11:38:10 +02:00
Tim van der Meij
76bf3da4b1
Merge pull request #17122 from timvandermeij/autoprint
Remove Escape key press from the `autoprint` integration test, and tweak the protocol timeout configuration for Puppeteer
2023-10-15 11:29:11 +02:00
Tim van der Meij
0c763d6c5a
Tweak the protocol timeout configuration for Puppeteer
The previous change that set the timeout had effect because we have seen
quite a few protocol timeouts now correctly being raised in the context
of the active test, however we have also still seen a handful of cases
where this wasn't the case and the one second difference turned out to
be too low (likely because the operation was started slightly after one
second into the test run). We therefore tweak the value to be 75% of the
Jasmine timeout. This should be enough to catch operations that happen
later on in the test run, and if a single operation takes that long any
hope for success is already gone anyway.
2023-10-14 18:20:22 +02:00
Tim van der Meij
48e41617f5
Remove Escape key press from the autoprint integration test
It's not necessary because we have configured silent printing for
Firefox and Chrome in the browser arguments we pass in `test.mjs`. This
means that the print dialog is not even shown at all or disappears
automatically once printing is done, so the Escape key press serves no
purpose. Since it has been shown to time out, likely because the page
loses focus during printing, and because the page itself doesn't know
when the printing dialog is shown and we therefore can't possibly do the
key press at the right time anyway, this commit gets rid of it to
stabilize the test.
2023-10-14 18:17:29 +02:00
Tim van der Meij
5c45dfa0ae
Merge pull request #17119 from timvandermeij/updates
Update translations/dependencies to the most recent versions and fix dependency vulnerabilities
2023-10-14 14:36:25 +02:00
Tim van der Meij
d53e166538
Merge pull request #17120 from timvandermeij/code-scanning-alerts
Remove obsolete `src/shared/{cffStandardStrings,fonts_utils}.js` files
2023-10-14 14:26:35 +02:00
Tim van der Meij
58e4fcdc6f
Remove obsolete src/shared/{cffStandardStrings,fonts_utils}.js files
Those files only contain old debugging code that is not used/imported
anywhere anymore, which is generating code scanning alerts. Moreover,
they rely on globals/platform-specific code and don't import/export
logic properly.
2023-10-14 14:07:49 +02:00
Tim van der Meij
4c17f99fab
Fix dependency vulnerabilities with npm audit fix 2023-10-14 13:50:24 +02:00
Tim van der Meij
e1307fdba8
Update dependencies to the most recent versions 2023-10-14 13:50:19 +02:00
Tim van der Meij
e79bb25086
Update translations to the most recent versions 2023-10-14 13:50:12 +02:00
Tim van der Meij
23b8dbb730
Merge pull request #17117 from Snuffleupagus/eslint-import-no-commonjs
Enable the `import/no-commonjs` ESLint plugin rule
2023-10-14 13:11:37 +02:00
Jonas Jenwald
d53093045a Enable the import/no-commonjs ESLint plugin rule
Given the amount of work put into removing `require`-calls from the code-base, let's ensure that new ones aren't accidentally added in the future.

Note that we still have a couple of files where `require` is being used, in particular:
 - The Node.js examples, however those will be updated to use `import` in PR 17081.
 - The Webpack examples, and related support files, however I unfortunately don't know enough about Webpack to be able to update those. (Hopefully users of that code will help out here, once version `4` is released.)
 - The `statcmp`-tool, since *some* of those `require`-calls cannot be converted to `import` without other code changes (and that file is only used during benchmarking).

Please find additional details at https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-commonjs.md
2023-10-14 12:49:17 +02:00
Tim van der Meij
57866cd31b
Merge pull request #14743 from Snuffleupagus/native-import-maps
Use native `import maps` in development mode
2023-10-14 12:07:39 +02:00
Tim van der Meij
7dfe08a0ee
Merge pull request #17098 from Snuffleupagus/createCDNWrapper-import
Tweak `PDFWorkerUtil.createCDNWrapper` to account for JavaScript modules (PR 17055 follow-up)
2023-10-14 12:05:46 +02:00
Jonas Jenwald
af9a7b0003 Tweak PDFWorkerUtil.createCDNWrapper to account for JavaScript modules (PR 17055 follow-up) 2023-10-14 11:34:40 +02:00
Jonas Jenwald
5e986cb514 Use native import maps in development mode
This patch seem to work fine locally now, and `mozregression` points to it being fixed in bug https://bugzilla.mozilla.org/show_bug.cgi?id=1803984 which landed in Firefox 116.

By using the native `import maps` functionality, we can remove a development dependency. Please find the specification at https://wicg.github.io/import-maps/
2023-10-13 20:35:34 +02:00
Jonas Jenwald
36c3c0a4c1
Merge pull request #17114 from Snuffleupagus/lib-modules
Output JavaScript modules for the `LIB` build-target (PR 17055 follow-up)
2023-10-13 20:33:35 +02:00
Jonas Jenwald
38245500fd Output JavaScript modules for the LIB build-target (PR 17055 follow-up)
This *finally* allows us to mark the entire PDF.js library as a "module", which should thus conclude the (multi-year) effort to re-factor and improve how we import files/resources in the code-base.

This also means that the `gulp ci-test` target, which is what's run in GitHub Actions, now uses JavaScript modules since that's supported in modern Node.js versions.
2023-10-13 18:54:33 +02:00
Jonas Jenwald
96258449e3
Merge pull request #17112 from Snuffleupagus/integration-test-modules
Convert the `integration` test-files to JavaScript modules
2023-10-13 18:53:52 +02:00
calixteman
4ac44b9d6d
Merge pull request #17113 from calixteman/bug1858700
Remove useless chrome.properties file (bug 1858700)
2023-10-12 17:19:57 +02:00
Calixte Denizet
cabda362c6 Remove useless chrome.properties file (bug 1858700) 2023-10-12 16:32:44 +02:00
Jonas Jenwald
9878d058fe Convert the integration test-files to JavaScript modules 2023-10-12 13:18:20 +02:00
Jonas Jenwald
33456d3704 Rename the integration test-files, in preparation for converting them to modules
This is done separately to ensure that Git is able to track the history correctly.
2023-10-12 13:17:56 +02:00
Jonas Jenwald
158ab5bf37
Merge pull request #17106 from Snuffleupagus/bug-1854145
Don't store page-level data, in the API, after cleanup has run (bug 1854145)
2023-10-12 10:47:23 +02:00
Jonas Jenwald
0238cf134d Don't store page-level data, in the API, after cleanup has run (bug 1854145)
For large/complex images it's possible that the image-data arrives in the API *after* the page has been scrolled out-of-view and thus been cleaned-up. In this case we obviously shouldn't cache such page-level data, since it'll first of all be unused and secondly can increase memory usage *a lot*.
Also, ensure that we *immediately* release any `ImageBitmap` data in this case to help reclaim memory faster.
2023-10-11 11:51:42 +02:00
Jonas Jenwald
2c39a739f5
Merge pull request #17105 from Snuffleupagus/interactive-examples-update
Update the "Interactive examples" links (PR 17055 follow-up)
2023-10-10 09:53:14 +02:00
Jonas Jenwald
734caab747 Update the "Interactive examples" links (PR 17055 follow-up)
The examples themselves were updated to account for JavaScript modules, which didn't require changing the actual URLs.
However, since it seems that JSFiddle doesn't support JavaScript modules in its separate "JavaScript" editing-area we need to change how we embed the examples to avoid showing a blank "JavaScript"-tab.
2023-10-10 09:41:01 +02:00
calixteman
2c87c4854a
Merge pull request #17073 from calixteman/debug_subst_font
[Debugger] Add some info about substitution font
2023-10-09 14:34:58 +02:00
Calixte Denizet
7851c0da8d [Debugger] Add some info about substitution font
When pdfBug is true, the substitution font is used in the text layer in order
to be able to know what is the font really used thanks to the devtools.
And to be sure that fonts are loaded, the font cache isn't cleaned up when
the debugger is active.
2023-10-09 12:06:33 +02:00
Jonas Jenwald
b4cd8ad215
Merge pull request #17095 from timvandermeij/protocol-timeout
Fix the protocol timeout configuration for Puppeteer
2023-10-09 09:43:51 +02:00
Tim van der Meij
ede65e11c6
Fix the protocol timeout configuration for Puppeteer
The default protocol timeout is 180 seconds according to the
documentation at https://pptr.dev/api/puppeteer.browserconnectoptions,
but the Jasmine timeout we configure in the individual boot files is 30
seconds. The consequence of this is that if a protocol (CDP) error
occurs after 30 seconds Jasmine will fail the test, but the actual
protocol error from Puppeteer is raised much later in the context of
another test, which causes unrelated failures or tracebacks.

This commit fixes the problem by configuring Puppeteer to always use a
lower protocol timeout than the Jasmine timeout so that protocol errors
are always raised in the context of the test that actually triggered it.
2023-10-08 18:22:02 +02:00
Jonas Jenwald
d64f223d03
Merge pull request #17094 from Snuffleupagus/debugger-module
Rename `web/debugger.js` since it's actually a JavaScript module (PR 17055 follow-up)
2023-10-08 13:56:37 +02:00
Jonas Jenwald
6ac3da0d1f Rename web/debugger.js since it's actually a JavaScript module (PR 17055 follow-up)
It's been loaded as a JavaScript module for a long time, and given that the file is bundled as-is (without building) it seems reasonable to just change the file extension now.
2023-10-08 13:16:42 +02:00
Jonas Jenwald
f04967017f
Merge pull request #17093 from mozilla/dependabot/npm_and_yarn/postcss-8.4.31
Bump postcss from 8.4.30 to 8.4.31
2023-10-08 10:08:49 +02:00
dependabot[bot]
67b5c69d15
Bump postcss from 8.4.30 to 8.4.31
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.30 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.30...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-08 04:06:58 +00:00
Tim van der Meij
60a458de29
Merge pull request #17090 from timvandermeij/autoprint-intermittent
Activate the selector check for the `autoprint` integration test as soon as possible
2023-10-07 20:34:16 +02:00
Tim van der Meij
2c1d95b153
Activate the selector check for the autoprint integration test as soon as possible
The Windows bot is usually slower than the Linux bot, and therefore
text layer rendering is as well. However, the `autoprint` test awaited
text layer rendering to complete before activating the selector check,
which makes it timing-sensitive and causes it to never resolve because
the page is already printed (and the printed page div removed) by then.

This commit should fix the issue by activating the selector check as
soon as possible, namely as soon as the viewer appears, which should
ensure we're always registering the selector check in time because we're
doing it even before rendering is starting.
2023-10-07 19:27:34 +02:00
Tim van der Meij
f2c9b64cb2
Merge pull request #17086 from Snuffleupagus/rm-structuredClone-polyfill
[api-minor] Stop polyfilling `structuredClone` in legacy builds
2023-10-07 18:26:28 +02:00
Jonas Jenwald
8bd3cc0313 [api-minor] Stop polyfilling structuredClone in legacy builds
Comparing the currently supported browsers/environments, see [the FAQ](https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support) and the [MDN compatibility data](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone#browser_compatibility), the `structuredClone` polyfill is *only* needed in Google Chrome versions < 98. Because of some limitations in the core-js polyfill we're currently forced to special-case the `transfer` handling to prevent bugs, and it'd be nice to avoid that.

Note that `structuredClone`, with transfers, is only used in two spots:
 - The `LoopbackPort` class, which is only used with fake workers. Given that fake workers should *never* be used in browsers, breaking that edge-case in older Google Chrome versions seem fine.
 - The `AnnotationStorage` class, when Stamp-annotations have been added to the document. Given that Google Chrome isn't the main focus of development, breaking *part* of the editing-functionality in older Google Chrome versions should hopefully be acceptable.
2023-10-07 16:52:47 +02:00
Jonas Jenwald
e6c3257175
Merge pull request #17080 from Snuffleupagus/scripting-module
Output `pdf.scripting.js` as a JavaScript module (PR 17055 follow-up)
2023-10-07 16:09:39 +02:00
Jonas Jenwald
4b489cd4e6 Output pdf.scripting.js as a JavaScript module (PR 17055 follow-up)
To avoid problems with `export` statements in the QuickJS Javascript Engine, we can work-around that by *explicitly* exposing `pdfjsScripting` globally instead.
2023-10-07 15:27:26 +02:00
Tim van der Meij
bab4c7f617
Merge pull request #17055 from Snuffleupagus/output-modules
[api-major] Output JavaScript modules in the builds (issue 10317)
2023-10-07 15:02:59 +02:00
Tim van der Meij
89d8c639fa
Merge pull request #17077 from Snuffleupagus/css-rm-unneeded-alpha
Remove unnecessary alpha-value from CSS `rgb` colors
2023-10-07 12:33:48 +02:00
Jonas Jenwald
927e50f5d4 [api-major] Output JavaScript modules in the builds (issue 10317)
At this point in time all browsers, and also Node.js, support standard `import`/`export` statements and we can now finally consider outputting modern JavaScript modules in the builds.[1]

In order for this to work we can *only* use proper `import`/`export` statements throughout the main code-base, and (as expected) our Node.js support made this much more complicated since both the official builds and the GitHub Actions-based tests must keep working.[2]
One remaining issue is that the `pdf.scripting.js` file cannot be built as a JavaScript module, since doing so breaks PDF scripting.

Note that my initial goal was to try and split these changes into a couple of commits, however that unfortunately didn't really work since it turned out to be difficult for smaller patches to work correctly and pass (all) tests that way.[3]
This is a classic case of every change requiring a couple of other changes, with each of those changes requiring further changes in turn and the size/scope quickly increasing as a result.

One possible "issue" with these changes is that we'll now only output JavaScript modules in the builds, which could perhaps be a problem with older tools. However it unfortunately seems far too complicated/time-consuming for us to attempt to support both the old and modern module formats, hence the alternative would be to do "nothing" here and just keep our "old" builds.[4]

---
[1] The final blocker was module support in workers in Firefox, which was implemented in Firefox 114; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility

[2] It's probably possible to further improve/simplify especially the Node.js-specific code, but it does appear to work as-is.

[3] Having partially "broken" patches, that fail tests, as part of the commit history is *really not* a good idea in general.

[4] Outputting JavaScript modules was first requested almost five years ago, see issue 10317, and nowadays there *should* be much better support for JavaScript modules in various tools.
2023-10-07 09:31:08 +02:00
Jonas Jenwald
0a970ee443 [api-major] Remove the fallbackWorkerSrc functionality in browsers
The user should *always* provide a correct `GlobalWorkerOptions.workerSrc` value when using the PDF.js library in browser environments. Note that the fallback:
 - Has been deprecated ever since PR 11418, first released in version `2.4.456` over three years ago.
 - Was always a best-effort solution, with no guarantees that it'd actually work correctly.
 - With upcoming changes, w.r.t. outputting JavaScript modules, it'd now be more diffiult to determine the correct value.
2023-10-06 12:12:30 +02:00
Jonas Jenwald
8158628a90 [api-minor] Stop building a minified default viewer
The minified default viewer has never been distributed in either official releases or through pdfjs-dist, which means that it's most likely unused, and it's has never been tested nor actively maintained.
2023-10-06 12:12:30 +02:00
calixteman
905ad1fe68
Merge pull request #16761 from calixteman/editor_add_new_with_keyboard
[Editor] Add the possibility to create a new editor in using the keyboard (bug 1853424)
2023-10-06 11:44:07 +02:00