• 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  cannotBeBase: false,
49  special: true,
50  [Symbol(context)]: URLContext {
51    flags: 2032,
52    scheme: 'https:',
53    username: 'username',
54    password: 'password',
55    host: 'host.name',
56    port: 8080,
57    path: [ 'path', 'name', '', [length]: 3 ],
58    query: 'que=ry',
59    fragment: 'hash'
60  }
61}`);
62
63assert.strictEqual(
64  util.inspect({ a: url }, { depth: 0 }),
65  '{ a: [URL] }');
66
67class MyURL extends URL {}
68assert(util.inspect(new MyURL(url.href)).startsWith('MyURL {'));
69