From 9b27a5e96243025f2a5e3db20c44e626ca714264 Mon Sep 17 00:00:00 2001 From: Hiroshige Hayashizaki Date: Wed, 15 Jan 2020 02:39:51 -0800 Subject: [PATCH] [Import Maps] Migrate Jest-based parsing tests into JSON-based This CL - Converts Jest-based parsing tests into JSONs (with minor refinement, and removing test cases depending on interoperability issues of underlying URL parsers), - Adjust the JSON schema for parsing tests, and - Removes imported resolution tests. The test failures (virtual/import-maps-without-builtin-modules/external/wpt/import-maps/common/parsing.tentative.html) are due to https://github.com/WICG/import-maps/issues/184, i.e. whether `null` mappings are removed from parsed import map or not. Bug: 1026809, https://github.com/WICG/import-maps/issues/170 Change-Id: If1e53cbeafd44c1de1a7fa38ef646fcd5721b495 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1982509 Reviewed-by: Domenic Denicola Commit-Queue: Hiroshige Hayashizaki Cr-Commit-Position: refs/heads/master@{#731910} --- import-maps/common/README.md | 12 +- import-maps/common/parsing.tentative.html | 26 +++ .../common/resources/common-test-helper.js | 132 ++++++++--- .../resources/parsing-addresses-absolute.json | 63 ++++++ .../resources/parsing-addresses-invalid.json | 21 ++ .../common/resources/parsing-addresses.json | 73 ++++++ .../resources/parsing-invalid-json.json | 6 + .../parsing-schema-normalization.json | 31 +++ .../resources/parsing-schema-scope.json | 46 ++++ .../parsing-schema-specifier-map.json | 38 ++++ .../resources/parsing-schema-toplevel.json | 97 ++++++++ .../common/resources/parsing-scope-keys.json | 191 ++++++++++++++++ .../resources/parsing-specifier-keys.json | 209 ++++++++++++++++++ .../resources/parsing-trailing-slashes.json | 13 ++ .../imported/parsing-addresses.tentative.html | 11 - .../imported/parsing-schema.tentative.html | 11 - .../parsing-scope-keys.tentative.html | 11 - .../parsing-specifier-keys.tentative.html | 11 - .../imported/resources/helpers/parsing.js | 44 ---- .../imported/resources/parsing-addresses.js | 175 --------------- .../imported/resources/parsing-schema.js | 99 --------- .../imported/resources/parsing-scope-keys.js | 144 ------------ .../resources/parsing-specifier-keys.js | 164 -------------- 23 files changed, 921 insertions(+), 707 deletions(-) create mode 100644 import-maps/common/parsing.tentative.html create mode 100644 import-maps/common/resources/parsing-addresses-absolute.json create mode 100644 import-maps/common/resources/parsing-addresses-invalid.json create mode 100644 import-maps/common/resources/parsing-addresses.json create mode 100644 import-maps/common/resources/parsing-invalid-json.json create mode 100644 import-maps/common/resources/parsing-schema-normalization.json create mode 100644 import-maps/common/resources/parsing-schema-scope.json create mode 100644 import-maps/common/resources/parsing-schema-specifier-map.json create mode 100644 import-maps/common/resources/parsing-schema-toplevel.json create mode 100644 import-maps/common/resources/parsing-scope-keys.json create mode 100644 import-maps/common/resources/parsing-specifier-keys.json create mode 100644 import-maps/common/resources/parsing-trailing-slashes.json delete mode 100644 import-maps/imported/parsing-addresses.tentative.html delete mode 100644 import-maps/imported/parsing-schema.tentative.html delete mode 100644 import-maps/imported/parsing-scope-keys.tentative.html delete mode 100644 import-maps/imported/parsing-specifier-keys.tentative.html delete mode 100644 import-maps/imported/resources/helpers/parsing.js delete mode 100644 import-maps/imported/resources/parsing-addresses.js delete mode 100644 import-maps/imported/resources/parsing-schema.js delete mode 100644 import-maps/imported/resources/parsing-scope-keys.js delete mode 100644 import-maps/imported/resources/parsing-specifier-keys.js diff --git a/import-maps/common/README.md b/import-maps/common/README.md index cda42d06099f16..6092c0d767050d 100644 --- a/import-maps/common/README.md +++ b/import-maps/common/README.md @@ -6,7 +6,12 @@ tests for the reference JavaScript implementation at [WICG repository](https://g ## Basics -A **test object** describes a set of parameters (import maps and base URLs) and specifiers to be tested. +A **test object** describes a set of parameters (import maps and base URLs) and test expectations. +Test expectations can be: + +- Expected resulting URLs for specifiers (resolution tests), or +- Expected parsed import maps (parsing tests). + Each JSON file under [resources/](resources/) directory consists of a test object. A minimum test object would be: @@ -33,10 +38,11 @@ Required fields: - In WPT tests, this is used for the test name of `promise_test()` together with specifier to be resolved, like `"Main test name: a"`. - `importMap` (object or string): the import map to be attached. - `importMapBaseURL` (string): the base URL used for [parsing the import map](https://wicg.github.io/import-maps/#parse-an-import-map-string). -- `baseURL` (string): the base URL used in [resolving a specifier](https://wicg.github.io/import-maps/#resolve-a-module-specifier) for each specifiers. -- `expectedResults` (object; string to (string or null)): test cases. +- (resolution tests only) `expectedResults` (object; string to (string or null)): resolution test cases. - The keys are specifiers to be resolved. - The values are expected resolved URLs. If `null`, resolution should fail. +- (resolution tests only) `baseURL` (string): the base URL used in [resolving a specifier](https://wicg.github.io/import-maps/#resolve-a-module-specifier) for each specifiers. +- (parsing tests only) `expectedParsedImportMap` (object): the expected parsed import map for parsing test cases. Optional fields: diff --git a/import-maps/common/parsing.tentative.html b/import-maps/common/parsing.tentative.html new file mode 100644 index 00000000000000..d3334d7bbb9b44 --- /dev/null +++ b/import-maps/common/parsing.tentative.html @@ -0,0 +1,26 @@ + + + + + + diff --git a/import-maps/common/resources/common-test-helper.js b/import-maps/common/resources/common-test-helper.js index 002c4b51fd06a6..0ddad9fe150b51 100644 --- a/import-maps/common/resources/common-test-helper.js +++ b/import-maps/common/resources/common-test-helper.js @@ -2,17 +2,15 @@ setup({allow_uncaught_exception : true}); // Creates a new Document (via