mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
chore(ext/node): removed skipped compat test cases (#19109)
This commit is contained in:
parent
2a0c664840
commit
ab88dc2c68
13 changed files with 12 additions and 1821 deletions
|
@ -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",
|
||||
|
|
|
@ -446,6 +446,7 @@ module.exports = {
|
|||
getArrayBufferViews,
|
||||
getBufferSources,
|
||||
hasCrypto: true,
|
||||
hasIntl: true,
|
||||
hasMultiLocalhost() {
|
||||
return false;
|
||||
},
|
||||
|
|
|
@ -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'
|
||||
);
|
File diff suppressed because it is too large
Load diff
|
@ -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'
|
||||
}
|
||||
);
|
||||
}
|
|
@ -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'
|
||||
}
|
||||
);
|
||||
});
|
|
@ -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'
|
||||
}
|
||||
);
|
||||
});
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 {'));
|
|
@ -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);
|
||||
}
|
|
@ -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)}`);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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": "<a>", "area": "<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 */
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue