• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// Tests below are not from WPT.
4
5require('../common');
6const assert = require('assert');
7
8const params = new URLSearchParams('a=b&c=d');
9const keys = params.keys();
10
11assert.strictEqual(typeof keys[Symbol.iterator], 'function');
12assert.strictEqual(keys[Symbol.iterator](), keys);
13assert.deepStrictEqual(keys.next(), {
14  value: 'a',
15  done: false
16});
17assert.deepStrictEqual(keys.next(), {
18  value: 'c',
19  done: false
20});
21assert.deepStrictEqual(keys.next(), {
22  value: undefined,
23  done: true
24});
25assert.deepStrictEqual(keys.next(), {
26  value: undefined,
27  done: true
28});
29
30assert.throws(() => {
31  keys.next.call(undefined);
32}, {
33  code: 'ERR_INVALID_THIS',
34  name: 'TypeError',
35  message: 'Value of "this" must be of type URLSearchParamsIterator'
36});
37assert.throws(() => {
38  params.keys.call(undefined);
39}, {
40  code: 'ERR_INVALID_THIS',
41  name: 'TypeError',
42  message: 'Value of "this" must be of type URLSearchParams'
43});
44