From 39f41c4497b134f7722381ac8c34ed3c93ae9f7f Mon Sep 17 00:00:00 2001 From: Hiroshige Hayashizaki Date: Wed, 15 Jan 2020 11:51:12 +0000 Subject: [PATCH] Bug 1607407 [wpt PR 21064] - [Import Maps] Migrate Jest-based parsing tests into JSON-based, a=testonly Automatic update from web-platform-tests [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} -- wpt-commits: a5e2efd90b6766f33e94d92e1858a68f8c40c977 wpt-pr: 21064 --- .../tests/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 testing/web-platform/tests/import-maps/common/parsing.tentative.html create mode 100644 testing/web-platform/tests/import-maps/common/resources/parsing-addresses-absolute.json create mode 100644 testing/web-platform/tests/import-maps/common/resources/parsing-addresses-invalid.json create mode 100644 testing/web-platform/tests/import-maps/common/resources/parsing-addresses.json create mode 100644 testing/web-platform/tests/import-maps/common/resources/parsing-invalid-json.json create mode 100644 testing/web-platform/tests/import-maps/common/resources/parsing-schema-normalization.json create mode 100644 testing/web-platform/tests/import-maps/common/resources/parsing-schema-scope.json create mode 100644 testing/web-platform/tests/import-maps/common/resources/parsing-schema-specifier-map.json create mode 100644 testing/web-platform/tests/import-maps/common/resources/parsing-schema-toplevel.json create mode 100644 testing/web-platform/tests/import-maps/common/resources/parsing-scope-keys.json create mode 100644 testing/web-platform/tests/import-maps/common/resources/parsing-specifier-keys.json create mode 100644 testing/web-platform/tests/import-maps/common/resources/parsing-trailing-slashes.json delete mode 100644 testing/web-platform/tests/import-maps/imported/parsing-addresses.tentative.html delete mode 100644 testing/web-platform/tests/import-maps/imported/parsing-schema.tentative.html delete mode 100644 testing/web-platform/tests/import-maps/imported/parsing-scope-keys.tentative.html delete mode 100644 testing/web-platform/tests/import-maps/imported/parsing-specifier-keys.tentative.html delete mode 100644 testing/web-platform/tests/import-maps/imported/resources/helpers/parsing.js delete mode 100644 testing/web-platform/tests/import-maps/imported/resources/parsing-addresses.js delete mode 100644 testing/web-platform/tests/import-maps/imported/resources/parsing-schema.js delete mode 100644 testing/web-platform/tests/import-maps/imported/resources/parsing-scope-keys.js delete mode 100644 testing/web-platform/tests/import-maps/imported/resources/parsing-specifier-keys.js diff --git a/testing/web-platform/tests/import-maps/common/README.md b/testing/web-platform/tests/import-maps/common/README.md index cda42d06099f1..6092c0d767050 100644 --- a/testing/web-platform/tests/import-maps/common/README.md +++ b/testing/web-platform/tests/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/testing/web-platform/tests/import-maps/common/parsing.tentative.html b/testing/web-platform/tests/import-maps/common/parsing.tentative.html new file mode 100644 index 0000000000000..d3334d7bbb9b4 --- /dev/null +++ b/testing/web-platform/tests/import-maps/common/parsing.tentative.html @@ -0,0 +1,26 @@ + + + + + + diff --git a/testing/web-platform/tests/import-maps/common/resources/common-test-helper.js b/testing/web-platform/tests/import-maps/common/resources/common-test-helper.js index 002c4b51fd06a..0ddad9fe150b5 100644 --- a/testing/web-platform/tests/import-maps/common/resources/common-test-helper.js +++ b/testing/web-platform/tests/import-maps/common/resources/common-test-helper.js @@ -2,17 +2,15 @@ setup({allow_uncaught_exception : true}); // Creates a new Document (via