summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/language/statements/for-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-of/iterator-close-return-emulates-undefined-throws-when-called.js')
-rw-r--r--js/src/tests/test262/annexB/language/statements/for-of/iterator-close-return-emulates-undefined-throws-when-called.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/language/statements/for-of/iterator-close-return-emulates-undefined-throws-when-called.js b/js/src/tests/test262/annexB/language/statements/for-of/iterator-close-return-emulates-undefined-throws-when-called.js
new file mode 100644
index 0000000000..6a81a3ec29
--- /dev/null
+++ b/js/src/tests/test262/annexB/language/statements/for-of/iterator-close-return-emulates-undefined-throws-when-called.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-iteratorclose
+description: >
+ If <iterator>.return is an object emulating `undefined` (e.g. `document.all`
+ in browsers), it shouldn't be treated as if it were actually `undefined`.
+features: [generators, IsHTMLDDA]
+---*/
+
+var IsHTMLDDA = $262.IsHTMLDDA;
+var iter = {
+ [Symbol.iterator]() { return this; },
+ next() { return {}; },
+ return: IsHTMLDDA,
+};
+
+assert.throws(TypeError, function() {
+ // `IsHTMLDDA` is called here with `iter` as `this` and no arguments, and it's
+ // specified to return `null` under these conditions. Then the iteration
+ // protocol throws a `TypeError` because `null` isn't an object.
+ for (var x of iter)
+ break;
+});
+
+reportCompare(0, 0);