gecko-dev/testing/web-platform/tests/WebIDL/ecmascript-binding/default-iterator-object.html
Timothy Gu ca19e5818e Bug 1441399 [wpt PR 8796] - [WebIDL] Add tests for iterator objects and prototypes, a=testonly
Automatic update from web-platform-tests[WebIDL] Add tests for iterator objects and prototypes (#8796)

wpt-commits: 73f03e31264cbe8acc554da744121e12ffe75baa
wpt-pr: 8796
wpt-commits: 73f03e31264cbe8acc554da744121e12ffe75baa
wpt-pr: 8796
2018-03-31 22:26:07 +01:00

27 lines
1.2 KiB
HTML

<!doctype html>
<meta charset="utf-8">
<title>Default iterator objects</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
const iterator1 = new URLSearchParams()[Symbol.iterator]();
const iterator2 = new URLSearchParams().keys();
const iterator3 = new URLSearchParams().values();
const iterator4 = new URLSearchParams().entries();
assert_equals(Object.getPrototypeOf(iterator1), Object.getPrototypeOf(iterator2));
assert_equals(Object.getPrototypeOf(iterator1), Object.getPrototypeOf(iterator3));
assert_equals(Object.getPrototypeOf(iterator1), Object.getPrototypeOf(iterator4));
}, "Default iterator objects for an interface have the same prototype");
test(() => {
const iterator = new URLSearchParams().entries();
assert_equals(Object.prototype.toString.call(iterator), "[object URLSearchParams Iterator]");
}, "Object.prototype.toString returns correct value");
test(() => {
const iterator = new URLSearchParams().entries();
assert_equals(iterator[Symbol.toStringTag], "URLSearchParams Iterator");
assert_equals(Object.getOwnPropertyDescriptor(iterator, Symbol.toStringTag), undefined);
}, "@@toStringTag has correct value from prototype");
</script>