pdf.js/test/unit
Jonas Jenwald 3351d3476d Don't store complex data in PDFDocument.formInfo, and replace the fields object with a hasFields boolean instead
*This patch is based on a couple of smaller things that I noticed when working on PR 12479.*

 - Don't store the /Fields on the `formInfo` getter, since that feels like overloading it with unintended (and too complex) data, and utilize a `hasFields` boolean instead.
   This functionality was originally added in PR 12271, to help determine what kind of form data a PDF document contains, and I think that we should ensure that the return value of `formInfo` only consists of "simple" data.
   With these changes the `fieldObjects` getter instead has to look-up the /Fields manually, however that shouldn't be a problem since the access is guarded by a `formInfo.hasFields` check which ensures that the data both exists and is valid. Furthermore, most documents doesn't even have any /AcroForm data anyway.

 - Determine the `hasFields` property *first*, to ensure that it's always correct even if there's errors when checking e.g. the /XFA or /SigFlags entires, since the `fieldObjects` getter depends on it.

 - Simplify a loop in `fieldObjects`, since the object being accessed is a `Map` and those have built-in iteration support.

 - Use a higher logging level for errors in the `formInfo` getter, and include the actual error message, since that'd have helped with fixing PR 12479 a lot quicker.

 - Update the JSDoc comment in `src/display/api.js` to list the return values correctly, and also slightly extend/improve the description.
2020-10-16 12:47:27 +02:00
..
annotation_spec.js Add the possibility to collect Javascript actions 2020-10-14 10:44:16 +02:00
annotation_storage_spec.js confirm if leaving a modified form without saving 2020-08-20 17:23:06 -07:00
api_spec.js Attempt to reduce intermittent failures in the "multiple render() on the same canvas" unit-test 2020-08-04 22:31:24 +02:00
bidi_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
cff_parser_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
clitests_helper.js Use the ESLint no-restricted-syntax rule to ensure that assert is always called with two arguments 2020-05-05 13:40:05 +02:00
clitests.json Save form data in XFA datasets when pdf is a mix of acroforms and xfa (#12344) 2020-09-08 15:13:52 -07:00
cmap_spec.js [api-minor] Use the NodeCanvasFactory/NodeCMapReaderFactory classes as defaults in Node.js environments (issue 11900) 2020-07-02 04:44:23 +02:00
colorspace_spec.js Remove the special handling, used when creating Indexed ColorSpaces, for the case where the lookup-data is a Stream 2020-07-10 17:22:55 +02:00
core_utils_spec.js PDF names need to be escaped when saving 2020-09-10 16:08:13 +02:00
crypto_spec.js Add support for saving forms 2020-08-12 10:32:59 +02:00
custom_spec.js Allow loading pdf fonts into another document. 2020-08-08 02:52:32 +00:00
display_svg_spec.js [api-minor] Decode all JPEG images with the built-in PDF.js decoder in src/core/jpg.js 2020-05-22 00:22:48 +02:00
display_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
document_spec.js Don't store complex data in PDFDocument.formInfo, and replace the fields object with a hasFields boolean instead 2020-10-16 12:47:27 +02:00
encodings_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
evaluator_spec.js Add local caching of "simple" Graphics State (ExtGState) data in PartialEvaluator.getOperatorList (issue 2813) 2020-07-14 10:34:43 +02:00
fetch_stream_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
function_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
jasmine-boot.js Remove now unnecessary no-unsanitized/method disabling in test/unit/jasmine-boot.js 2020-10-04 15:30:24 +02:00
message_handler_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
metadata_spec.js Move the isEmptyObj helper function from src/shared/util.js to test/unit/test_utils.js 2020-06-09 17:50:16 +02:00
murmurhash3_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
network_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
network_utils_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
node_stream_spec.js Use the ESLint no-restricted-syntax rule to ensure that assert is always called with two arguments 2020-05-05 13:40:05 +02:00
parser_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
pdf_find_controller_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02: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 Add support, in Dict.merge, for merging of "sub"-dictionaries 2020-08-30 23:18:32 +02:00
stream_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
test_utils.js Fix the "should get form info when AcroForm is present" unit-test 2020-10-15 13:26:32 +02:00
testreporter.js Log the total number of tests and the random seed in the test runner 2020-08-01 21:09:01 +02:00
type1_parser_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
ui_utils_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
unicode_spec.js Enable the dot-notation ESLint rule 2020-04-17 12:24:46 +02:00
unit_test.html Replaces RequireJS to SystemJS. 2017-02-27 08:32:39 -06:00
util_spec.js Replace \n and \r by \n and \r when saving a string 2020-09-14 17:34:39 +02:00
writer_spec.js Dict keys need to be escaped too when saving 2020-09-11 12:25:05 +02:00
xml_spec.js Follow-up of pr #12344 2020-09-09 11:46:02 +02:00