2017-01-23 00:01:36 +09:00
|
|
|
'use strict';
|
|
|
|
|
2018-08-22 03:27:56 +08:00
|
|
|
// Tests below are not from WPT.
|
|
|
|
|
2017-04-21 11:54:58 -07:00
|
|
|
const common = require('../common');
|
2017-01-23 00:01:36 +09:00
|
|
|
const assert = require('assert');
|
|
|
|
const URLSearchParams = require('url').URLSearchParams;
|
|
|
|
|
|
|
|
const params = new URLSearchParams('a=b&c=d');
|
|
|
|
const keys = params.keys();
|
|
|
|
|
|
|
|
assert.strictEqual(typeof keys[Symbol.iterator], 'function');
|
|
|
|
assert.strictEqual(keys[Symbol.iterator](), keys);
|
|
|
|
assert.deepStrictEqual(keys.next(), {
|
|
|
|
value: 'a',
|
|
|
|
done: false
|
|
|
|
});
|
|
|
|
assert.deepStrictEqual(keys.next(), {
|
|
|
|
value: 'c',
|
|
|
|
done: false
|
|
|
|
});
|
|
|
|
assert.deepStrictEqual(keys.next(), {
|
|
|
|
value: undefined,
|
|
|
|
done: true
|
|
|
|
});
|
|
|
|
assert.deepStrictEqual(keys.next(), {
|
|
|
|
value: undefined,
|
|
|
|
done: true
|
|
|
|
});
|
|
|
|
|
2017-12-06 22:16:44 +05:30
|
|
|
common.expectsError(() => {
|
2017-01-23 00:01:36 +09:00
|
|
|
keys.next.call(undefined);
|
2017-12-06 22:16:44 +05:30
|
|
|
}, {
|
2017-04-21 11:54:58 -07:00
|
|
|
code: 'ERR_INVALID_THIS',
|
|
|
|
type: TypeError,
|
|
|
|
message: 'Value of "this" must be of type URLSearchParamsIterator'
|
2017-12-06 22:16:44 +05:30
|
|
|
});
|
|
|
|
common.expectsError(() => {
|
2017-01-23 00:01:36 +09:00
|
|
|
params.keys.call(undefined);
|
2017-12-06 22:16:44 +05:30
|
|
|
}, {
|
2017-04-21 11:54:58 -07:00
|
|
|
code: 'ERR_INVALID_THIS',
|
|
|
|
type: TypeError,
|
|
|
|
message: 'Value of "this" must be of type URLSearchParams'
|
2017-12-06 22:16:44 +05:30
|
|
|
});
|