Skip to content

Commit

Permalink
Bug 1588671 [wpt PR 19685] - [Import Maps] Import tests, a=testonly
Browse files Browse the repository at this point in the history
Automatic update from web-platform-tests
[Import Maps] Import tests

This CL imports post-#176 upstream reference implementation's tests
into wpt/import-maps/imported/, and
executes them under virtual/import-maps-without-builtin-modules/.

The pre-#176 existing tests are still left under
wpt/import-maps/builtin-support.tentative/imported/, which are excluded
by this CL from virtual/import-maps-without-builtin-modules.

To match with the expectation of post-#176 tests,
this CL modifies ImportMap::ToString() to output
strings (not single-element arrays) as right hand side.

WICG/import-maps#176

Bug: 990561, 1010751
Change-Id: I652b35969d48e0147d07aa869ca3a97004f2f7a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1842928
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: Domenic Denicola <domenic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706637}

--

wpt-commits: 2a907985ffc3ea3455fe277c584cadfe70b53623
wpt-pr: 19685


--HG--
rename : testing/web-platform/tests/import-maps/imported/resources/parsing-addresses.js => testing/web-platform/tests/import-maps/builtin-support.tentative/imported/resources/parsing-addresses.js
rename : testing/web-platform/tests/import-maps/imported/resources/parsing-schema.js => testing/web-platform/tests/import-maps/builtin-support.tentative/imported/resources/parsing-schema.js
rename : testing/web-platform/tests/import-maps/imported/resources/parsing-scope-keys.js => testing/web-platform/tests/import-maps/builtin-support.tentative/imported/resources/parsing-scope-keys.js
rename : testing/web-platform/tests/import-maps/imported/resources/parsing-specifier-keys.js => testing/web-platform/tests/import-maps/builtin-support.tentative/imported/resources/parsing-specifier-keys.js
rename : testing/web-platform/tests/import-maps/imported/resources/resolving-builtins.js => testing/web-platform/tests/import-maps/builtin-support.tentative/imported/resources/resolving-builtins.js
rename : testing/web-platform/tests/import-maps/imported/resources/resolving-not-yet-implemented.js => testing/web-platform/tests/import-maps/builtin-support.tentative/imported/resources/resolving-not-yet-implemented.js
rename : testing/web-platform/tests/import-maps/imported/resources/resolving-scopes.js => testing/web-platform/tests/import-maps/builtin-support.tentative/imported/resources/resolving-scopes.js
rename : testing/web-platform/tests/import-maps/imported/resources/resolving.js => testing/web-platform/tests/import-maps/builtin-support.tentative/imported/resources/resolving.js
  • Loading branch information
hiroshige-g authored and jgraham committed Oct 24, 2019
1 parent 67bc45a commit c1993c0
Show file tree
Hide file tree
Showing 23 changed files with 1,534 additions and 388 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/jest-test-helper.js"></script>
<script type="module" src="resources/helpers/parsing.js"></script>

<!--
Imported from https://github.com/WICG/import-maps/blob/master/reference-implementation/__tests__/parsing-addresses.js
-->
<script type="module" src="resources/parsing-addresses.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/jest-test-helper.js"></script>
<script type="module" src="resources/helpers/parsing.js"></script>

<!--
Imported from https://github.com/WICG/import-maps/blob/master/reference-implementation/__tests__/parsing-schema.js
-->
<script type="module" src="resources/parsing-schema.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/jest-test-helper.js"></script>
<script type="module" src="resources/helpers/parsing.js"></script>

<!--
Imported from https://github.com/WICG/import-maps/blob/master/reference-implementation/__tests__/parsing-scope-keys.js
-->
<script type="module" src="resources/parsing-scope-keys.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/jest-test-helper.js"></script>
<script type="module" src="resources/helpers/parsing.js"></script>

<!--
Imported from https://github.com/WICG/import-maps/blob/master/reference-implementation/__tests__/parsing-specifier-keys.js
-->
<script type="module" src="resources/parsing-specifier-keys.js"></script>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/jest-test-helper.js"></script>
<script src="../../resources/jest-test-helper.js"></script>
<script type="module" src="resources/helpers/parsing.js"></script>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/jest-test-helper.js"></script>
<script src="../../resources/jest-test-helper.js"></script>
<script type="module" src="resources/helpers/parsing.js"></script>

<!--
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/jest-test-helper.js"></script>
<script type="module" src="resources/helpers/parsing.js"></script>

<!--
Imported from https://github.com/WICG/import-maps/blob/master/reference-implementation/__tests__/resolving-scopes.js
-->
<script type="module" src="resources/resolving-scopes.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/jest-test-helper.js"></script>
<script type="module" src="resources/helpers/parsing.js"></script>

<!--
Imported from https://github.com/WICG/import-maps/blob/master/reference-implementation/__tests__/resolving.js
-->
<script type="module" src="resources/resolving.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict';
const { parseFromString } = require('../../lib/parser.js');

// Local modifications from upstream:
// Currently warnings and scopes are not checked in expectSpecifierMap().
exports.expectSpecifierMap = (input, baseURL, output, warnings = []) => {
expect(parseFromString(`{ "imports": ${input} }`, baseURL))
.toEqual({ imports: output, scopes: {} });
};

exports.expectScopes = (inputArray, baseURL, outputArray, warnings = []) => {
const checkWarnings = testWarningHandler(warnings);

const inputScopesAsStrings = inputArray.map(scopePrefix => `${JSON.stringify(scopePrefix)}: {}`);
const inputString = `{ "scopes": { ${inputScopesAsStrings.join(', ')} } }`;

const outputScopesObject = {};
for (const outputScopePrefix of outputArray) {
outputScopesObject[outputScopePrefix] = {};
}

expect(parseFromString(inputString, baseURL)).toEqual({ imports: {}, scopes: outputScopesObject });

checkWarnings();
};

exports.expectBad = (input, baseURL, warnings = []) => {
const checkWarnings = testWarningHandler(warnings);
expect(() => parseFromString(input, baseURL)).toThrow(TypeError);
checkWarnings();
};

exports.expectWarnings = (input, baseURL, output, warnings = []) => {
const checkWarnings = testWarningHandler(warnings);
expect(parseFromString(input, baseURL)).toEqual(output);

checkWarnings();
};

function testWarningHandler(expectedWarnings) {
// We don't check warnings on WPT tests, because there are no
// ways to catch console warnings from JavaScript.
return () => {};
}
Loading

0 comments on commit c1993c0

Please sign in to comment.