pdf.js/test/unit
Jonas Jenwald db1e1612df [api-minor] Support proper URL-objects, in addition to URL-strings, in getDocument
Currently only URL-strings are officially supported by `getDocument`, however at this point in time I cannot really see any compelling reason to not support `URL`-objects as well.

Most likely the reason that we've don't already support `URL`-objects, in `getDocument`, is that historically `URL` wasn't fully implemented across browsers and our old polyfill wasn't perfect; see https://developer.mozilla.org/en-US/docs/Web/API/URL/URL#browser_compatibility

*Please note:* Because of how the `url` parameter is currently handled, there's actually *some* cases where passing a `URL`-object to `getDocument` already works. That, in my opinion, provides additional motivation for supporting `URL`-objects officially, since it makes the API more consistent.

The following is an attempt to summarize the *current* situation, based on the actual code rather than the JSDocs:
 - `getDocument("url string")` works and is documented.[1]
 - `getDocument({ url: "url string", })` works and is documented.[1]
 - `getDocument(new URL(...))` throws immediately, since no supported parameters are found.
 - `getDocument({ url: new URL(...), })` actually works even though it's not documented.[1] Originally, when data was fetched on the worker-thread, this would likely have thrown since `URL` isn't clonable.[2]
 - `getDocument({ url: { abc: 123, }, })`, or some similarily meaningless input, will be "accepted" by `getDocument` and then throw a `MissingPDFException` when attempting to fetch the bogus data.

With the changes in this patch, not only is `URL`-objects now officially supported and documented when calling `getDocument`, but we'll also do a much better job at actually validating any URL-data passed to `getDocument` (and instead fail early).

---
[1] In *browsers*, we create a valid URL thus indirectly validating the input. In Node.js environments, on the other hand, no validation is done since obtaining a baseUrl is more difficult (and PDF.js is primarily written for browsers anyway).

[2] https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types
2021-03-31 16:21:41 +02:00
..
.eslintrc Enable the ESLint no-var rule globally 2021-03-13 16:12:53 +01:00
annotation_spec.js Remove redundant done-callback functions from unit-tests which are async 2021-03-21 11:33:39 +01: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] Support proper URL-objects, in addition to URL-strings, in getDocument 2021-03-31 16:21:41 +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 Convert var to const/let in the test/unit folder 2020-10-25 15:40:51 +01: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 - Add a lexer/parser for FormCalc language (#12936) 2021-02-17 20:28:06 +01:00
cmap_spec.js Remove unncessary CanvasFactory/CMapReaderFactory/FileReaderFactory duplication in unit-tests 2021-01-08 17:33:59 +01: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 Move the encodeToXmlString helper function to src/core/core_utils.js 2021-02-17 13:12:01 +01:00
crypto_spec.js Fix var conversions that ESLint could not do automatically 2020-10-25 16:17:12 +01: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 Use slightly less verbose font-names in the "Default appearance" unit-tests 2021-01-23 15:34:22 +01: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 Move the getPdfFilenameFromUrl helper function from web/ui_utils.js and into src/display/display_utils.js 2021-03-17 15:48:24 +01:00
document_spec.js Don't use 'in' operator to check if key is in a Map 2020-12-16 16:00:12 +01:00
encodings_spec.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
evaluator_spec.js Run gulp lint --fix, to account for changes in Prettier version 2.2.1 2020-11-29 10:01:46 +01: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 XFA - Convert some template properties into CSS ones (#13082) 2021-03-25 13:02:39 +01: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 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 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 Add support, in Dict.merge, for merging of "sub"-dictionaries 2020-08-30 23:18:32 +02:00
scripting_spec.js JS - Fix setting a color on an annotation 2021-02-20 15:24:37 +01:00
stream_spec.js Convert var to const/let in the test/unit folder 2020-10-25 15:40:51 +01: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 Move the getPdfFilenameFromUrl helper function from web/ui_utils.js and into src/display/display_utils.js 2021-03-17 15:48:24 +01:00
unicode_spec.js Convert var to const/let in the test/unit folder 2020-10-25 15:40:51 +01: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 Dict keys need to be escaped too when saving 2020-09-11 12:25:05 +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 - Add support for few ui elements (#13115) 2021-03-31 15:42:21 +02:00
xfa_tohtml_spec.js XFA - Convert some template properties into CSS ones (#13082) 2021-03-25 13:02:39 +01:00
xml_spec.js Move the XML-parser to the src/core/-folder 2021-02-17 13:12:01 +01:00