diff --git a/test/fixtures/url-tests.js b/test/fixtures/url-tests.js index 745adb8d8aab43..48533ed09073db 100644 --- a/test/fixtures/url-tests.js +++ b/test/fixtures/url-tests.js @@ -2,7 +2,7 @@ /* The following tests are copied from WPT. Modifications to them should be upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/ed4bb727ed/url/urltestdata.json + https://github.com/w3c/web-platform-tests/blob/88b75886e/url/urltestdata.json License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html */ module.exports = @@ -6529,27 +6529,34 @@ module.exports = "search": "?a", "hash": "#%GH" }, - "Bad bases", + "URLs that require a non-about:blank base. (Also serve as invalid base tests.)", { - "input": "test-a.html", - "base": "a", + "input": "a", + "base": "about:blank", "failure": true }, { - "input": "test-a-slash.html", - "base": "a/", + "input": "a/", + "base": "about:blank", "failure": true }, { - "input": "test-a-slash-slash.html", - "base": "a//", + "input": "a//", + "base": "about:blank", "failure": true }, + "Bases that don't fail to parse but fail to be bases", { "input": "test-a-colon.html", "base": "a:", "failure": true }, + { + "input": "test-a-colon-b.html", + "base": "a:b", + "failure": true + }, + "Other base URL tests, that must succeed", { "input": "test-a-colon-slash.html", "base": "a:/", @@ -6578,11 +6585,6 @@ module.exports = "search": "", "hash": "" }, - { - "input": "test-a-colon-b.html", - "base": "a:b", - "failure": true - }, { "input": "test-a-colon-slash-b.html", "base": "a:/b", diff --git a/test/parallel/test-whatwg-url-parsing.js b/test/parallel/test-whatwg-url-parsing.js index fd34fee1954d8c..fd8570eb720831 100644 --- a/test/parallel/test-whatwg-url-parsing.js +++ b/test/parallel/test-whatwg-url-parsing.js @@ -12,7 +12,10 @@ const fixtures = require('../common/fixtures'); // Tests below are not from WPT. const tests = require(fixtures.path('url-tests')); -const failureTests = tests.filter((test) => test.failure).concat([ + +const originalFailures = tests.filter((test) => test.failure); + +const typeFailures = [ { input: '' }, { input: 'test' }, { input: undefined }, @@ -25,7 +28,23 @@ const failureTests = tests.filter((test) => test.failure).concat([ { input: 'test', base: null }, { input: 'http://nodejs.org', base: null }, { input: () => {} } -]); +]; + +// See https://github.com/w3c/web-platform-tests/pull/10955 +// > If `failure` is true, parsing `about:blank` against `base` +// > must give failure. This tests that the logic for converting +// > base URLs into strings properly fails the whole parsing +// > algorithm if the base URL cannot be parsed. +const aboutBlankFailures = originalFailures + .map((test) => ({ + input: 'about:blank', + base: test.input, + failure: true + })); + +const failureTests = originalFailures + .concat(typeFailures) + .concat(aboutBlankFailures); const expectedError = common.expectsError( { code: 'ERR_INVALID_URL', type: TypeError }, failureTests.length);