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