• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// Tests below are not from WPT.
4
5const common = require('../common');
6if (!common.hasIntl) {
7  // A handful of the tests fail when ICU is not included.
8  common.skip('missing Intl');
9}
10
11const util = require('util');
12const assert = require('assert');
13
14const url = new URL('https://username:password@host.name:8080/path/name/?que=ry#hash');
15
16assert.strictEqual(
17  util.inspect(url),
18  `URL {
19  href: 'https://username:password@host.name:8080/path/name/?que=ry#hash',
20  origin: 'https://host.name:8080',
21  protocol: 'https:',
22  username: 'username',
23  password: 'password',
24  host: 'host.name:8080',
25  hostname: 'host.name',
26  port: '8080',
27  pathname: '/path/name/',
28  search: '?que=ry',
29  searchParams: URLSearchParams { 'que' => 'ry' },
30  hash: '#hash'
31}`);
32
33assert.strictEqual(
34  util.inspect(url, { showHidden: true }),
35  `URL {
36  href: 'https://username:password@host.name:8080/path/name/?que=ry#hash',
37  origin: 'https://host.name:8080',
38  protocol: 'https:',
39  username: 'username',
40  password: 'password',
41  host: 'host.name:8080',
42  hostname: 'host.name',
43  port: '8080',
44  pathname: '/path/name/',
45  search: '?que=ry',
46  searchParams: URLSearchParams { 'que' => 'ry' },
47  hash: '#hash',
48  [Symbol(context)]: URLContext {
49    href: 'https://username:password@host.name:8080/path/name/?que=ry#hash',
50    protocol_end: 6,
51    username_end: 16,
52    host_start: 25,
53    host_end: 35,
54    pathname_start: 40,
55    search_start: 51,
56    hash_start: 58,
57    port: 8080,
58    scheme_type: 2,
59    [hasPort]: [Getter],
60    [hasSearch]: [Getter],
61    [hasHash]: [Getter]
62  }
63}`);
64
65assert.strictEqual(
66  util.inspect({ a: url }, { depth: 0 }),
67  '{ a: [URL] }');
68
69class MyURL extends URL {}
70assert(util.inspect(new MyURL(url.href)).startsWith('MyURL {'));
71