node/test/parallel/test-whatwg-url-invalidthis.js
Matt Cowley 925a464cb8
url: remove #context from URLSearchParams
PR-URL: https://github.com/nodejs/node/pull/51520
Fixes: https://github.com/nodejs/node/issues/51518
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2024-01-24 14:36:36 +00:00

63 lines
1.2 KiB
JavaScript

'use strict';
require('../common');
const { URL } = require('url');
const assert = require('assert');
[
'toString',
'toJSON',
].forEach((i) => {
assert.throws(() => Reflect.apply(URL.prototype[i], [], {}), {
name: 'TypeError',
message: /Receiver must be an instance of class/,
});
});
[
'href',
'search',
].forEach((i) => {
assert.throws(() => Reflect.get(URL.prototype, i, {}), {
name: 'TypeError',
message: /Receiver must be an instance of class/,
});
assert.throws(() => Reflect.set(URL.prototype, i, null, {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
});
[
'protocol',
'username',
'password',
'host',
'hostname',
'port',
'pathname',
'hash',
].forEach((i) => {
assert.throws(() => Reflect.get(URL.prototype, i, {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
assert.throws(() => Reflect.set(URL.prototype, i, null, {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
});
[
'origin',
'searchParams',
].forEach((i) => {
assert.throws(() => Reflect.get(URL.prototype, i, {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
});