Commit Graph

13312 Commits

Author SHA1 Message Date
Brendan Dahl
3c603fb28b
Merge pull request #12635 from calixteman/js_display_evts
JS -- Send events to the sandbox from annotation layer
2020-12-15 21:24:55 -08:00
Tim van der Meij
0655f50810
Merge pull request #12737 from Snuffleupagus/Safari-10
Change the minimum "supported" version of the Safari-browser to Safari 10
2020-12-15 22:58:23 +01:00
Calixte Denizet
6502ae889d JS -- Send events to the sandbox from annotation layer 2020-12-15 16:28:47 +01:00
Jonas Jenwald
499d865ebf Change the minimum "supported" version of the Safari-browser to Safari 10
According to https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support, Safari 9 is still listed as "mostly supported".

Given that the *last* release from the Safari 9 branch was on [September 1, 2016](https://en.wikipedia.org/wiki/Safari_version_history#Safari_9), it's questionable at least to me if it actually makes sense for us to even pretend to "support" such an old browser.
Especially when the *first* release from the Safari 10 branch was on [September 20, 2016](https://en.wikipedia.org/wiki/Safari_version_history#Safari_10), which is now over four years ago.

Based on the MDN compatibility data, this patch thus removes the following polyfills:
 - `TypedArray.prototype.slice()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice#Browser_compatibility
 - `String.prototype.codePointAt()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt#Browser_compatibility
 - `String.fromCodePoint()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint#Browser_compatibility
2020-12-15 09:49:32 +01:00
Tim van der Meij
640a08444c
Merge pull request #12724 from calixteman/follow-up-12707
Follow-up of #12707: Add an integration test for checkboxes as radio …
2020-12-15 00:04:10 +01:00
Calixte Denizet
c6c9cc96bf Follow-up of #12707: Add an integration test for checkboxes as radio buttons
* Integration tests: Add a function to load a pdf and wait for a selected element
 * Integration tests: Add a function to close all the open pages
2020-12-15 00:00:04 +01:00
Tim van der Meij
a825b9195b
Merge pull request #12700 from calixteman/12699
Fix automatic zoom under spread mode
2020-12-14 23:39:48 +01:00
Tim van der Meij
5354a97025
Merge pull request #12736 from Snuffleupagus/rm-IE-polyfills
Remove the remaining IE 11 polyfills
2020-12-14 23:36:36 +01:00
Calixte Denizet
785487c558 Fix automatic zoom under spread mode (#12699)
Reset scale when update spread mode
2020-12-14 17:57:00 +01:00
Jonas Jenwald
a2874b380a Remove the remaining IE 11 polyfills
We really ought to settle on the *lowest* supported versions of various browsers[1], since that should allow even more clean-up, but given that https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support *explicitly* lists IE 11 as unsupported after PDF.js version `2.6.347` there's a number of polyfills that are no longer needed.

Based on the MDN compatibility data, this patch thus removes the following polyfills:
 - `String.prototype.startsWith()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith#Browser_compatibility

 - `String.prototype.endsWith()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith#Browser_compatibility

  - `String.prototype.includes()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Browser_compatibility

 - `Array.prototype.includes()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes#Browser_compatibility

  - `Array.from()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Browser_compatibility

  - `Object.assign()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Browser_compatibility

  - `Math.log2()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2#Browser_compatibility

  - `Number.isNaN()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN#Browser_compatibility

  - `Number.isInteger()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger#Browser_compatibility

  - `Map.prototype.entries()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries#Browser_compatibility

  - `Set.prototype.entries()`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries#Browser_compatibility

  - `WeakMap`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap#Browser_compatibility

  - `WeakSet`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet#Browser_compatibility

  - `Symbol`, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility

Finally, this patch also attempts to update the compatibility information for the remaining polyfills.

---
[1] For example: It's questionable if Safari 9 should be listed as supported, given that the last release from that branch was in 2016.
2020-12-14 14:31:25 +01:00
Tim van der Meij
959dc379ee
Merge pull request #12733 from Snuffleupagus/bug-1292316-test
Add a test-case for bug 1292316
2020-12-13 13:38:40 +01:00
Tim van der Meij
61d9269201
Merge pull request #12734 from Snuffleupagus/update-packages
Update packages and translations
2020-12-13 13:36:36 +01:00
Jonas Jenwald
3655777db7 Enable the ESLint no-unsafe-optional-chaining rule
Given that we're using optional chaining in the code-base, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining, it can't hurt to add this ESLint rule to help catch one possible source of bugs when using optional chaining expressions.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-unsafe-optional-chaining
2020-12-13 11:46:32 +01:00
Jonas Jenwald
ad91972eb2 Update l10n files 2020-12-13 11:43:49 +01:00
Jonas Jenwald
e09f2a462d Update npm packages 2020-12-13 11:38:37 +01:00
Tim van der Meij
e3caa29239
Merge pull request #12732 from Snuffleupagus/scripting_spec-fail
Call `done.fail` correctly in the `scripting_spec.js` unit-tests
2020-12-12 13:33:28 +01:00
Jonas Jenwald
7f89be5dbf Add a test-case for bug 1292316
It appears that the PDF document in [bug 1292316](https://bugzilla.mozilla.org/show_bug.cgi?id=1292316) now renders "correctly"[1] when compared to e.g. Adobe Reader and PDFium. Most likely this bug was fixed by a *somewhat* recent patch, or patches, to the `XRef.indexObjects` method.

Before just closing [bug 1292316](https://bugzilla.mozilla.org/show_bug.cgi?id=1292316) as WFM, I figured that it probably can't hurt to add it as a new test-case to avoid accidentally regressing this document in the future.

---
[1] Given that the XRef table is corrupt, and that we're forced to recover, there's generally speaking probably some question as to what actually constitutes "correct" in this case.
2020-12-12 13:24:31 +01:00
Jonas Jenwald
9adb225a7d Call done.fail correctly in the scripting_spec.js unit-tests
The `done.fail` method should *always* be called with a reason, to ensure that any errors are propagated as intended to the test results.
2020-12-12 12:41:47 +01:00
Tim van der Meij
d1848f5022
Merge pull request #12725 from brendandahl/remeasure-std
Use widths defined by font for standard fonts.
2020-12-11 20:36:19 +01:00
Tim van der Meij
217a00ee3a
Merge pull request #12718 from Snuffleupagus/issue-12705
Ignore color-operators in Type3 glyphs beginning with a `d1` operator (issue 12705)
2020-12-11 20:19:49 +01:00
Tim van der Meij
8beb62e397
Merge pull request #12728 from Snuffleupagus/gulpfile-move-timezone
[gulpfile.js] Move the time-zone hack to the `testing-pre` task, such that *all* tests work regardless of the current time-zone
2020-12-11 20:08:52 +01:00
Jonas Jenwald
67e5db75d8 Ignore color-operators in Type3 glyphs beginning with a d1 operator (issue 12705)
Please refer to the PDF specification at https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G8.1977497 and https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G7.3998470

This patch removes the color-operators in the evaluator, since that should be more efficient than doing it repeatedly in the main-thread when rendering the Type3 glyphs.
2020-12-11 15:49:13 +01:00
Jonas Jenwald
20557d8199 [gulpfile.js] Move the time-zone hack to the testing-pre task, such that *all* tests work regardless of the current time-zone
Currently only the `gulp unittest` task actually set the time-zone, which means that locally I'm now getting failures with e.g. `gulp test`.

*Please note:* I firmly believe that the unit-tests in question should be re-written, since even with this patch applied there's failures when running http://localhost:8888/test/unit/unit_test.html directly in a browser.
2020-12-11 12:17:16 +01:00
Brendan Dahl
45d9ab6e45 Use widths defined by font for standard fonts.
There doesn't seem to be anything definitive about this in
the spec, but from experimenting, it seems acrobat lets
PDFs override the widths of the standard fonts.
2020-12-10 15:30:39 -08:00
Tim van der Meij
00b4f86db3
Merge pull request #12717 from Snuffleupagus/issue-12714
Ensure that the /Annots-entry, on /Page-instances, is actually an Array (issue 12714)
2020-12-10 23:06:59 +01:00
Tim van der Meij
954ac3d944
Merge pull request #12719 from calixteman/emailvalidate
JS -- add function eMailValidate used to validate an email address
2020-12-10 22:19:37 +01:00
Tim van der Meij
e53ae01330
Merge pull request #12723 from mozilla/dependabot/npm_and_yarn/ini-1.3.7
Bump ini from 1.3.5 to 1.3.7
2020-12-10 22:08:53 +01:00
Brendan Dahl
31ea30ab25
Merge pull request #12668 from calixteman/interaction
Add some integration tests using puppeteer
2020-12-10 12:52:03 -08:00
Calixte Denizet
f94269c0d1 JS -- add function eMailValidate used to validate an email address 2020-12-10 21:51:37 +01:00
dependabot[bot]
7a0d89b3c0
Bump ini from 1.3.5 to 1.3.7
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.7)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-10 20:48:56 +00:00
Tim van der Meij
7097114e0c
Merge pull request #12720 from calixteman/fix_co
Be sure that CalculationOrder is either null or a non-empty array
2020-12-10 21:43:35 +01:00
Tim van der Meij
85ab53fef0
Merge pull request #12722 from calixteman/printf
JS -- fix printd issue with negative number
2020-12-10 21:41:11 +01:00
Calixte Denizet
5b42ac364a Add some integration tests using puppeteer and Jasmine
* run with `gulp integrationtest`
2020-12-10 20:55:15 +01:00
Calixte Denizet
c7b09b8efc JS -- fix printd issue with negative number 2020-12-10 18:43:04 +01:00
Calixte Denizet
25bf504ff5 Be sure that CalculationOrder is either null or a non-empty array 2020-12-10 16:02:11 +01:00
Jonas Jenwald
796a0d3155 Ensure that the /Annots-entry, on /Page-instances, is actually an Array (issue 12714)
In the referenced PDF document, the second and third page has *corrupt* /Annots-entries which contain /Dict-data rather than the intended Arrays.
2020-12-10 11:42:00 +01:00
Tim van der Meij
93b3ba2abb
Merge pull request #12712 from Snuffleupagus/issue-12704
Attempt to handle collapsed outline items, in the default viewer, according to the specification (issue 12704, PR 10890 follow-up)
2020-12-09 23:43:07 +01:00
Tim van der Meij
f48cfba945
Merge pull request #12707 from calixteman/radio_check
Checkboxes with the same name must behave like a radio buttons group
2020-12-09 23:29:03 +01:00
Tim van der Meij
0629a8f553
Merge pull request #12703 from Snuffleupagus/GenericScripting-rm-scriptElement
Ensure that the `pdf.sandbox.js` is removed from the DOM on destroy, and unbreak the Chromium-extension (PR 12695 follow-up)
2020-12-09 23:09:06 +01:00
Jonas Jenwald
6218b9a512 Re-factor/re-name the scripting getter, on the externalServices-implementations, to a createScripting method
Given that the GENERIC default viewer supports opening more than one document, and that a unique scripting-instance is now used for each document, the changes made in this patch seem appropriate.
2020-12-09 22:15:50 +01:00
Jonas Jenwald
a7230eb033 Move the GenericScripting class to its own file, such that it can be used in the Chromium-extension
While it's not entirely clear to me that it's ultimately desirable to use the `pdf.sandbox.js` in the Chromium-extension, given that the MOZCENTRAL-build uses `pdf.scripting.js` directly in a *custom* sandbox, the current state isn't that great since setting `enableScripting = true` with the Chromium-extension will currently fail completely.

Hence this patch, which should at least unbreak things for now.
2020-12-09 22:15:50 +01:00
Jonas Jenwald
6c807f3f86 Move destroying of the scripting-instance from PDFViewerApplication.close and into its own helper method
Since the `close` method has become quite large, this small re-factoring shouldn't hurt (and may also be useful with future changes to the `_initializeJavaScript` method).
2020-12-09 22:15:50 +01:00
Jonas Jenwald
8d72981c18 Move cancelling of idleCallbacks from PDFViewerApplication.close and into its own helper method
Since the `close` method has become quite large, this small re-factoring shouldn't hurt.
2020-12-09 22:15:50 +01:00
Jonas Jenwald
7ce6634c51 Ensure that the pdf.sandbox.js scriptElement is also removed from the DOM (PR 12695 follow-up)
I completely missed this previously, but we obviously should remove the scriptElement as well to *really* clean-up everything properly.

Given that there's multiple existing usages of `loadScript` in the code-base, the safest/quickest solution seemed to be to have call-sites opt-in to remove the scriptElement using a new parameter.
2020-12-09 22:15:47 +01:00
Jonas Jenwald
09f79ffa92 Attempt to handle collapsed outline items, in the default viewer, according to the specification (issue 12704, PR 10890 follow-up)
This patch *attempts* to actually implement what's described for the `Count`-entry in the PDF specification, see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.2095911, which I mostly ignored back in PR 10890 since it seemed unnecessarily complicated[1].

Besides issue 12704, I've also tested a couple of other documents (e.g. the PDF specification) and these changes don't *seem* to break anything else; additional testing would be helpful though!

---
[1] At the time, all PDF documents that I tested worked even with a very simple approach and I thus hoped that it'd would suffice.
2020-12-09 20:48:36 +01:00
Calixte Denizet
1fcffe8034 Checkboxes with the same name must behave like a radio buttons group
* aims to fix issue #12706
2020-12-08 15:53:19 +01:00
Brendan Dahl
b194c820bf
Merge pull request #12634 from calixteman/aform
JS -- Add aform functions
2020-12-07 11:35:23 -08:00
Calixte Denizet
0f899edfc8 JS -- Add aform functions
* These functions aren't in the PDF specs but seems to be widely used
 * So the specs for these functions are:
   * http://www.sfu.ca/~wcs/ForGraham/Aladdin%20stuff/Acrobat%20Reader%205.0/Contents/MacOS/JavaScripts/AForm.js
   * pdfium source code
2020-12-07 19:37:34 +01:00
Tim van der Meij
d784af3f38
Merge pull request #12696 from timvandermeij/annotation-quadpoints
Fix non-standard quadpoints orders for annotations
2020-12-06 16:52:33 +01:00
Tim van der Meij
3df72c3fac
Merge pull request #12695 from Snuffleupagus/sandbox-build
Various clean-up and improvements related to `pdf.sandbox.js` building, and the related default-viewer functionality
2020-12-06 16:51:41 +01:00