pdf.js/test/unit
Jonas Jenwald 2b2234fd5a [api-minor] Ensure that PDFDocumentProxy.hasJSActions won't fail if MissingDataExceptions are thrown during the associated worker-thread parsing
With the current implementation of `PDFDocument.hasJSActions`, in the worker-thread, we're not actually handling not-yet-loaded data correctly. This can thus fail in *two* different ways:
 - The `PDFDocument.fieldObjects` getter (and its helper method), while it may *return* a Promise, still fetches all of its data synchronously and it can thus throw a `MissingDataException` during parsing.
 - The `Catalog.jsActions` getter, which is completely synchronous, can obviously throw a `MissingDataException` during parsing.

If either of these cases occur currently, the `PDFDocumentProxy.hasJSActions` method in the API can either return a *rejected* Promise (which it never should) or possibly "hang" and never resolve.

*Please note:* While I've not *yet* seen this error in an actual PDF document, it can happen during loading if you're unlucky enough with e.g. the structure of the PDF document and/or the download speed offered by the server.
This patch is thus based on code-inspection *and* on manually throwing a `MissingDataException` on the first access of `Catalog.jsActions` to simulate this situation.

Finally, this patch adds a couple of *API* unit-tests for this (since none existed).
2021-04-13 14:33:56 +02:00
..
.eslintrc Enable the ESLint no-var rule globally 2021-03-13 16:12:53 +01:00
annotation_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
annotation_storage_spec.js [api-minor] Annotation -- Don't compute appearance when nothing has changed 2021-02-12 19:27:21 +01:00
api_spec.js [api-minor] Ensure that PDFDocumentProxy.hasJSActions won't fail if MissingDataExceptions are thrown during the associated worker-thread parsing 2021-04-13 14:33:56 +02:00
bidi_spec.js Convert var to const/let in the test/unit folder 2020-10-25 15:40:51 +01:00
cff_parser_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
clitests_helper.js [api-minor] Highlight search results correctly for normalized text (PR 9448) 2021-01-12 18:08:08 +01:00
clitests.json XFA -- Display text content 2021-04-12 14:13:49 +02:00
cmap_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
colorspace_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
core_utils_spec.js Move the encodeToXmlString helper function to src/core/core_utils.js 2021-02-17 13:12:01 +01:00
crypto_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
custom_spec.js Remove unncessary CanvasFactory/CMapReaderFactory/FileReaderFactory duplication in unit-tests 2021-01-08 17:33:59 +01:00
default_appearance_spec.js [api-minor] Change the format of the fontName-property, in defaultAppearanceData, on Annotation-instances (PR 12831 follow-up) 2021-04-01 16:47:30 +02:00
display_svg_spec.js Load all unit-tests with native import, rather than SystemJS 2020-10-26 11:11:48 +01:00
display_utils_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
document_spec.js Display widget signature 2021-04-10 19:13:28 +02:00
encodings_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
evaluator_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
fetch_stream_spec.js Remove unnecessary /* eslint no-var: error */ lines in the test/unit/ folder (PR 12528 follow-up) 2021-03-13 11:50:11 +01:00
function_spec.js Convert var to const/let in the test/unit folder 2020-10-25 15:40:51 +01:00
jasmine-boot.js Add support for basic structure tree for accessibility. 2021-04-09 09:56:28 -07:00
message_handler_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
metadata_spec.js Move the Metadata parsing to the worker-thread 2021-02-17 13:12:01 +01:00
murmurhash3_spec.js Add a MurmurHash3_64.update unit-test for TypedArrays which share the same underlying ArrayBuffer (PR 12534 follow-up) 2020-10-28 12:42:04 +01:00
network_spec.js Fix var conversions that ESLint could not do automatically 2020-10-25 16:17:12 +01:00
network_utils_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
node_stream_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
parser_spec.js Remove unnecessary /* eslint no-var: error */ lines in the test/unit/ folder (PR 12528 follow-up) 2021-03-13 11:50:11 +01:00
pdf_find_controller_spec.js [api-minor] Highlight search results correctly for normalized text (PR 9448) 2021-01-12 18:08:08 +01:00
pdf_find_utils_spec.js Run gulp lint --fix, to account for changes in Prettier version 2.1.x 2020-09-06 12:23:59 +02:00
pdf_history_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
primitives_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
scripting_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
stream_spec.js Convert var to const/let in the test/unit folder 2020-10-25 15:40:51 +01:00
struct_tree_spec.js Add support for basic structure tree for accessibility. 2021-04-09 09:56:28 -07:00
test_utils.js Use ESLint to ensure that exports are sorted alphabetically 2021-01-09 20:37:51 +01:00
testreporter.js Replace a few new Date().getTime() instances with Date.now() 2021-02-11 23:00:42 +01:00
type1_parser_spec.js Convert var to const/let in the test/unit folder 2020-10-25 15:40:51 +01:00
ui_utils_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
unicode_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
unit_test.html Import the TestReporter, in the unit and font tests 2020-10-27 11:30:15 +01:00
util_spec.js Move the encodeToXmlString helper function to src/core/core_utils.js 2021-02-17 13:12:01 +01:00
writer_spec.js Remove obsolete done callbacks from the unit tests 2021-04-10 20:29:39 +02:00
xfa_formcalc_spec.js XFA - Add a lexer/parser for FormCalc language (#12936) 2021-02-17 20:28:06 +01:00
xfa_parser_spec.js XFA -- Display text content 2021-04-12 14:13:49 +02:00
xfa_tohtml_spec.js XFA -- Display text content 2021-04-12 14:13:49 +02:00
xml_spec.js Move the XML-parser to the src/core/-folder 2021-02-17 13:12:01 +01:00