pdf.js/test/unit
Tim van der Meij 280207c740
Redo the form type detection logic and include unit tests
Good form type detection is important to get reliable telemetry and to
only show the fallback bar if a form cannot be filled out by the user.

PDF.js only supports AcroForm data, so XFA data is explicitly unsupported
(tracked in issue #2373). However, the previous form type detection
couldn't separate AcroForm and XFA well enough, causing form type
telemetry to be incorrect sometimes and the fallback bar to be shown for
forms that could in fact be filled out by the user.

The solution in this commit is found by studying the specification and
the form documents that are available to us. In a nutshell the rules are:

- There is XFA data if the `XFA` entry is a non-empty array or stream.
- There is AcroForm data if the `Fields` entry is a non-empty array and
  it doesn't consist of only document signatures.

The document signatures part was not handled in the old code, causing a
document with only XFA data to also be marked as having AcroForm data.
Moreover, the old code didn't check all the data types.

Now that AcroForm and XFA can be distinguished, the viewer is configured
to only show the fallback bar for documents that only have XFA data. If
a document also has AcroForm data, the viewer can use that to render the
form. We have not found documents where the XFA data was necessary in
that case.

Finally, we include unit tests to ensure that all cases are covered and
move the form type detection out of the `parse` function so that it's
only executed if the document information is actually requested
(potentially making initial parsing a tiny bit faster).
2020-08-25 23:28:55 +02:00
..
annotation_spec.js Move the AcroForm logic from the document to the catalog 2020-08-25 23:28:55 +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 Add support for saving forms 2020-08-12 10:32:59 +02: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 Update Prettier to version 2.0 2020-04-14 12:28:14 +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 Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
document_spec.js Redo the form type detection logic and include unit tests 2020-08-25 23:28:55 +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 Add support for saving forms 2020-08-12 10:32:59 +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 Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
pdf_history_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
primitives_spec.js Add a getRawValues method, to Dict instances, to provide an easier way of getting all *raw* values 2020-07-17 16:32:00 +02:00
stream_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
test_utils.js Add support for saving forms 2020-08-12 10:32:59 +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 Add support for saving forms 2020-08-12 10:32:59 +02:00
writer_spec.js Add support for saving forms 2020-08-12 10:32:59 +02:00