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