summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/language/statements/for-await-of/iterator-close-return-emulates-undefined-throws-when-called.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/annexB/language/statements/for-await-of/iterator-close-return-emulates-undefined-throws-when-called.js')
-rw-r--r--js/src/tests/test262/annexB/language/statements/for-await-of/iterator-close-return-emulates-undefined-throws-when-called.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/language/statements/for-await-of/iterator-close-return-emulates-undefined-throws-when-called.js b/js/src/tests/test262/annexB/language/statements/for-await-of/iterator-close-return-emulates-undefined-throws-when-called.js
new file mode 100644
index 0000000000..21860d325e
--- /dev/null
+++ b/js/src/tests/test262/annexB/language/statements/for-await-of/iterator-close-return-emulates-undefined-throws-when-called.js
@@ -0,0 +1,40 @@
+// |reftest| async
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-getiterator
+description: >
+ `GetIterator(obj, ~async~)` must attempt to call `obj[@@asyncIterator]` when
+ that value is an object with an [[IsHTMLDDA]] internal slot, not act as if
+ the value were `undefined`.
+features: [async-iteration, IsHTMLDDA]
+flags: [async]
+---*/
+
+async function f() {
+ var IsHTMLDDA = $262.IsHTMLDDA;
+ var iter = {
+ [Symbol.asyncIterator]: IsHTMLDDA,
+ get [Symbol.iterator]() {
+ throw new Test262Error("shouldn't touch Symbol.iterator");
+ },
+ };
+
+ // `IsHTMLDDA` is called here with `iter` as `this` and no arguments, and it's
+ // expected to return `null` under these conditions. Then the iteration
+ // protocol throws a `TypeError` because `null` isn't an object.
+ for await (var x of iter)
+ return "for-await-of body shouldn't be reached";
+
+ return "should have failed earlier";
+}
+
+f().then($DONE,
+ function (e) {
+ assert.sameValue(e.constructor, TypeError,
+ "expected TypeError because " +
+ "`iter[Symbol.asyncIterator]() returned a " +
+ "non-object: " + e);
+ })
+ .then($DONE, $DONE);