From 3f935d74e0acb92666e9f6600551b04d6ce45ac0 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 1 Oct 2018 15:37:08 +0200 Subject: [PATCH] test: remove WPT tests that are now .any.js in the upstream In favor of actual .any.js tests that will be run with the WPT harness in a subsequent patch. The other types of .js tests (e.g. .window.js tests) and the .html tests remained to be supported or migrated in the upstream. PR-URL: https://github.com/nodejs/node/pull/24035 Refs: https://github.com/nodejs/node/issues/23192 Reviewed-By: Daijiro Wachi --- .../test-whatwg-console-is-a-namespace.js | 47 ----- .../test-whatwg-console-label-conversion.js | 45 ----- .../test-whatwg-console-tests-historical.js | 36 ---- test/parallel/test-whatwg-url-historical.js | 46 ----- .../test-whatwg-url-searchparams-append.js | 49 ----- ...est-whatwg-url-searchparams-constructor.js | 191 ------------------ .../test-whatwg-url-searchparams-delete.js | 59 ------ .../test-whatwg-url-searchparams-foreach.js | 47 ----- .../test-whatwg-url-searchparams-get.js | 34 ---- .../test-whatwg-url-searchparams-getall.js | 39 ---- .../test-whatwg-url-searchparams-has.js | 37 ---- .../test-whatwg-url-searchparams-set.js | 35 ---- .../test-whatwg-url-searchparams-sort.js | 63 ------ ...est-whatwg-url-searchparams-stringifier.js | 123 ----------- test/parallel/test-whatwg-url-tojson.js | 17 -- 15 files changed, 868 deletions(-) delete mode 100644 test/parallel/test-whatwg-console-is-a-namespace.js delete mode 100644 test/parallel/test-whatwg-console-label-conversion.js delete mode 100644 test/parallel/test-whatwg-console-tests-historical.js delete mode 100644 test/parallel/test-whatwg-url-historical.js delete mode 100644 test/parallel/test-whatwg-url-searchparams-append.js delete mode 100644 test/parallel/test-whatwg-url-searchparams-constructor.js delete mode 100644 test/parallel/test-whatwg-url-searchparams-delete.js delete mode 100644 test/parallel/test-whatwg-url-searchparams-foreach.js delete mode 100644 test/parallel/test-whatwg-url-searchparams-get.js delete mode 100644 test/parallel/test-whatwg-url-searchparams-getall.js delete mode 100644 test/parallel/test-whatwg-url-searchparams-has.js delete mode 100644 test/parallel/test-whatwg-url-searchparams-set.js delete mode 100644 test/parallel/test-whatwg-url-searchparams-sort.js delete mode 100644 test/parallel/test-whatwg-url-searchparams-stringifier.js delete mode 100644 test/parallel/test-whatwg-url-tojson.js diff --git a/test/parallel/test-whatwg-console-is-a-namespace.js b/test/parallel/test-whatwg-console-is-a-namespace.js deleted file mode 100644 index fb28e751a322af..00000000000000 --- a/test/parallel/test-whatwg-console-is-a-namespace.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; - -require('../common'); - -const { test, assert_equals, assert_true, assert_false } = - require('../common/wpt'); - -const self = global; - -/* eslint-disable quotes, max-len */ - -/* The following tests should not be modified as they are copied */ -/* WPT Refs: - https://github.com/w3c/web-platform-tests/blob/40e451c/console/console-is-a-namespace.any.js - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ - -// https://heycam.github.io/webidl/#es-namespaces -// https://console.spec.whatwg.org/#console-namespace - -test(() => { - assert_true(self.hasOwnProperty("console")); -}, "console exists on the global object"); - -test(() => { - const propDesc = Object.getOwnPropertyDescriptor(self, "console"); - assert_equals(propDesc.writable, true, "must be writable"); - assert_equals(propDesc.enumerable, false, "must not be enumerable"); - assert_equals(propDesc.configurable, true, "must be configurable"); - assert_equals(propDesc.value, console, "must have the right value"); -}, "console has the right property descriptors"); - -test(() => { - assert_false("Console" in self); -}, "Console (uppercase, as if it were an interface) must not exist"); - -test(() => { - const prototype1 = Object.getPrototypeOf(console); - const prototype2 = Object.getPrototypeOf(prototype1); - - // This got commented out from the original test because in Node.js all - // functions are declared on the prototype. - // assert_equals(Object.getOwnPropertyNames(prototype1).length, 0, "The [[Prototype]] must have no properties"); - assert_equals(prototype2, Object.prototype, "The [[Prototype]]'s [[Prototype]] must be %ObjectPrototype%"); -}, "The prototype chain must be correct"); - -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-console-label-conversion.js b/test/parallel/test-whatwg-console-label-conversion.js deleted file mode 100644 index 9131a0c175d11c..00000000000000 --- a/test/parallel/test-whatwg-console-label-conversion.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -require('../common'); - -const { test, assert_true, assert_throws } = - require('../common/wpt'); - -/* eslint-disable max-len, object-curly-spacing */ - -/* The following tests should not be modified as they are copied */ -/* WPT Refs: - https://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/console/console-label-conversion.any.js - License: https://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/LICENSE.md -*/ - -// https://console.spec.whatwg/org/#counting -// https://console.spec.whatwg/org/#timing - -const methods = ['count', 'countReset', 'time', 'timeLog', 'timeEnd']; - -for (const method of methods) { - test(() => { - let labelToStringCalled = false; - - console[method]({ - toString() { - labelToStringCalled = true; - } - }); - - assert_true(labelToStringCalled, `${method}() must call toString() on label when label is an object`); - }, `console.${method}()'s label gets converted to string via label.toString() when label is an object`); - - test(() => { - assert_throws({name: 'Error'}, () => { - console[method]({ - toString() { - throw new Error('conversion error'); - } - }); - }, `${method} must re-throw any exceptions thrown by label.toString() conversion`); - }, `console.${method}() throws exceptions generated by erroneous label.toString() conversion`); -} - -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-console-tests-historical.js b/test/parallel/test-whatwg-console-tests-historical.js deleted file mode 100644 index d4a998b07061b9..00000000000000 --- a/test/parallel/test-whatwg-console-tests-historical.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -require('../common'); - -const { test, assert_equals } = - require('../common/wpt'); - -/* eslint-disable max-len, quotes */ - -/* The following tests should not be modified as they are copied */ -/* WPT Refs: - https://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/console/console-tests-historical.any.js - License: https://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/LICENSE.md -*/ - -/** - * These tests assert the non-existence of certain - * legacy Console methods that are not included in - * the specification: http://console.spec.whatwg.org/ - */ - -"use strict"; - -test(() => { - assert_equals(console.timeline, undefined, "console.timeline should be undefined"); -}, "'timeline' function should not exist on the console object"); - -test(() => { - assert_equals(console.timelineEnd, undefined, "console.timelineEnd should be undefined"); -}, "'timelineEnd' function should not exist on the console object"); - -test(() => { - assert_equals(console.markTimeline, undefined, "console.markTimeline should be undefined"); -}, "'markTimeline' function should not exist on the console object"); - -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-historical.js b/test/parallel/test-whatwg-url-historical.js deleted file mode 100644 index 466949cd322d37..00000000000000 --- a/test/parallel/test-whatwg-url-historical.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; -const common = require('../common'); -if (!common.hasIntl) { - // A handful of the tests fail when ICU is not included. - common.skip('missing Intl'); -} - -const URL = require('url').URL; -const { test, assert_equals, assert_throws } = require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/8791bed/url/historical.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -// var objects = [ -// [function() { return window.location }, "location object"], -// [function() { return document.createElement("a") }, "a element"], -// [function() { return document.createElement("area") }, "area element"], -// ]; - -// objects.forEach(function(o) { -// test(function() { -// var object = o[0](); -// assert_false("searchParams" in object, -// o[1] + " should not have a searchParams attribute"); -// }, "searchParams on " + o[1]); -// }); - -test(function() { - var url = new URL("./foo", "http://www.example.org"); - assert_equals(url.href, "http://www.example.org/foo"); - assert_throws(new TypeError(), function() { - url.href = "./bar"; - }); -}, "Setting URL's href attribute and base URLs"); - -test(function() { - assert_equals(URL.domainToASCII, undefined); -}, "URL.domainToASCII should be undefined"); - -test(function() { - assert_equals(URL.domainToUnicode, undefined); -}, "URL.domainToUnicode should be undefined"); -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-searchparams-append.js b/test/parallel/test-whatwg-url-searchparams-append.js deleted file mode 100644 index 342cbd53357986..00000000000000 --- a/test/parallel/test-whatwg-url-searchparams-append.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; - -require('../common'); -const URLSearchParams = require('url').URLSearchParams; -const { test, assert_equals, assert_true } = require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/8791bed/url/urlsearchparams-append.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -test(function() { - var params = new URLSearchParams(); - params.append('a', 'b'); - assert_equals(params + '', 'a=b'); - params.append('a', 'b'); - assert_equals(params + '', 'a=b&a=b'); - params.append('a', 'c'); - assert_equals(params + '', 'a=b&a=b&a=c'); -}, 'Append same name'); -test(function() { - var params = new URLSearchParams(); - params.append('', ''); - assert_equals(params + '', '='); - params.append('', ''); - assert_equals(params + '', '=&='); -}, 'Append empty strings'); -test(function() { - var params = new URLSearchParams(); - params.append(null, null); - assert_equals(params + '', 'null=null'); - params.append(null, null); - assert_equals(params + '', 'null=null&null=null'); -}, 'Append null'); -test(function() { - var params = new URLSearchParams(); - params.append('first', 1); - params.append('second', 2); - params.append('third', ''); - params.append('first', 10); - assert_true(params.has('first'), 'Search params object has name "first"'); - assert_equals(params.get('first'), '1', 'Search params object has name "first" with value "1"'); - assert_equals(params.get('second'), '2', 'Search params object has name "second" with value "2"'); - assert_equals(params.get('third'), '', 'Search params object has name "third" with value ""'); - params.append('first', 10); - assert_equals(params.get('first'), '1', 'Search params object has name "first" with value "1"'); -}, 'Append multiple'); -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-searchparams-constructor.js b/test/parallel/test-whatwg-url-searchparams-constructor.js deleted file mode 100644 index 882072ba445fcb..00000000000000 --- a/test/parallel/test-whatwg-url-searchparams-constructor.js +++ /dev/null @@ -1,191 +0,0 @@ -'use strict'; - -require('../common'); -const URLSearchParams = require('url').URLSearchParams; -const { - test, assert_equals, assert_true, - assert_false, assert_throws, assert_array_equals -} = require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/54c3502d7b/url/urlsearchparams-constructor.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -var params; // Strict mode fix for WPT. -test(function() { - var params = new URLSearchParams(); - assert_equals(params + '', ''); - params = new URLSearchParams(''); - assert_equals(params + '', ''); - params = new URLSearchParams('a=b'); - assert_equals(params + '', 'a=b'); - params = new URLSearchParams(params); - assert_equals(params + '', 'a=b'); -}, 'Basic URLSearchParams construction'); - -test(function() { - var params = new URLSearchParams() - assert_equals(params.toString(), "") -}, "URLSearchParams constructor, no arguments") - -// test(() => { -// params = new URLSearchParams(DOMException.prototype); -// assert_equals(params.toString(), "INDEX_SIZE_ERR=1&DOMSTRING_SIZE_ERR=2&HIERARCHY_REQUEST_ERR=3&WRONG_DOCUMENT_ERR=4&INVALID_CHARACTER_ERR=5&NO_DATA_ALLOWED_ERR=6&NO_MODIFICATION_ALLOWED_ERR=7&NOT_FOUND_ERR=8&NOT_SUPPORTED_ERR=9&INUSE_ATTRIBUTE_ERR=10&INVALID_STATE_ERR=11&SYNTAX_ERR=12&INVALID_MODIFICATION_ERR=13&NAMESPACE_ERR=14&INVALID_ACCESS_ERR=15&VALIDATION_ERR=16&TYPE_MISMATCH_ERR=17&SECURITY_ERR=18&NETWORK_ERR=19&ABORT_ERR=20&URL_MISMATCH_ERR=21"A_EXCEEDED_ERR=22&TIMEOUT_ERR=23&INVALID_NODE_TYPE_ERR=24&DATA_CLONE_ERR=25") -// }, "URLSearchParams constructor, DOMException.prototype as argument") - -test(() => { - params = new URLSearchParams(''); - assert_true(params != null, 'constructor returned non-null value.'); - assert_equals(params.__proto__, URLSearchParams.prototype, 'expected URLSearchParams.prototype as prototype.'); -}, "URLSearchParams constructor, empty string as argument") - -test(() => { - params = new URLSearchParams({}); - assert_equals(params + '', ""); -}, 'URLSearchParams constructor, {} as argument'); - -test(function() { - var params = new URLSearchParams('a=b'); - assert_true(params != null, 'constructor returned non-null value.'); - assert_true(params.has('a'), 'Search params object has name "a"'); - assert_false(params.has('b'), 'Search params object has not got name "b"'); - var params = new URLSearchParams('a=b&c'); - assert_true(params != null, 'constructor returned non-null value.'); - assert_true(params.has('a'), 'Search params object has name "a"'); - assert_true(params.has('c'), 'Search params object has name "c"'); - var params = new URLSearchParams('&a&&& &&&&&a+b=& c&m%c3%b8%c3%b8'); - assert_true(params != null, 'constructor returned non-null value.'); - assert_true(params.has('a'), 'Search params object has name "a"'); - assert_true(params.has('a b'), 'Search params object has name "a b"'); - assert_true(params.has(' '), 'Search params object has name " "'); - assert_false(params.has('c'), 'Search params object did not have the name "c"'); - assert_true(params.has(' c'), 'Search params object has name " c"'); - assert_true(params.has('møø'), 'Search params object has name "møø"'); -}, 'URLSearchParams constructor, string.'); - -test(function() { - var seed = new URLSearchParams('a=b&c=d'); - var params = new URLSearchParams(seed); - assert_true(params != null, 'constructor returned non-null value.'); - assert_equals(params.get('a'), 'b'); - assert_equals(params.get('c'), 'd'); - assert_false(params.has('d')); - // The name-value pairs are copied when created; later updates - // should not be observable. - seed.append('e', 'f'); - assert_false(params.has('e')); - params.append('g', 'h'); - assert_false(seed.has('g')); -}, 'URLSearchParams constructor, object.'); - -test(function() { - var params = new URLSearchParams('a=b+c'); - assert_equals(params.get('a'), 'b c'); - params = new URLSearchParams('a+b=c'); - assert_equals(params.get('a b'), 'c'); -}, 'Parse +'); - -test(function() { - const testValue = '+15555555555'; - const params = new URLSearchParams(); - params.set('query', testValue); - var newParams = new URLSearchParams(params.toString()); - - assert_equals(params.toString(), 'query=%2B15555555555'); - assert_equals(params.get('query'), testValue); - assert_equals(newParams.get('query'), testValue); -}, 'Parse encoded +'); - -test(function() { - var params = new URLSearchParams('a=b c'); - assert_equals(params.get('a'), 'b c'); - params = new URLSearchParams('a b=c'); - assert_equals(params.get('a b'), 'c'); -}, 'Parse space'); - -test(function() { - var params = new URLSearchParams('a=b%20c'); - assert_equals(params.get('a'), 'b c'); - params = new URLSearchParams('a%20b=c'); - assert_equals(params.get('a b'), 'c'); -}, 'Parse %20'); - -test(function() { - var params = new URLSearchParams('a=b\0c'); - assert_equals(params.get('a'), 'b\0c'); - params = new URLSearchParams('a\0b=c'); - assert_equals(params.get('a\0b'), 'c'); -}, 'Parse \\0'); - -test(function() { - var params = new URLSearchParams('a=b%00c'); - assert_equals(params.get('a'), 'b\0c'); - params = new URLSearchParams('a%00b=c'); - assert_equals(params.get('a\0b'), 'c'); -}, 'Parse %00'); - -test(function() { - var params = new URLSearchParams('a=b\u2384'); - assert_equals(params.get('a'), 'b\u2384'); - params = new URLSearchParams('a\u2384b=c'); - assert_equals(params.get('a\u2384b'), 'c'); -}, 'Parse \u2384'); // Unicode Character 'COMPOSITION SYMBOL' (U+2384) - -test(function() { - var params = new URLSearchParams('a=b%e2%8e%84'); - assert_equals(params.get('a'), 'b\u2384'); - params = new URLSearchParams('a%e2%8e%84b=c'); - assert_equals(params.get('a\u2384b'), 'c'); -}, 'Parse %e2%8e%84'); // Unicode Character 'COMPOSITION SYMBOL' (U+2384) - -test(function() { - var params = new URLSearchParams('a=b\uD83D\uDCA9c'); - assert_equals(params.get('a'), 'b\uD83D\uDCA9c'); - params = new URLSearchParams('a\uD83D\uDCA9b=c'); - assert_equals(params.get('a\uD83D\uDCA9b'), 'c'); -}, 'Parse \uD83D\uDCA9'); // Unicode Character 'PILE OF POO' (U+1F4A9) - -test(function() { - var params = new URLSearchParams('a=b%f0%9f%92%a9c'); - assert_equals(params.get('a'), 'b\uD83D\uDCA9c'); - params = new URLSearchParams('a%f0%9f%92%a9b=c'); - assert_equals(params.get('a\uD83D\uDCA9b'), 'c'); -}, 'Parse %f0%9f%92%a9'); // Unicode Character 'PILE OF POO' (U+1F4A9) - -test(function() { - var params = new URLSearchParams([]); - assert_true(params != null, 'constructor returned non-null value.'); - params = new URLSearchParams([['a', 'b'], ['c', 'd']]); - assert_equals(params.get("a"), "b"); - assert_equals(params.get("c"), "d"); - assert_throws(new TypeError(), function() { new URLSearchParams([[1]]); }); - assert_throws(new TypeError(), function() { new URLSearchParams([[1,2,3]]); }); -}, "Constructor with sequence of sequences of strings"); - -[ - { "input": {"+": "%C2"}, "output": [["+", "%C2"]], "name": "object with +" }, - { "input": {c: "x", a: "?"}, "output": [["c", "x"], ["a", "?"]], "name": "object with two keys" }, - { "input": [["c", "x"], ["a", "?"]], "output": [["c", "x"], ["a", "?"]], "name": "array with two keys" }, - { "input": {"a\0b": "42", "c\uD83D": "23", "d\u1234": "foo"}, "output": [["a\0b", "42"], ["c\uFFFD", "23"], ["d\u1234", "foo"]], "name": "object with NULL, non-ASCII, and surrogate keys" } -].forEach((val) => { - test(() => { - let params = new URLSearchParams(val.input), - i = 0 - for (let param of params) { - assert_array_equals(param, val.output[i]) - i++ - } - }, "Construct with " + val.name) -}) - -test(() => { - params = new URLSearchParams() - params[Symbol.iterator] = function *() { - yield ["a", "b"] - } - let params2 = new URLSearchParams(params) - assert_equals(params2.get("a"), "b") -}, "Custom [Symbol.iterator]") -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-searchparams-delete.js b/test/parallel/test-whatwg-url-searchparams-delete.js deleted file mode 100644 index cdf3332efc7807..00000000000000 --- a/test/parallel/test-whatwg-url-searchparams-delete.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; - -require('../common'); -const { URL, URLSearchParams } = require('url'); -const { test, assert_equals, assert_true, assert_false } = - require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/70a0898763/url/urlsearchparams-delete.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -test(function() { - var params = new URLSearchParams('a=b&c=d'); - params.delete('a'); - assert_equals(params + '', 'c=d'); - params = new URLSearchParams('a=a&b=b&a=a&c=c'); - params.delete('a'); - assert_equals(params + '', 'b=b&c=c'); - params = new URLSearchParams('a=a&=&b=b&c=c'); - params.delete(''); - assert_equals(params + '', 'a=a&b=b&c=c'); - params = new URLSearchParams('a=a&null=null&b=b'); - params.delete(null); - assert_equals(params + '', 'a=a&b=b'); - params = new URLSearchParams('a=a&undefined=undefined&b=b'); - params.delete(undefined); - assert_equals(params + '', 'a=a&b=b'); -}, 'Delete basics'); - -test(function() { - var params = new URLSearchParams(); - params.append('first', 1); - assert_true(params.has('first'), 'Search params object has name "first"'); - assert_equals(params.get('first'), '1', 'Search params object has name "first" with value "1"'); - params.delete('first'); - assert_false(params.has('first'), 'Search params object has no "first" name'); - params.append('first', 1); - params.append('first', 10); - params.delete('first'); - assert_false(params.has('first'), 'Search params object has no "first" name'); -}, 'Deleting appended multiple'); - -test(function() { - var url = new URL('http://example.com/?param1¶m2'); - url.searchParams.delete('param1'); - url.searchParams.delete('param2'); - assert_equals(url.href, 'http://example.com/', 'url.href does not have ?'); - assert_equals(url.search, '', 'url.search does not have ?'); -}, 'Deleting all params removes ? from URL'); - -test(function() { - var url = new URL('http://example.com/?'); - url.searchParams.delete('param1'); - assert_equals(url.href, 'http://example.com/', 'url.href does not have ?'); - assert_equals(url.search, '', 'url.search does not have ?'); -}, 'Removing non-existent param removes ? from URL'); -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-searchparams-foreach.js b/test/parallel/test-whatwg-url-searchparams-foreach.js deleted file mode 100644 index 833858618f8e5b..00000000000000 --- a/test/parallel/test-whatwg-url-searchparams-foreach.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; - -require('../common'); -const { URL, URLSearchParams } = require('url'); -const { test, assert_array_equals, assert_unreached } = - require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/a8b2b1e/url/urlsearchparams-foreach.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -var i; // Strict mode fix for WPT. -test(function() { - var params = new URLSearchParams('a=1&b=2&c=3'); - var keys = []; - var values = []; - params.forEach(function(value, key) { - keys.push(key); - values.push(value); - }); - assert_array_equals(keys, ['a', 'b', 'c']); - assert_array_equals(values, ['1', '2', '3']); -}, "ForEach Check"); - -test(function() { - let a = new URL("http://a.b/c?a=1&b=2&c=3&d=4"); - let b = a.searchParams; - var c = []; - for (i of b) { - a.search = "x=1&y=2&z=3"; - c.push(i); - } - assert_array_equals(c[0], ["a","1"]); - assert_array_equals(c[1], ["y","2"]); - assert_array_equals(c[2], ["z","3"]); -}, "For-of Check"); - -test(function() { - let a = new URL("http://a.b/c"); - let b = a.searchParams; - for (i of b) { - assert_unreached(i); - } -}, "empty"); -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-searchparams-get.js b/test/parallel/test-whatwg-url-searchparams-get.js deleted file mode 100644 index 94e92c18e4b218..00000000000000 --- a/test/parallel/test-whatwg-url-searchparams-get.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -require('../common'); -const URLSearchParams = require('url').URLSearchParams; -const { test, assert_equals, assert_true } = require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/8791bed/url/urlsearchparams-get.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -test(function() { - var params = new URLSearchParams('a=b&c=d'); - assert_equals(params.get('a'), 'b'); - assert_equals(params.get('c'), 'd'); - assert_equals(params.get('e'), null); - params = new URLSearchParams('a=b&c=d&a=e'); - assert_equals(params.get('a'), 'b'); - params = new URLSearchParams('=b&c=d'); - assert_equals(params.get(''), 'b'); - params = new URLSearchParams('a=&c=d&a=e'); - assert_equals(params.get('a'), ''); -}, 'Get basics'); - -test(function() { - var params = new URLSearchParams('first=second&third&&'); - assert_true(params != null, 'constructor returned non-null value.'); - assert_true(params.has('first'), 'Search params object has name "first"'); - assert_equals(params.get('first'), 'second', 'Search params object has name "first" with value "second"'); - assert_equals(params.get('third'), '', 'Search params object has name "third" with the empty value.'); - assert_equals(params.get('fourth'), null, 'Search params object has no "fourth" name and value.'); -}, 'More get() basics'); -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-searchparams-getall.js b/test/parallel/test-whatwg-url-searchparams-getall.js deleted file mode 100644 index 06827f37d95bfe..00000000000000 --- a/test/parallel/test-whatwg-url-searchparams-getall.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -require('../common'); -const URLSearchParams = require('url').URLSearchParams; -const { test, assert_equals, assert_true, assert_array_equals } = - require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/8791bed/url/urlsearchparams-getall.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -test(function() { - var params = new URLSearchParams('a=b&c=d'); - assert_array_equals(params.getAll('a'), ['b']); - assert_array_equals(params.getAll('c'), ['d']); - assert_array_equals(params.getAll('e'), []); - params = new URLSearchParams('a=b&c=d&a=e'); - assert_array_equals(params.getAll('a'), ['b', 'e']); - params = new URLSearchParams('=b&c=d'); - assert_array_equals(params.getAll(''), ['b']); - params = new URLSearchParams('a=&c=d&a=e'); - assert_array_equals(params.getAll('a'), ['', 'e']); -}, 'getAll() basics'); - -test(function() { - var params = new URLSearchParams('a=1&a=2&a=3&a'); - assert_true(params.has('a'), 'Search params object has name "a"'); - var matches = params.getAll('a'); - assert_true(matches && matches.length == 4, 'Search params object has values for name "a"'); - assert_array_equals(matches, ['1', '2', '3', ''], 'Search params object has expected name "a" values'); - params.set('a', 'one'); - assert_equals(params.get('a'), 'one', 'Search params object has name "a" with value "one"'); - var matches = params.getAll('a'); - assert_true(matches && matches.length == 1, 'Search params object has values for name "a"'); - assert_array_equals(matches, ['one'], 'Search params object has expected name "a" values'); -}, 'getAll() multiples'); -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-searchparams-has.js b/test/parallel/test-whatwg-url-searchparams-has.js deleted file mode 100644 index 95e69beb4d26ec..00000000000000 --- a/test/parallel/test-whatwg-url-searchparams-has.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -require('../common'); -const URLSearchParams = require('url').URLSearchParams; -const { test, assert_false, assert_true } = require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/8791bed/url/urlsearchparams-has.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -test(function() { - var params = new URLSearchParams('a=b&c=d'); - assert_true(params.has('a')); - assert_true(params.has('c')); - assert_false(params.has('e')); - params = new URLSearchParams('a=b&c=d&a=e'); - assert_true(params.has('a')); - params = new URLSearchParams('=b&c=d'); - assert_true(params.has('')); - params = new URLSearchParams('null=a'); - assert_true(params.has(null)); -}, 'Has basics'); - -test(function() { - var params = new URLSearchParams('a=b&c=d&&'); - params.append('first', 1); - params.append('first', 2); - assert_true(params.has('a'), 'Search params object has name "a"'); - assert_true(params.has('c'), 'Search params object has name "c"'); - assert_true(params.has('first'), 'Search params object has name "first"'); - assert_false(params.has('d'), 'Search params object has no name "d"'); - params.delete('first'); - assert_false(params.has('first'), 'Search params object has no name "first"'); -}, 'has() following delete()'); -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-searchparams-set.js b/test/parallel/test-whatwg-url-searchparams-set.js deleted file mode 100644 index 0d43678427c23f..00000000000000 --- a/test/parallel/test-whatwg-url-searchparams-set.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -require('../common'); -const URLSearchParams = require('url').URLSearchParams; -const { test, assert_equals, assert_true } = require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/8791bed/url/urlsearchparams-set.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -test(function() { - var params = new URLSearchParams('a=b&c=d'); - params.set('a', 'B'); - assert_equals(params + '', 'a=B&c=d'); - params = new URLSearchParams('a=b&c=d&a=e'); - params.set('a', 'B'); - assert_equals(params + '', 'a=B&c=d') - params.set('e', 'f'); - assert_equals(params + '', 'a=B&c=d&e=f') -}, 'Set basics'); - -test(function() { - var params = new URLSearchParams('a=1&a=2&a=3'); - assert_true(params.has('a'), 'Search params object has name "a"'); - assert_equals(params.get('a'), '1', 'Search params object has name "a" with value "1"'); - params.set('first', 4); - assert_true(params.has('a'), 'Search params object has name "a"'); - assert_equals(params.get('a'), '1', 'Search params object has name "a" with value "1"'); - params.set('a', 4); - assert_true(params.has('a'), 'Search params object has name "a"'); - assert_equals(params.get('a'), '4', 'Search params object has name "a" with value "4"'); -}, 'URLSearchParams.set'); -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-searchparams-sort.js b/test/parallel/test-whatwg-url-searchparams-sort.js deleted file mode 100644 index 65dd23a6daba57..00000000000000 --- a/test/parallel/test-whatwg-url-searchparams-sort.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict'; - -require('../common'); -const { URL, URLSearchParams } = require('url'); -const { test, assert_equals, assert_array_equals } = require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/70a0898763/url/urlsearchparams-sort.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -[ - { - "input": "z=b&a=b&z=a&a=a", - "output": [["a", "b"], ["a", "a"], ["z", "b"], ["z", "a"]] - }, - { - "input": "\uFFFD=x&\uFFFC&\uFFFD=a", - "output": [["\uFFFC", ""], ["\uFFFD", "x"], ["\uFFFD", "a"]] - }, - { - "input": "ffi&🌈", // 🌈 > code point, but < code unit because two code units - "output": [["🌈", ""], ["ffi", ""]] - }, - { - "input": "é&e\uFFFD&e\u0301", - "output": [["e\u0301", ""], ["e\uFFFD", ""], ["é", ""]] - }, - { - "input": "z=z&a=a&z=y&a=b&z=x&a=c&z=w&a=d&z=v&a=e&z=u&a=f&z=t&a=g", - "output": [["a", "a"], ["a", "b"], ["a", "c"], ["a", "d"], ["a", "e"], ["a", "f"], ["a", "g"], ["z", "z"], ["z", "y"], ["z", "x"], ["z", "w"], ["z", "v"], ["z", "u"], ["z", "t"]] - } -].forEach((val) => { - test(() => { - let params = new URLSearchParams(val.input), - i = 0 - params.sort() - for(let param of params) { - assert_array_equals(param, val.output[i]) - i++ - } - }, `Parse and sort: ${val.input}`) - - test(() => { - let url = new URL(`?${val.input}`, "https://example/") - url.searchParams.sort() - let params = new URLSearchParams(url.search), - i = 0 - for(let param of params) { - assert_array_equals(param, val.output[i]) - i++ - } - }, `URL parse and sort: ${val.input}`) -}) - -test(function() { - const url = new URL("http://example.com/?") - url.searchParams.sort() - assert_equals(url.href, "http://example.com/") - assert_equals(url.search, "") -}, "Sorting non-existent params removes ? from URL") -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-searchparams-stringifier.js b/test/parallel/test-whatwg-url-searchparams-stringifier.js deleted file mode 100644 index e2b6faaabe85fc..00000000000000 --- a/test/parallel/test-whatwg-url-searchparams-stringifier.js +++ /dev/null @@ -1,123 +0,0 @@ -'use strict'; - -require('../common'); -const URLSearchParams = require('url').URLSearchParams; -const { test, assert_equals } = require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/8791bed/url/urlsearchparams-stringifier.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -test(function() { - var params = new URLSearchParams(); - params.append('a', 'b c'); - assert_equals(params + '', 'a=b+c'); - params.delete('a'); - params.append('a b', 'c'); - assert_equals(params + '', 'a+b=c'); -}, 'Serialize space'); - -test(function() { - var params = new URLSearchParams(); - params.append('a', ''); - assert_equals(params + '', 'a='); - params.append('a', ''); - assert_equals(params + '', 'a=&a='); - params.append('', 'b'); - assert_equals(params + '', 'a=&a=&=b'); - params.append('', ''); - assert_equals(params + '', 'a=&a=&=b&='); - params.append('', ''); - assert_equals(params + '', 'a=&a=&=b&=&='); -}, 'Serialize empty value'); - -test(function() { - var params = new URLSearchParams(); - params.append('', 'b'); - assert_equals(params + '', '=b'); - params.append('', 'b'); - assert_equals(params + '', '=b&=b'); -}, 'Serialize empty name'); - -test(function() { - var params = new URLSearchParams(); - params.append('', ''); - assert_equals(params + '', '='); - params.append('', ''); - assert_equals(params + '', '=&='); -}, 'Serialize empty name and value'); - -test(function() { - var params = new URLSearchParams(); - params.append('a', 'b+c'); - assert_equals(params + '', 'a=b%2Bc'); - params.delete('a'); - params.append('a+b', 'c'); - assert_equals(params + '', 'a%2Bb=c'); -}, 'Serialize +'); - -test(function() { - var params = new URLSearchParams(); - params.append('=', 'a'); - assert_equals(params + '', '%3D=a'); - params.append('b', '='); - assert_equals(params + '', '%3D=a&b=%3D'); -}, 'Serialize ='); - -test(function() { - var params = new URLSearchParams(); - params.append('&', 'a'); - assert_equals(params + '', '%26=a'); - params.append('b', '&'); - assert_equals(params + '', '%26=a&b=%26'); -}, 'Serialize &'); - -test(function() { - var params = new URLSearchParams(); - params.append('a', '*-._'); - assert_equals(params + '', 'a=*-._'); - params.delete('a'); - params.append('*-._', 'c'); - assert_equals(params + '', '*-._=c'); -}, 'Serialize *-._'); - -test(function() { - var params = new URLSearchParams(); - params.append('a', 'b%c'); - assert_equals(params + '', 'a=b%25c'); - params.delete('a'); - params.append('a%b', 'c'); - assert_equals(params + '', 'a%25b=c'); -}, 'Serialize %'); - -test(function() { - var params = new URLSearchParams(); - params.append('a', 'b\0c'); - assert_equals(params + '', 'a=b%00c'); - params.delete('a'); - params.append('a\0b', 'c'); - assert_equals(params + '', 'a%00b=c'); -}, 'Serialize \\0'); - -test(function() { - var params = new URLSearchParams(); - params.append('a', 'b\uD83D\uDCA9c'); - assert_equals(params + '', 'a=b%F0%9F%92%A9c'); - params.delete('a'); - params.append('a\uD83D\uDCA9b', 'c'); - assert_equals(params + '', 'a%F0%9F%92%A9b=c'); -}, 'Serialize \uD83D\uDCA9'); // Unicode Character 'PILE OF POO' (U+1F4A9) - -test(function() { - var params; - params = new URLSearchParams('a=b&c=d&&e&&'); - assert_equals(params.toString(), 'a=b&c=d&e='); - params = new URLSearchParams('a = b &a=b&c=d%20'); - assert_equals(params.toString(), 'a+=+b+&a=b&c=d+'); - // The lone '=' _does_ survive the roundtrip. - params = new URLSearchParams('a=&a=b'); - assert_equals(params.toString(), 'a=&a=b'); -}, 'URLSearchParams.toString'); -/* eslint-enable */ diff --git a/test/parallel/test-whatwg-url-tojson.js b/test/parallel/test-whatwg-url-tojson.js deleted file mode 100644 index 8e9a30c7e017e4..00000000000000 --- a/test/parallel/test-whatwg-url-tojson.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -require('../common'); -const URL = require('url').URL; -const { test, assert_equals } = require('../common/wpt'); - -/* The following tests are copied from WPT. Modifications to them should be - upstreamed first. Refs: - https://github.com/w3c/web-platform-tests/blob/02585db/url/url-tojson.html - License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html -*/ -/* eslint-disable */ -test(() => { - const a = new URL("https://example.com/") - assert_equals(JSON.stringify(a), "\"https://example.com/\"") -}) -/* eslint-enable */