diff --git a/cli/tests/node_compat/config.jsonc b/cli/tests/node_compat/config.jsonc index 81463bcaf5..2146daf926 100644 --- a/cli/tests/node_compat/config.jsonc +++ b/cli/tests/node_compat/config.jsonc @@ -610,9 +610,7 @@ "test-url-domain-ascii-unicode.js", "test-url-fileurltopath.js", "test-url-format-invalid-input.js", - "test-url-format-whatwg.js", "test-url-format.js", - "test-url-parse-format.js", "test-url-parse-invalid-input.js", "test-url-parse-query.js", "test-url-pathtofileurl.js", @@ -635,25 +633,17 @@ "test-vm-static-this.js", "test-webcrypto-sign-verify.js", "test-whatwg-encoding-custom-api-basics.js", - "test-whatwg-encoding-custom-fatal-streaming.js", - "test-whatwg-encoding-custom-textdecoder-fatal.js", "test-whatwg-encoding-custom-textdecoder-ignorebom.js", "test-whatwg-encoding-custom-textdecoder-streaming.js", - "test-whatwg-encoding-custom-textdecoder-utf16-surrogates.js", "test-whatwg-events-add-event-listener-options-passive.js", "test-whatwg-events-add-event-listener-options-signal.js", "test-whatwg-events-customevent.js", "test-whatwg-url-custom-deepequal.js", - "test-whatwg-url-custom-domainto.js", "test-whatwg-url-custom-global.js", "test-whatwg-url-custom-href-side-effect.js", - "test-whatwg-url-custom-inspect.js", - "test-whatwg-url-custom-parsing.js", - "test-whatwg-url-custom-setters.js", "test-whatwg-url-custom-tostringtag.js", "test-whatwg-url-override-hostname.js", "test-whatwg-url-properties.js", - "test-whatwg-url-toascii.js", "test-zlib-close-after-error.js", "test-zlib-close-after-write.js", "test-zlib-convenience-methods.js", diff --git a/cli/tests/node_compat/test/common/index.js b/cli/tests/node_compat/test/common/index.js index 491dabd2f3..0f6019746e 100644 --- a/cli/tests/node_compat/test/common/index.js +++ b/cli/tests/node_compat/test/common/index.js @@ -446,6 +446,7 @@ module.exports = { getArrayBufferViews, getBufferSources, hasCrypto: true, + hasIntl: true, hasMultiLocalhost() { return false; }, diff --git a/cli/tests/node_compat/test/parallel/test-url-format-whatwg.js b/cli/tests/node_compat/test/parallel/test-url-format-whatwg.js deleted file mode 100644 index ea099f494c..0000000000 --- a/cli/tests/node_compat/test/parallel/test-url-format-whatwg.js +++ /dev/null @@ -1,149 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 18.12.1 -// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually - -'use strict'; - -const common = require('../common'); -if (!common.hasIntl) - common.skip('missing Intl'); - -const assert = require('assert'); -const url = require('url'); - -const myURL = new URL('http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b#c'); - -assert.strictEqual( - url.format(myURL), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, {}), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -{ - [true, 1, 'test', Infinity].forEach((value) => { - assert.throws( - () => url.format(myURL, value), - { - code: 'ERR_INVALID_ARG_TYPE', - name: 'TypeError', - message: 'The "options" argument must be of type object.' + - common.invalidArgTypeHelper(value) - } - ); - }); -} - -// Any falsy value other than undefined will be treated as false. -// Any truthy value will be treated as true. - -assert.strictEqual( - url.format(myURL, { auth: false }), - 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { auth: '' }), - 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { auth: 0 }), - 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { auth: 1 }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { auth: {} }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { fragment: false }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b' -); - -assert.strictEqual( - url.format(myURL, { fragment: '' }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b' -); - -assert.strictEqual( - url.format(myURL, { fragment: 0 }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b' -); - -assert.strictEqual( - url.format(myURL, { fragment: 1 }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { fragment: {} }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { search: false }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a#c' -); - -assert.strictEqual( - url.format(myURL, { search: '' }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a#c' -); - -assert.strictEqual( - url.format(myURL, { search: 0 }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a#c' -); - -assert.strictEqual( - url.format(myURL, { search: 1 }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { search: {} }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { unicode: true }), - 'http://user:pass@理容ナカムラ.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { unicode: 1 }), - 'http://user:pass@理容ナカムラ.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { unicode: {} }), - 'http://user:pass@理容ナカムラ.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { unicode: false }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(myURL, { unicode: 0 }), - 'http://user:pass@xn--lck1c3crb1723bpq4a.com/a?a=b#c' -); - -assert.strictEqual( - url.format(new URL('http://user:pass@xn--0zwm56d.com:8080/path'), { unicode: true }), - 'http://user:pass@测试.com:8080/path' -); diff --git a/cli/tests/node_compat/test/parallel/test-url-parse-format.js b/cli/tests/node_compat/test/parallel/test-url-parse-format.js deleted file mode 100644 index 7079857bd5..0000000000 --- a/cli/tests/node_compat/test/parallel/test-url-parse-format.js +++ /dev/null @@ -1,1053 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 18.12.1 -// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually - -'use strict'; -const common = require('../common'); - -if (!common.hasIntl) - common.skip('missing Intl'); - -const assert = require('assert'); -const inspect = require('util').inspect; - -const url = require('url'); - -// URLs to parse, and expected data -// { url : parsed } -const parseTests = { - '//some_path': { - href: '//some_path', - pathname: '//some_path', - path: '//some_path' - }, - - 'http:\\\\evil-phisher\\foo.html#h\\a\\s\\h': { - protocol: 'http:', - slashes: true, - host: 'evil-phisher', - hostname: 'evil-phisher', - pathname: '/foo.html', - path: '/foo.html', - hash: '#h%5Ca%5Cs%5Ch', - href: 'http://evil-phisher/foo.html#h%5Ca%5Cs%5Ch' - }, - - 'http:\\\\evil-phisher\\foo.html?json="\\"foo\\""#h\\a\\s\\h': { - protocol: 'http:', - slashes: true, - host: 'evil-phisher', - hostname: 'evil-phisher', - pathname: '/foo.html', - search: '?json=%22%5C%22foo%5C%22%22', - query: 'json=%22%5C%22foo%5C%22%22', - path: '/foo.html?json=%22%5C%22foo%5C%22%22', - hash: '#h%5Ca%5Cs%5Ch', - href: 'http://evil-phisher/foo.html?json=%22%5C%22foo%5C%22%22#h%5Ca%5Cs%5Ch' - }, - - 'http:\\\\evil-phisher\\foo.html#h\\a\\s\\h?blarg': { - protocol: 'http:', - slashes: true, - host: 'evil-phisher', - hostname: 'evil-phisher', - pathname: '/foo.html', - path: '/foo.html', - hash: '#h%5Ca%5Cs%5Ch?blarg', - href: 'http://evil-phisher/foo.html#h%5Ca%5Cs%5Ch?blarg' - }, - - - 'http:\\\\evil-phisher\\foo.html': { - protocol: 'http:', - slashes: true, - host: 'evil-phisher', - hostname: 'evil-phisher', - pathname: '/foo.html', - path: '/foo.html', - href: 'http://evil-phisher/foo.html' - }, - - 'HTTP://www.example.com/': { - href: 'http://www.example.com/', - protocol: 'http:', - slashes: true, - host: 'www.example.com', - hostname: 'www.example.com', - pathname: '/', - path: '/' - }, - - 'HTTP://www.example.com': { - href: 'http://www.example.com/', - protocol: 'http:', - slashes: true, - host: 'www.example.com', - hostname: 'www.example.com', - pathname: '/', - path: '/' - }, - - 'http://www.ExAmPlE.com/': { - href: 'http://www.example.com/', - protocol: 'http:', - slashes: true, - host: 'www.example.com', - hostname: 'www.example.com', - pathname: '/', - path: '/' - }, - - 'http://user:pw@www.ExAmPlE.com/': { - href: 'http://user:pw@www.example.com/', - protocol: 'http:', - slashes: true, - auth: 'user:pw', - host: 'www.example.com', - hostname: 'www.example.com', - pathname: '/', - path: '/' - }, - - 'http://USER:PW@www.ExAmPlE.com/': { - href: 'http://USER:PW@www.example.com/', - protocol: 'http:', - slashes: true, - auth: 'USER:PW', - host: 'www.example.com', - hostname: 'www.example.com', - pathname: '/', - path: '/' - }, - - 'http://user@www.example.com/': { - href: 'http://user@www.example.com/', - protocol: 'http:', - slashes: true, - auth: 'user', - host: 'www.example.com', - hostname: 'www.example.com', - pathname: '/', - path: '/' - }, - - 'http://user%3Apw@www.example.com/': { - href: 'http://user:pw@www.example.com/', - protocol: 'http:', - slashes: true, - auth: 'user:pw', - host: 'www.example.com', - hostname: 'www.example.com', - pathname: '/', - path: '/' - }, - - 'http://x.com/path?that\'s#all, folks': { - href: 'http://x.com/path?that%27s#all,%20folks', - protocol: 'http:', - slashes: true, - host: 'x.com', - hostname: 'x.com', - search: '?that%27s', - query: 'that%27s', - pathname: '/path', - hash: '#all,%20folks', - path: '/path?that%27s' - }, - - 'HTTP://X.COM/Y': { - href: 'http://x.com/Y', - protocol: 'http:', - slashes: true, - host: 'x.com', - hostname: 'x.com', - pathname: '/Y', - path: '/Y' - }, - - // Whitespace in the front - ' http://www.example.com/': { - href: 'http://www.example.com/', - protocol: 'http:', - slashes: true, - host: 'www.example.com', - hostname: 'www.example.com', - pathname: '/', - path: '/' - }, - - // + not an invalid host character - // per https://url.spec.whatwg.org/#host-parsing - 'http://x.y.com+a/b/c': { - href: 'http://x.y.com+a/b/c', - protocol: 'http:', - slashes: true, - host: 'x.y.com+a', - hostname: 'x.y.com+a', - pathname: '/b/c', - path: '/b/c' - }, - - // An unexpected invalid char in the hostname. - 'HtTp://x.y.cOm;a/b/c?d=e#f gi': { - href: 'http://x.y.com/;a/b/c?d=e#f%20g%3Ch%3Ei', - protocol: 'http:', - slashes: true, - host: 'x.y.com', - hostname: 'x.y.com', - pathname: ';a/b/c', - search: '?d=e', - query: 'd=e', - hash: '#f%20g%3Ch%3Ei', - path: ';a/b/c?d=e' - }, - - // Make sure that we don't accidentally lcast the path parts. - 'HtTp://x.y.cOm;A/b/c?d=e#f gi': { - href: 'http://x.y.com/;A/b/c?d=e#f%20g%3Ch%3Ei', - protocol: 'http:', - slashes: true, - host: 'x.y.com', - hostname: 'x.y.com', - pathname: ';A/b/c', - search: '?d=e', - query: 'd=e', - hash: '#f%20g%3Ch%3Ei', - path: ';A/b/c?d=e' - }, - - 'http://x...y...#p': { - href: 'http://x...y.../#p', - protocol: 'http:', - slashes: true, - host: 'x...y...', - hostname: 'x...y...', - hash: '#p', - pathname: '/', - path: '/' - }, - - 'http://x/p/"quoted"': { - href: 'http://x/p/%22quoted%22', - protocol: 'http:', - slashes: true, - host: 'x', - hostname: 'x', - pathname: '/p/%22quoted%22', - path: '/p/%22quoted%22' - }, - - ' Is a URL!': { - href: '%3Chttp://goo.corn/bread%3E%20Is%20a%20URL!', - pathname: '%3Chttp://goo.corn/bread%3E%20Is%20a%20URL!', - path: '%3Chttp://goo.corn/bread%3E%20Is%20a%20URL!' - }, - - 'http://www.narwhaljs.org/blog/categories?id=news': { - href: 'http://www.narwhaljs.org/blog/categories?id=news', - protocol: 'http:', - slashes: true, - host: 'www.narwhaljs.org', - hostname: 'www.narwhaljs.org', - search: '?id=news', - query: 'id=news', - pathname: '/blog/categories', - path: '/blog/categories?id=news' - }, - - 'http://mt0.google.com/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=': { - href: 'http://mt0.google.com/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=', - protocol: 'http:', - slashes: true, - host: 'mt0.google.com', - hostname: 'mt0.google.com', - pathname: '/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=', - path: '/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=' - }, - - 'http://mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=': { - href: 'http://mt0.google.com/vt/lyrs=m@114???&hl=en&src=api' + - '&x=2&y=2&z=3&s=', - protocol: 'http:', - slashes: true, - host: 'mt0.google.com', - hostname: 'mt0.google.com', - search: '???&hl=en&src=api&x=2&y=2&z=3&s=', - query: '??&hl=en&src=api&x=2&y=2&z=3&s=', - pathname: '/vt/lyrs=m@114', - path: '/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=' - }, - - 'http://user:pass@mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=': { - href: 'http://user:pass@mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=', - protocol: 'http:', - slashes: true, - host: 'mt0.google.com', - auth: 'user:pass', - hostname: 'mt0.google.com', - search: '???&hl=en&src=api&x=2&y=2&z=3&s=', - query: '??&hl=en&src=api&x=2&y=2&z=3&s=', - pathname: '/vt/lyrs=m@114', - path: '/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=' - }, - - 'file:///etc/passwd': { - href: 'file:///etc/passwd', - slashes: true, - protocol: 'file:', - pathname: '/etc/passwd', - hostname: '', - host: '', - path: '/etc/passwd' - }, - - 'file://localhost/etc/passwd': { - href: 'file://localhost/etc/passwd', - protocol: 'file:', - slashes: true, - pathname: '/etc/passwd', - hostname: 'localhost', - host: 'localhost', - path: '/etc/passwd' - }, - - 'file://foo/etc/passwd': { - href: 'file://foo/etc/passwd', - protocol: 'file:', - slashes: true, - pathname: '/etc/passwd', - hostname: 'foo', - host: 'foo', - path: '/etc/passwd' - }, - - 'file:///etc/node/': { - href: 'file:///etc/node/', - slashes: true, - protocol: 'file:', - pathname: '/etc/node/', - hostname: '', - host: '', - path: '/etc/node/' - }, - - 'file://localhost/etc/node/': { - href: 'file://localhost/etc/node/', - protocol: 'file:', - slashes: true, - pathname: '/etc/node/', - hostname: 'localhost', - host: 'localhost', - path: '/etc/node/' - }, - - 'file://foo/etc/node/': { - href: 'file://foo/etc/node/', - protocol: 'file:', - slashes: true, - pathname: '/etc/node/', - hostname: 'foo', - host: 'foo', - path: '/etc/node/' - }, - - 'http:/baz/../foo/bar': { - href: 'http:/baz/../foo/bar', - protocol: 'http:', - pathname: '/baz/../foo/bar', - path: '/baz/../foo/bar' - }, - - 'http://user:pass@example.com:8000/foo/bar?baz=quux#frag': { - href: 'http://user:pass@example.com:8000/foo/bar?baz=quux#frag', - protocol: 'http:', - slashes: true, - host: 'example.com:8000', - auth: 'user:pass', - port: '8000', - hostname: 'example.com', - hash: '#frag', - search: '?baz=quux', - query: 'baz=quux', - pathname: '/foo/bar', - path: '/foo/bar?baz=quux' - }, - - '//user:pass@example.com:8000/foo/bar?baz=quux#frag': { - href: '//user:pass@example.com:8000/foo/bar?baz=quux#frag', - slashes: true, - host: 'example.com:8000', - auth: 'user:pass', - port: '8000', - hostname: 'example.com', - hash: '#frag', - search: '?baz=quux', - query: 'baz=quux', - pathname: '/foo/bar', - path: '/foo/bar?baz=quux' - }, - - '/foo/bar?baz=quux#frag': { - href: '/foo/bar?baz=quux#frag', - hash: '#frag', - search: '?baz=quux', - query: 'baz=quux', - pathname: '/foo/bar', - path: '/foo/bar?baz=quux' - }, - - 'http:/foo/bar?baz=quux#frag': { - href: 'http:/foo/bar?baz=quux#frag', - protocol: 'http:', - hash: '#frag', - search: '?baz=quux', - query: 'baz=quux', - pathname: '/foo/bar', - path: '/foo/bar?baz=quux' - }, - - 'mailto:foo@bar.com?subject=hello': { - href: 'mailto:foo@bar.com?subject=hello', - protocol: 'mailto:', - host: 'bar.com', - auth: 'foo', - hostname: 'bar.com', - search: '?subject=hello', - query: 'subject=hello', - path: '?subject=hello' - }, - - 'javascript:alert(\'hello\');': { - href: 'javascript:alert(\'hello\');', - protocol: 'javascript:', - pathname: 'alert(\'hello\');', - path: 'alert(\'hello\');' - }, - - 'xmpp:isaacschlueter@jabber.org': { - href: 'xmpp:isaacschlueter@jabber.org', - protocol: 'xmpp:', - host: 'jabber.org', - auth: 'isaacschlueter', - hostname: 'jabber.org' - }, - - 'http://atpass:foo%40bar@127.0.0.1:8080/path?search=foo#bar': { - href: 'http://atpass:foo%40bar@127.0.0.1:8080/path?search=foo#bar', - protocol: 'http:', - slashes: true, - host: '127.0.0.1:8080', - auth: 'atpass:foo@bar', - hostname: '127.0.0.1', - port: '8080', - pathname: '/path', - search: '?search=foo', - query: 'search=foo', - hash: '#bar', - path: '/path?search=foo' - }, - - 'svn+ssh://foo/bar': { - href: 'svn+ssh://foo/bar', - host: 'foo', - hostname: 'foo', - protocol: 'svn+ssh:', - pathname: '/bar', - path: '/bar', - slashes: true - }, - - 'dash-test://foo/bar': { - href: 'dash-test://foo/bar', - host: 'foo', - hostname: 'foo', - protocol: 'dash-test:', - pathname: '/bar', - path: '/bar', - slashes: true - }, - - 'dash-test:foo/bar': { - href: 'dash-test:foo/bar', - host: 'foo', - hostname: 'foo', - protocol: 'dash-test:', - pathname: '/bar', - path: '/bar' - }, - - 'dot.test://foo/bar': { - href: 'dot.test://foo/bar', - host: 'foo', - hostname: 'foo', - protocol: 'dot.test:', - pathname: '/bar', - path: '/bar', - slashes: true - }, - - 'dot.test:foo/bar': { - href: 'dot.test:foo/bar', - host: 'foo', - hostname: 'foo', - protocol: 'dot.test:', - pathname: '/bar', - path: '/bar' - }, - - // IDNA tests - 'http://www.日本語.com/': { - href: 'http://www.xn--wgv71a119e.com/', - protocol: 'http:', - slashes: true, - host: 'www.xn--wgv71a119e.com', - hostname: 'www.xn--wgv71a119e.com', - pathname: '/', - path: '/' - }, - - 'http://example.Bücher.com/': { - href: 'http://example.xn--bcher-kva.com/', - protocol: 'http:', - slashes: true, - host: 'example.xn--bcher-kva.com', - hostname: 'example.xn--bcher-kva.com', - pathname: '/', - path: '/' - }, - - 'http://www.Äffchen.com/': { - href: 'http://www.xn--ffchen-9ta.com/', - protocol: 'http:', - slashes: true, - host: 'www.xn--ffchen-9ta.com', - hostname: 'www.xn--ffchen-9ta.com', - pathname: '/', - path: '/' - }, - - 'http://www.Äffchen.cOm;A/b/c?d=e#f gi': { - href: 'http://www.xn--ffchen-9ta.com/;A/b/c?d=e#f%20g%3Ch%3Ei', - protocol: 'http:', - slashes: true, - host: 'www.xn--ffchen-9ta.com', - hostname: 'www.xn--ffchen-9ta.com', - pathname: ';A/b/c', - search: '?d=e', - query: 'd=e', - hash: '#f%20g%3Ch%3Ei', - path: ';A/b/c?d=e' - }, - - 'http://SÉLIER.COM/': { - href: 'http://xn--slier-bsa.com/', - protocol: 'http:', - slashes: true, - host: 'xn--slier-bsa.com', - hostname: 'xn--slier-bsa.com', - pathname: '/', - path: '/' - }, - - 'http://ليهمابتكلموشعربي؟.ي؟/': { - href: 'http://xn--egbpdaj6bu4bxfgehfvwxn.xn--egb9f/', - protocol: 'http:', - slashes: true, - host: 'xn--egbpdaj6bu4bxfgehfvwxn.xn--egb9f', - hostname: 'xn--egbpdaj6bu4bxfgehfvwxn.xn--egb9f', - pathname: '/', - path: '/' - }, - - 'http://➡.ws/➡': { - href: 'http://xn--hgi.ws/➡', - protocol: 'http:', - slashes: true, - host: 'xn--hgi.ws', - hostname: 'xn--hgi.ws', - pathname: '/➡', - path: '/➡' - }, - - 'http://bucket_name.s3.amazonaws.com/image.jpg': { - protocol: 'http:', - slashes: true, - host: 'bucket_name.s3.amazonaws.com', - hostname: 'bucket_name.s3.amazonaws.com', - pathname: '/image.jpg', - href: 'http://bucket_name.s3.amazonaws.com/image.jpg', - path: '/image.jpg' - }, - - 'git+http://github.com/joyent/node.git': { - protocol: 'git+http:', - slashes: true, - host: 'github.com', - hostname: 'github.com', - pathname: '/joyent/node.git', - path: '/joyent/node.git', - href: 'git+http://github.com/joyent/node.git' - }, - - // If local1@domain1 is uses as a relative URL it may - // be parse into auth@hostname, but here there is no - // way to make it work in url.parse, I add the test to be explicit - 'local1@domain1': { - pathname: 'local1@domain1', - path: 'local1@domain1', - href: 'local1@domain1' - }, - - // While this may seem counter-intuitive, a browser will parse - // as a path. - 'www.example.com': { - href: 'www.example.com', - pathname: 'www.example.com', - path: 'www.example.com' - }, - - // ipv6 support - '[fe80::1]': { - href: '[fe80::1]', - pathname: '[fe80::1]', - path: '[fe80::1]' - }, - - 'coap://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]': { - protocol: 'coap:', - slashes: true, - host: '[fedc:ba98:7654:3210:fedc:ba98:7654:3210]', - hostname: 'fedc:ba98:7654:3210:fedc:ba98:7654:3210', - href: 'coap://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/', - pathname: '/', - path: '/' - }, - - 'coap://[1080:0:0:0:8:800:200C:417A]:61616/': { - protocol: 'coap:', - slashes: true, - host: '[1080:0:0:0:8:800:200c:417a]:61616', - port: '61616', - hostname: '1080:0:0:0:8:800:200c:417a', - href: 'coap://[1080:0:0:0:8:800:200c:417a]:61616/', - pathname: '/', - path: '/' - }, - - 'http://user:password@[3ffe:2a00:100:7031::1]:8080': { - protocol: 'http:', - slashes: true, - auth: 'user:password', - host: '[3ffe:2a00:100:7031::1]:8080', - port: '8080', - hostname: '3ffe:2a00:100:7031::1', - href: 'http://user:password@[3ffe:2a00:100:7031::1]:8080/', - pathname: '/', - path: '/' - }, - - 'coap://u:p@[::192.9.5.5]:61616/.well-known/r?n=Temperature': { - protocol: 'coap:', - slashes: true, - auth: 'u:p', - host: '[::192.9.5.5]:61616', - port: '61616', - hostname: '::192.9.5.5', - href: 'coap://u:p@[::192.9.5.5]:61616/.well-known/r?n=Temperature', - search: '?n=Temperature', - query: 'n=Temperature', - pathname: '/.well-known/r', - path: '/.well-known/r?n=Temperature' - }, - - // empty port - 'http://example.com:': { - protocol: 'http:', - slashes: true, - host: 'example.com', - hostname: 'example.com', - href: 'http://example.com/', - pathname: '/', - path: '/' - }, - - 'http://example.com:/a/b.html': { - protocol: 'http:', - slashes: true, - host: 'example.com', - hostname: 'example.com', - href: 'http://example.com/a/b.html', - pathname: '/a/b.html', - path: '/a/b.html' - }, - - 'http://example.com:?a=b': { - protocol: 'http:', - slashes: true, - host: 'example.com', - hostname: 'example.com', - href: 'http://example.com/?a=b', - search: '?a=b', - query: 'a=b', - pathname: '/', - path: '/?a=b' - }, - - 'http://example.com:#abc': { - protocol: 'http:', - slashes: true, - host: 'example.com', - hostname: 'example.com', - href: 'http://example.com/#abc', - hash: '#abc', - pathname: '/', - path: '/' - }, - - 'http://[fe80::1]:/a/b?a=b#abc': { - protocol: 'http:', - slashes: true, - host: '[fe80::1]', - hostname: 'fe80::1', - href: 'http://[fe80::1]/a/b?a=b#abc', - search: '?a=b', - query: 'a=b', - hash: '#abc', - pathname: '/a/b', - path: '/a/b?a=b' - }, - - 'http://-lovemonsterz.tumblr.com/rss': { - protocol: 'http:', - slashes: true, - host: '-lovemonsterz.tumblr.com', - hostname: '-lovemonsterz.tumblr.com', - href: 'http://-lovemonsterz.tumblr.com/rss', - pathname: '/rss', - path: '/rss', - }, - - 'http://-lovemonsterz.tumblr.com:80/rss': { - protocol: 'http:', - slashes: true, - port: '80', - host: '-lovemonsterz.tumblr.com:80', - hostname: '-lovemonsterz.tumblr.com', - href: 'http://-lovemonsterz.tumblr.com:80/rss', - pathname: '/rss', - path: '/rss', - }, - - 'http://user:pass@-lovemonsterz.tumblr.com/rss': { - protocol: 'http:', - slashes: true, - auth: 'user:pass', - host: '-lovemonsterz.tumblr.com', - hostname: '-lovemonsterz.tumblr.com', - href: 'http://user:pass@-lovemonsterz.tumblr.com/rss', - pathname: '/rss', - path: '/rss', - }, - - 'http://user:pass@-lovemonsterz.tumblr.com:80/rss': { - protocol: 'http:', - slashes: true, - auth: 'user:pass', - port: '80', - host: '-lovemonsterz.tumblr.com:80', - hostname: '-lovemonsterz.tumblr.com', - href: 'http://user:pass@-lovemonsterz.tumblr.com:80/rss', - pathname: '/rss', - path: '/rss', - }, - - 'http://_jabber._tcp.google.com/test': { - protocol: 'http:', - slashes: true, - host: '_jabber._tcp.google.com', - hostname: '_jabber._tcp.google.com', - href: 'http://_jabber._tcp.google.com/test', - pathname: '/test', - path: '/test', - }, - - 'http://user:pass@_jabber._tcp.google.com/test': { - protocol: 'http:', - slashes: true, - auth: 'user:pass', - host: '_jabber._tcp.google.com', - hostname: '_jabber._tcp.google.com', - href: 'http://user:pass@_jabber._tcp.google.com/test', - pathname: '/test', - path: '/test', - }, - - 'http://_jabber._tcp.google.com:80/test': { - protocol: 'http:', - slashes: true, - port: '80', - host: '_jabber._tcp.google.com:80', - hostname: '_jabber._tcp.google.com', - href: 'http://_jabber._tcp.google.com:80/test', - pathname: '/test', - path: '/test', - }, - - 'http://user:pass@_jabber._tcp.google.com:80/test': { - protocol: 'http:', - slashes: true, - auth: 'user:pass', - port: '80', - host: '_jabber._tcp.google.com:80', - hostname: '_jabber._tcp.google.com', - href: 'http://user:pass@_jabber._tcp.google.com:80/test', - pathname: '/test', - path: '/test', - }, - - 'http://x:1/\' <>"`/{}|\\^~`/': { - protocol: 'http:', - slashes: true, - host: 'x:1', - port: '1', - hostname: 'x', - pathname: '/%27%20%3C%3E%22%60/%7B%7D%7C/%5E~%60/', - path: '/%27%20%3C%3E%22%60/%7B%7D%7C/%5E~%60/', - href: 'http://x:1/%27%20%3C%3E%22%60/%7B%7D%7C/%5E~%60/' - }, - - 'http://a@b@c/': { - protocol: 'http:', - slashes: true, - auth: 'a@b', - host: 'c', - hostname: 'c', - href: 'http://a%40b@c/', - path: '/', - pathname: '/' - }, - - 'http://a@b?@c': { - protocol: 'http:', - slashes: true, - auth: 'a', - host: 'b', - hostname: 'b', - href: 'http://a@b/?@c', - path: '/?@c', - pathname: '/', - search: '?@c', - query: '@c' - }, - - 'http://a.b/\tbc\ndr\ref g"hq\'j?mn\\op^q=r`99{st|uv}wz': { - protocol: 'http:', - slashes: true, - host: 'a.b', - port: null, - hostname: 'a.b', - hash: null, - pathname: '/%09bc%0Adr%0Def%20g%22hq%27j%3Ckl%3E', - path: '/%09bc%0Adr%0Def%20g%22hq%27j%3Ckl%3E?mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz', - search: '?mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz', - query: 'mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz', - href: 'http://a.b/%09bc%0Adr%0Def%20g%22hq%27j%3Ckl%3E?mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz' - }, - - 'http://a\r" \t\n<\'b:b@c\r\nd/e?f': { - protocol: 'http:', - slashes: true, - auth: 'a\r" \t\n<\'b:b', - host: 'c', - port: null, - hostname: 'c', - hash: null, - search: '?f', - query: 'f', - pathname: '%0D%0Ad/e', - path: '%0D%0Ad/e?f', - href: 'http://a%0D%22%20%09%0A%3C\'b:b@c/%0D%0Ad/e?f' - }, - - // Git urls used by npm - 'git+ssh://git@github.com:npm/npm': { - protocol: 'git+ssh:', - slashes: true, - auth: 'git', - host: 'github.com', - port: null, - hostname: 'github.com', - hash: null, - search: null, - query: null, - pathname: '/:npm/npm', - path: '/:npm/npm', - href: 'git+ssh://git@github.com/:npm/npm' - }, - - 'https://*': { - protocol: 'https:', - slashes: true, - auth: null, - host: '', - port: null, - hostname: '', - hash: null, - search: null, - query: null, - pathname: '/*', - path: '/*', - href: 'https:///*' - }, - - // The following two URLs are the same, but they differ for a capital A. - // Verify that the protocol is checked in a case-insensitive manner. - 'javascript:alert(1);a=\x27@white-listed.com\x27': { - protocol: 'javascript:', - slashes: null, - auth: null, - host: null, - port: null, - hostname: null, - hash: null, - search: null, - query: null, - pathname: "alert(1);a='@white-listed.com'", - path: "alert(1);a='@white-listed.com'", - href: "javascript:alert(1);a='@white-listed.com'" - }, - - 'javAscript:alert(1);a=\x27@white-listed.com\x27': { - protocol: 'javascript:', - slashes: null, - auth: null, - host: null, - port: null, - hostname: null, - hash: null, - search: null, - query: null, - pathname: "alert(1);a='@white-listed.com'", - path: "alert(1);a='@white-listed.com'", - href: "javascript:alert(1);a='@white-listed.com'" - }, - - 'ws://www.example.com': { - protocol: 'ws:', - slashes: true, - hostname: 'www.example.com', - host: 'www.example.com', - pathname: '/', - path: '/', - href: 'ws://www.example.com/' - }, - - 'wss://www.example.com': { - protocol: 'wss:', - slashes: true, - hostname: 'www.example.com', - host: 'www.example.com', - pathname: '/', - path: '/', - href: 'wss://www.example.com/' - }, - - '//fhqwhgads@example.com/everybody-to-the-limit': { - protocol: null, - slashes: true, - auth: 'fhqwhgads', - host: 'example.com', - port: null, - hostname: 'example.com', - hash: null, - search: null, - query: null, - pathname: '/everybody-to-the-limit', - path: '/everybody-to-the-limit', - href: '//fhqwhgads@example.com/everybody-to-the-limit' - }, - - '//fhqwhgads@example.com/everybody#to-the-limit': { - protocol: null, - slashes: true, - auth: 'fhqwhgads', - host: 'example.com', - port: null, - hostname: 'example.com', - hash: '#to-the-limit', - search: null, - query: null, - pathname: '/everybody', - path: '/everybody', - href: '//fhqwhgads@example.com/everybody#to-the-limit' - }, - - '\bhttp://example.com/\b': { - protocol: 'http:', - slashes: true, - auth: null, - host: 'example.com', - port: null, - hostname: 'example.com', - hash: null, - search: null, - query: null, - pathname: '/', - path: '/', - href: 'http://example.com/' - } -}; - -for (const u in parseTests) { - let actual = url.parse(u); - const spaced = url.parse(` \t ${u}\n\t`); - let expected = Object.assign(new url.Url(), parseTests[u]); - - Object.keys(actual).forEach(function(i) { - if (expected[i] === undefined && actual[i] === null) { - expected[i] = null; - } - }); - - assert.deepStrictEqual( - actual, - expected, - `expected ${inspect(expected)}, got ${inspect(actual)}` - ); - assert.deepStrictEqual( - spaced, - expected, - `expected ${inspect(expected)}, got ${inspect(spaced)}` - ); - - expected = parseTests[u].href; - actual = url.format(parseTests[u]); - - assert.strictEqual(actual, expected, - `format(${u}) == ${u}\nactual:${actual}`); -} - -{ - const parsed = url.parse('http://nodejs.org/') - .resolveObject('jAvascript:alert(1);a=\x27@white-listed.com\x27'); - - const expected = Object.assign(new url.Url(), { - protocol: 'javascript:', - slashes: null, - auth: null, - host: null, - port: null, - hostname: null, - hash: null, - search: null, - query: null, - pathname: "alert(1);a='@white-listed.com'", - path: "alert(1);a='@white-listed.com'", - href: "javascript:alert(1);a='@white-listed.com'" - }); - - assert.deepStrictEqual(parsed, expected); -} diff --git a/cli/tests/node_compat/test/parallel/test-whatwg-encoding-custom-fatal-streaming.js b/cli/tests/node_compat/test/parallel/test-whatwg-encoding-custom-fatal-streaming.js deleted file mode 100644 index b3ad5f0585..0000000000 --- a/cli/tests/node_compat/test/parallel/test-whatwg-encoding-custom-fatal-streaming.js +++ /dev/null @@ -1,68 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 18.12.1 -// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually - -'use strict'; - -// From: https://github.com/w3c/web-platform-tests/blob/d74324b53c/encoding/textdecoder-fatal-streaming.html -// With the twist that we specifically test for Node.js error codes - -const common = require('../common'); -const assert = require('assert'); - -if (!common.hasIntl) - common.skip('missing Intl'); - -{ - [ - { encoding: 'utf-8', sequence: [0xC0] }, - { encoding: 'utf-16le', sequence: [0x00] }, - { encoding: 'utf-16be', sequence: [0x00] }, - ].forEach((testCase) => { - const data = new Uint8Array([testCase.sequence]); - assert.throws( - () => { - const decoder = new TextDecoder(testCase.encoding, { fatal: true }); - decoder.decode(data); - }, { - code: 'ERR_ENCODING_INVALID_ENCODED_DATA', - name: 'TypeError', - message: - `The encoded data was not valid for encoding ${testCase.encoding}` - } - ); - }); -} - -{ - const decoder = new TextDecoder('utf-16le', { fatal: true }); - const odd = new Uint8Array([0x00]); - const even = new Uint8Array([0x00, 0x00]); - - assert.throws( - () => { - decoder.decode(even, { stream: true }); - decoder.decode(odd); - }, { - code: 'ERR_ENCODING_INVALID_ENCODED_DATA', - name: 'TypeError', - message: - 'The encoded data was not valid for encoding utf-16le' - } - ); - - assert.throws( - () => { - decoder.decode(odd, { stream: true }); - decoder.decode(even); - }, { - code: 'ERR_ENCODING_INVALID_ENCODED_DATA', - name: 'TypeError', - message: - 'The encoded data was not valid for encoding utf-16le' - } - ); -} diff --git a/cli/tests/node_compat/test/parallel/test-whatwg-encoding-custom-textdecoder-fatal.js b/cli/tests/node_compat/test/parallel/test-whatwg-encoding-custom-textdecoder-fatal.js deleted file mode 100644 index 3a8aac4003..0000000000 --- a/cli/tests/node_compat/test/parallel/test-whatwg-encoding-custom-textdecoder-fatal.js +++ /dev/null @@ -1,91 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 18.12.1 -// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually - -'use strict'; - -// From: https://github.com/w3c/web-platform-tests/blob/39a67e2fff/encoding/textdecoder-fatal.html -// With the twist that we specifically test for Node.js error codes - -const common = require('../common'); - -if (!common.hasIntl) - common.skip('missing Intl'); - -const assert = require('assert'); - -const bad = [ - { encoding: 'utf-8', input: [0xFF], name: 'invalid code' }, - { encoding: 'utf-8', input: [0xC0], name: 'ends early' }, - { encoding: 'utf-8', input: [0xE0], name: 'ends early 2' }, - { encoding: 'utf-8', input: [0xC0, 0x00], name: 'invalid trail' }, - { encoding: 'utf-8', input: [0xC0, 0xC0], name: 'invalid trail 2' }, - { encoding: 'utf-8', input: [0xE0, 0x00], name: 'invalid trail 3' }, - { encoding: 'utf-8', input: [0xE0, 0xC0], name: 'invalid trail 4' }, - { encoding: 'utf-8', input: [0xE0, 0x80, 0x00], name: 'invalid trail 5' }, - { encoding: 'utf-8', input: [0xE0, 0x80, 0xC0], name: 'invalid trail 6' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x80, 0x80], - name: '> 0x10FFFF' }, - { encoding: 'utf-8', input: [0xFE, 0x80, 0x80, 0x80, 0x80, 0x80], - name: 'obsolete lead byte' }, - // Overlong encodings - { encoding: 'utf-8', input: [0xC0, 0x80], name: 'overlong U+0000 - 2 bytes' }, - { encoding: 'utf-8', input: [0xE0, 0x80, 0x80], - name: 'overlong U+0000 - 3 bytes' }, - { encoding: 'utf-8', input: [0xF0, 0x80, 0x80, 0x80], - name: 'overlong U+0000 - 4 bytes' }, - { encoding: 'utf-8', input: [0xF8, 0x80, 0x80, 0x80, 0x80], - name: 'overlong U+0000 - 5 bytes' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x80, 0x80], - name: 'overlong U+0000 - 6 bytes' }, - { encoding: 'utf-8', input: [0xC1, 0xBF], name: 'overlong U+007F - 2 bytes' }, - { encoding: 'utf-8', input: [0xE0, 0x81, 0xBF], - name: 'overlong U+007F - 3 bytes' }, - { encoding: 'utf-8', input: [0xF0, 0x80, 0x81, 0xBF], - name: 'overlong U+007F - 4 bytes' }, - { encoding: 'utf-8', input: [0xF8, 0x80, 0x80, 0x81, 0xBF], - name: 'overlong U+007F - 5 bytes' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x81, 0xBF], - name: 'overlong U+007F - 6 bytes' }, - { encoding: 'utf-8', input: [0xE0, 0x9F, 0xBF], - name: 'overlong U+07FF - 3 bytes' }, - { encoding: 'utf-8', input: [0xF0, 0x80, 0x9F, 0xBF], - name: 'overlong U+07FF - 4 bytes' }, - { encoding: 'utf-8', input: [0xF8, 0x80, 0x80, 0x9F, 0xBF], - name: 'overlong U+07FF - 5 bytes' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x9F, 0xBF], - name: 'overlong U+07FF - 6 bytes' }, - { encoding: 'utf-8', input: [0xF0, 0x8F, 0xBF, 0xBF], - name: 'overlong U+FFFF - 4 bytes' }, - { encoding: 'utf-8', input: [0xF8, 0x80, 0x8F, 0xBF, 0xBF], - name: 'overlong U+FFFF - 5 bytes' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x8F, 0xBF, 0xBF], - name: 'overlong U+FFFF - 6 bytes' }, - { encoding: 'utf-8', input: [0xF8, 0x84, 0x8F, 0xBF, 0xBF], - name: 'overlong U+10FFFF - 5 bytes' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x84, 0x8F, 0xBF, 0xBF], - name: 'overlong U+10FFFF - 6 bytes' }, - // UTF-16 surrogates encoded as code points in UTF-8 - { encoding: 'utf-8', input: [0xED, 0xA0, 0x80], name: 'lead surrogate' }, - { encoding: 'utf-8', input: [0xED, 0xB0, 0x80], name: 'trail surrogate' }, - { encoding: 'utf-8', input: [0xED, 0xA0, 0x80, 0xED, 0xB0, 0x80], - name: 'surrogate pair' }, - { encoding: 'utf-16le', input: [0x00], name: 'truncated code unit' }, - // Mismatched UTF-16 surrogates are exercised in utf16-surrogates.html - // FIXME: Add legacy encoding cases -]; - -bad.forEach((t) => { - assert.throws( - () => { - new TextDecoder(t.encoding, { fatal: true }) - .decode(new Uint8Array(t.input)); - }, { - code: 'ERR_ENCODING_INVALID_ENCODED_DATA', - name: 'TypeError' - } - ); -}); diff --git a/cli/tests/node_compat/test/parallel/test-whatwg-encoding-custom-textdecoder-utf16-surrogates.js b/cli/tests/node_compat/test/parallel/test-whatwg-encoding-custom-textdecoder-utf16-surrogates.js deleted file mode 100644 index afe542dfd9..0000000000 --- a/cli/tests/node_compat/test/parallel/test-whatwg-encoding-custom-textdecoder-utf16-surrogates.js +++ /dev/null @@ -1,63 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 18.12.1 -// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually - -'use strict'; - -// From: https://github.com/w3c/web-platform-tests/blob/39a67e2fff/encoding/textdecoder-utf16-surrogates.html -// With the twist that we specifically test for Node.js error codes - -const common = require('../common'); - -if (!common.hasIntl) - common.skip('missing Intl'); - -const assert = require('assert'); - -const bad = [ - { - encoding: 'utf-16le', - input: [0x00, 0xd8], - expected: '\uFFFD', - name: 'lone surrogate lead' - }, - { - encoding: 'utf-16le', - input: [0x00, 0xdc], - expected: '\uFFFD', - name: 'lone surrogate trail' - }, - { - encoding: 'utf-16le', - input: [0x00, 0xd8, 0x00, 0x00], - expected: '\uFFFD\u0000', - name: 'unmatched surrogate lead' - }, - { - encoding: 'utf-16le', - input: [0x00, 0xdc, 0x00, 0x00], - expected: '\uFFFD\u0000', - name: 'unmatched surrogate trail' - }, - { - encoding: 'utf-16le', - input: [0x00, 0xdc, 0x00, 0xd8], - expected: '\uFFFD\uFFFD', - name: 'swapped surrogate pair' - }, -]; - -bad.forEach((t) => { - assert.throws( - () => { - new TextDecoder(t.encoding, { fatal: true }) - .decode(new Uint8Array(t.input)); - }, { - code: 'ERR_ENCODING_INVALID_ENCODED_DATA', - name: 'TypeError' - } - ); -}); diff --git a/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-domainto.js b/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-domainto.js deleted file mode 100644 index 225f8a05c9..0000000000 --- a/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-domainto.js +++ /dev/null @@ -1,64 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 18.12.1 -// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually - -'use strict'; - -// Tests below are not from WPT. - -const common = require('../common'); - -if (!common.hasIntl) - common.skip('missing Intl'); - -const assert = require('assert'); -const { domainToASCII, domainToUnicode } = require('url'); - -const tests = require('../fixtures/url-idna'); -const fixtures = require('../common/fixtures'); -const wptToASCIITests = require( - fixtures.path('wpt', 'url', 'resources', 'toascii.json') -); - -{ - const expectedError = { code: 'ERR_MISSING_ARGS', name: 'TypeError' }; - assert.throws(() => domainToASCII(), expectedError); - assert.throws(() => domainToUnicode(), expectedError); - assert.strictEqual(domainToASCII(undefined), 'undefined'); - assert.strictEqual(domainToUnicode(undefined), 'undefined'); -} - -{ - for (const [i, { ascii, unicode }] of tests.entries()) { - assert.strictEqual(ascii, domainToASCII(unicode), - `domainToASCII(${i + 1})`); - assert.strictEqual(unicode, domainToUnicode(ascii), - `domainToUnicode(${i + 1})`); - assert.strictEqual(ascii, domainToASCII(domainToUnicode(ascii)), - `domainToASCII(domainToUnicode(${i + 1}))`); - assert.strictEqual(unicode, domainToUnicode(domainToASCII(unicode)), - `domainToUnicode(domainToASCII(${i + 1}))`); - } -} - -{ - for (const [i, test] of wptToASCIITests.entries()) { - if (typeof test === 'string') - continue; // skip comments - const { comment, input, output } = test; - let caseComment = `Case ${i + 1}`; - if (comment) - caseComment += ` (${comment})`; - if (output === null) { - assert.strictEqual(domainToASCII(input), '', caseComment); - assert.strictEqual(domainToUnicode(input), '', caseComment); - } else { - assert.strictEqual(domainToASCII(input), output, caseComment); - const roundtripped = domainToASCII(domainToUnicode(input)); - assert.strictEqual(roundtripped, output, caseComment); - } - } -} diff --git a/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-inspect.js b/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-inspect.js deleted file mode 100644 index 7a92d5ea3e..0000000000 --- a/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-inspect.js +++ /dev/null @@ -1,75 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 18.12.1 -// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually - -'use strict'; - -// Tests below are not from WPT. - -const common = require('../common'); -if (!common.hasIntl) { - // A handful of the tests fail when ICU is not included. - common.skip('missing Intl'); -} - -const util = require('util'); -const assert = require('assert'); - -const url = new URL('https://username:password@host.name:8080/path/name/?que=ry#hash'); - -assert.strictEqual( - util.inspect(url), - `URL { - href: 'https://username:password@host.name:8080/path/name/?que=ry#hash', - origin: 'https://host.name:8080', - protocol: 'https:', - username: 'username', - password: 'password', - host: 'host.name:8080', - hostname: 'host.name', - port: '8080', - pathname: '/path/name/', - search: '?que=ry', - searchParams: URLSearchParams { 'que' => 'ry' }, - hash: '#hash' -}`); - -assert.strictEqual( - util.inspect(url, { showHidden: true }), - `URL { - href: 'https://username:password@host.name:8080/path/name/?que=ry#hash', - origin: 'https://host.name:8080', - protocol: 'https:', - username: 'username', - password: 'password', - host: 'host.name:8080', - hostname: 'host.name', - port: '8080', - pathname: '/path/name/', - search: '?que=ry', - searchParams: URLSearchParams { 'que' => 'ry' }, - hash: '#hash', - cannotBeBase: false, - special: true, - [Symbol(context)]: URLContext { - flags: 2032, - scheme: 'https:', - username: 'username', - password: 'password', - host: 'host.name', - port: 8080, - path: [ 'path', 'name', '', [length]: 3 ], - query: 'que=ry', - fragment: 'hash' - } -}`); - -assert.strictEqual( - util.inspect({ a: url }, { depth: 0 }), - '{ a: [URL] }'); - -class MyURL extends URL {} -assert(util.inspect(new MyURL(url.href)).startsWith('MyURL {')); diff --git a/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-parsing.js b/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-parsing.js deleted file mode 100644 index 7af0759566..0000000000 --- a/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-parsing.js +++ /dev/null @@ -1,87 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 18.12.1 -// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually - -'use strict'; - -// Tests below are not from WPT. - -const common = require('../common'); -if (!common.hasIntl) { - // A handful of the tests fail when ICU is not included. - common.skip('missing Intl'); -} - -const assert = require('assert'); -const fixtures = require('../common/fixtures'); - -const tests = require( - fixtures.path('wpt', 'url', 'resources', 'urltestdata.json') -); - -const originalFailures = tests.filter((test) => test.failure); - -const typeFailures = [ - { input: '' }, - { input: 'test' }, - { input: undefined }, - { input: 0 }, - { input: true }, - { input: false }, - { input: null }, - { input: new Date() }, - { input: new RegExp() }, - { 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 = { code: 'ERR_INVALID_URL', name: 'TypeError' }; - -for (const test of failureTests) { - assert.throws( - () => new URL(test.input, test.base), - (error) => { - assert.throws(() => { throw error; }, expectedError); - assert.strictEqual(`${error}`, 'TypeError [ERR_INVALID_URL]: Invalid URL'); - assert.strictEqual(error.message, 'Invalid URL'); - return true; - }); -} - -const additional_tests = - require(fixtures.path('url-tests-additional.js')); - -for (const test of additional_tests) { - const url = new URL(test.url); - if (test.href) assert.strictEqual(url.href, test.href); - if (test.origin) assert.strictEqual(url.origin, test.origin); - if (test.protocol) assert.strictEqual(url.protocol, test.protocol); - if (test.username) assert.strictEqual(url.username, test.username); - if (test.password) assert.strictEqual(url.password, test.password); - if (test.hostname) assert.strictEqual(url.hostname, test.hostname); - if (test.host) assert.strictEqual(url.host, test.host); - if (test.port !== undefined) assert.strictEqual(url.port, test.port); - if (test.pathname) assert.strictEqual(url.pathname, test.pathname); - if (test.search) assert.strictEqual(url.search, test.search); - if (test.hash) assert.strictEqual(url.hash, test.hash); -} diff --git a/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-setters.js b/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-setters.js deleted file mode 100644 index c0b4e41bdc..0000000000 --- a/cli/tests/node_compat/test/parallel/test-whatwg-url-custom-setters.js +++ /dev/null @@ -1,67 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 18.12.1 -// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually - -'use strict'; - -// Tests below are not from WPT. - -const common = require('../common'); -if (!common.hasIntl) { - // A handful of the tests fail when ICU is not included. - common.skip('missing Intl'); -} - -const assert = require('assert'); -const { test, assert_equals } = require('../common/wpt').harness; -const fixtures = require('../common/fixtures'); - -// TODO(joyeecheung): we should submit these to the upstream -const additionalTestCases = - require(fixtures.path('url-setter-tests-additional.js')); - -{ - for (const attributeToBeSet in additionalTestCases) { - if (attributeToBeSet === 'comment') { - continue; - } - const testCases = additionalTestCases[attributeToBeSet]; - for (const testCase of testCases) { - let name = `Setting <${testCase.href}>.${attributeToBeSet}` + - ` = "${testCase.new_value}"`; - if ('comment' in testCase) { - name += ` ${testCase.comment}`; - } - test(function() { - const url = new URL(testCase.href); - url[attributeToBeSet] = testCase.new_value; - for (const attribute in testCase.expected) { - assert_equals(url[attribute], testCase.expected[attribute]); - } - }, `URL: ${name}`); - } - } -} - -{ - const url = new URL('http://example.com/'); - const obj = { - toString() { throw new Error('toString'); }, - valueOf() { throw new Error('valueOf'); } - }; - const sym = Symbol(); - const props = Object.getOwnPropertyDescriptors(Object.getPrototypeOf(url)); - for (const [name, { set }] of Object.entries(props)) { - if (set) { - assert.throws(() => url[name] = obj, - /^Error: toString$/, - `url.${name} = { toString() { throw ... } }`); - assert.throws(() => url[name] = sym, - /^TypeError: Cannot convert a Symbol value to a string$/, - `url.${name} = ${String(sym)}`); - } - } -} diff --git a/cli/tests/node_compat/test/parallel/test-whatwg-url-toascii.js b/cli/tests/node_compat/test/parallel/test-whatwg-url-toascii.js deleted file mode 100644 index 82ac527f1f..0000000000 --- a/cli/tests/node_compat/test/parallel/test-whatwg-url-toascii.js +++ /dev/null @@ -1,93 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 18.12.1 -// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually - -'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 fixtures = require('../common/fixtures'); -const { test, assert_equals, assert_throws } = require('../common/wpt').harness; - -const request = { - response: require( - fixtures.path('wpt', 'url', 'resources', 'toascii.json') - ) -}; - -// The following tests are copied from WPT. Modifications to them should be -// upstreamed first. -// Refs: https://github.com/w3c/web-platform-tests/blob/4839a0a804/url/toascii.window.js -// License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html - -/* eslint-disable */ -// async_test(t => { -// const request = new XMLHttpRequest() -// request.open("GET", "toascii.json") -// request.send() -// request.responseType = "json" -// request.onload = t.step_func_done(() => { - runTests(request.response) -// }) -// }, "Loading data…") - -function makeURL(type, input) { - input = "https://" + input + "/x" - if(type === "url") { - return new URL(input) - } else { - const url = document.createElement(type) - url.href = input - return url - } -} - -function runTests(tests) { - for(var i = 0, l = tests.length; i < l; i++) { - let hostTest = tests[i] - if (typeof hostTest === "string") { - continue // skip comments - } - const typeName = { "url": "URL", "a": "", "area": "" } - // ;["url", "a", "area"].forEach((type) => { - ;["url"].forEach((type) => { - test(() => { - if(hostTest.output !== null) { - const url = makeURL("url", hostTest.input) - assert_equals(url.host, hostTest.output) - assert_equals(url.hostname, hostTest.output) - assert_equals(url.pathname, "/x") - assert_equals(url.href, "https://" + hostTest.output + "/x") - } else { - if(type === "url") { - assert_throws(new TypeError, () => makeURL("url", hostTest.input)) - } else { - const url = makeURL(type, hostTest.input) - assert_equals(url.host, "") - assert_equals(url.hostname, "") - assert_equals(url.pathname, "") - assert_equals(url.href, "https://" + hostTest.input + "/x") - } - } - }, hostTest.input + " (using " + typeName[type] + ")") - ;["host", "hostname"].forEach((val) => { - test(() => { - const url = makeURL(type, "x") - url[val] = hostTest.input - if(hostTest.output !== null) { - assert_equals(url[val], hostTest.output) - } else { - assert_equals(url[val], "x") - } - }, hostTest.input + " (using " + typeName[type] + "." + val + ")") - }) - }) - } -} -/* eslint-enable */ diff --git a/tools/node_compat/TODO.md b/tools/node_compat/TODO.md index 0aae01edcd..650cd4b165 100644 --- a/tools/node_compat/TODO.md +++ b/tools/node_compat/TODO.md @@ -3,7 +3,7 @@ NOTE: This file should not be manually edited. Please edit 'cli/tests/node_compat/config.json' and run 'tools/node_compat/setup.ts' instead. -Total: 2924 +Total: 2934 - [abort/test-abort-backtrace.js](https://github.com/nodejs/node/tree/v18.12.1/test/abort/test-abort-backtrace.js) - [abort/test-abort-fatal-error.js](https://github.com/nodejs/node/tree/v18.12.1/test/abort/test-abort-fatal-error.js) @@ -2371,7 +2371,9 @@ Total: 2924 - [parallel/test-ttywrap-stack.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-ttywrap-stack.js) - [parallel/test-unhandled-exception-rethrow-error.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-unhandled-exception-rethrow-error.js) - [parallel/test-unicode-node-options.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-unicode-node-options.js) +- [parallel/test-url-format-whatwg.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-url-format-whatwg.js) - [parallel/test-url-null-char.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-url-null-char.js) +- [parallel/test-url-parse-format.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-url-parse-format.js) - [parallel/test-utf8-scripts.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-utf8-scripts.js) - [parallel/test-util-callbackify.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-util-callbackify.js) - [parallel/test-util-emit-experimental-warning.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-util-emit-experimental-warning.js) @@ -2496,10 +2498,13 @@ Total: 2924 - [parallel/test-webcrypto-wrap-unwrap.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-webcrypto-wrap-unwrap.js) - [parallel/test-webstream-encoding-inspect.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-webstream-encoding-inspect.js) - [parallel/test-webstream-readablestream-pipeto.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-webstream-readablestream-pipeto.js) +- [parallel/test-whatwg-encoding-custom-fatal-streaming.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-encoding-custom-fatal-streaming.js) - [parallel/test-whatwg-encoding-custom-internals.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-encoding-custom-internals.js) - [parallel/test-whatwg-encoding-custom-interop.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-encoding-custom-interop.js) - [parallel/test-whatwg-encoding-custom-textdecoder-api-invalid-label.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-encoding-custom-textdecoder-api-invalid-label.js) +- [parallel/test-whatwg-encoding-custom-textdecoder-fatal.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-encoding-custom-textdecoder-fatal.js) - [parallel/test-whatwg-encoding-custom-textdecoder-invalid-arg.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-encoding-custom-textdecoder-invalid-arg.js) +- [parallel/test-whatwg-encoding-custom-textdecoder-utf16-surrogates.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-encoding-custom-textdecoder-utf16-surrogates.js) - [parallel/test-whatwg-encoding-custom-textdecoder.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-encoding-custom-textdecoder.js) - [parallel/test-whatwg-events-event-constructors.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-events-event-constructors.js) - [parallel/test-whatwg-events-eventtarget-this-of-listener.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-events-eventtarget-this-of-listener.js) @@ -2507,6 +2512,9 @@ Total: 2924 - [parallel/test-whatwg-readablebytestream.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-readablebytestream.js) - [parallel/test-whatwg-readablestream.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-readablestream.js) - [parallel/test-whatwg-transformstream.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-transformstream.js) +- [parallel/test-whatwg-url-custom-domainto.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-custom-domainto.js) +- [parallel/test-whatwg-url-custom-inspect.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-custom-inspect.js) +- [parallel/test-whatwg-url-custom-parsing.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-custom-parsing.js) - [parallel/test-whatwg-url-custom-properties.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-custom-properties.js) - [parallel/test-whatwg-url-custom-searchparams-append.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-custom-searchparams-append.js) - [parallel/test-whatwg-url-custom-searchparams-constructor.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-custom-searchparams-constructor.js) @@ -2523,7 +2531,9 @@ Total: 2924 - [parallel/test-whatwg-url-custom-searchparams-stringifier.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-custom-searchparams-stringifier.js) - [parallel/test-whatwg-url-custom-searchparams-values.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-custom-searchparams-values.js) - [parallel/test-whatwg-url-custom-searchparams.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-custom-searchparams.js) +- [parallel/test-whatwg-url-custom-setters.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-custom-setters.js) - [parallel/test-whatwg-url-invalidthis.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-invalidthis.js) +- [parallel/test-whatwg-url-toascii.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-url-toascii.js) - [parallel/test-whatwg-webstreams-adapters-streambase.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-webstreams-adapters-streambase.js) - [parallel/test-whatwg-webstreams-adapters-to-readablestream.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-webstreams-adapters-to-readablestream.js) - [parallel/test-whatwg-webstreams-adapters-to-readablewritablepair.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-whatwg-webstreams-adapters-to-readablewritablepair.js)