1'use strict';
2
3require('../common');
4
5const { URL } = require('url');
6const assert = require('assert');
7
8[
9  'toString',
10  'toJSON',
11].forEach((i) => {
12  assert.throws(() => Reflect.apply(URL.prototype[i], [], {}), {
13    code: 'ERR_INVALID_THIS',
14  });
15});
16
17[
18  'href',
19  'protocol',
20  'username',
21  'password',
22  'host',
23  'hostname',
24  'port',
25  'pathname',
26  'search',
27  'hash',
28].forEach((i) => {
29  assert.throws(() => Reflect.get(URL.prototype, i, {}), {
30    code: 'ERR_INVALID_THIS',
31  });
32
33  assert.throws(() => Reflect.set(URL.prototype, i, null, {}), {
34    code: 'ERR_INVALID_THIS',
35  });
36});
37
38[
39  'origin',
40  'searchParams',
41].forEach((i) => {
42  assert.throws(() => Reflect.get(URL.prototype, i, {}), {
43    code: 'ERR_INVALID_THIS',
44  });
45});
46