From f1b0a1e2704cbe75102b4b8a41f42f8748c8e1d1 Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Mon, 4 May 2020 17:56:01 -0700 Subject: [PATCH] Fix testing for throw in an iterator via yield* throws IsHTMLDDA is specified in INTERPRETING.md to return null on [[Call]] when called with no arguments or with single argument "". Return null causes the iterator protocol to throw. Also see star-iterable-return-emulates-undefined-throws-when-called.js --- ...able-throw-emulates-undefined-throws-when-called.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/annexB/language/expressions/yield/star-iterable-throw-emulates-undefined-throws-when-called.js b/test/annexB/language/expressions/yield/star-iterable-throw-emulates-undefined-throws-when-called.js index 4b6ec85d86..219aef8a57 100644 --- a/test/annexB/language/expressions/yield/star-iterable-throw-emulates-undefined-throws-when-called.js +++ b/test/annexB/language/expressions/yield/star-iterable-throw-emulates-undefined-throws-when-called.js @@ -35,6 +35,14 @@ var inner = { var outer = (function* () { yield* inner; })(); outer.next(); -outer.throw(); + +assert.throws(TypeError, function() { + // `IsHTMLDDA` is called here with `iter` as `this` and `emptyString` as the + // sole argument, and it's specified to return `null` under these conditions. + // As `iter`'s iteration isn't ending because of a throw, the iteration + // protocol will then throw a `TypeError` because `null` isn't an object. + var emptyString = ""; + outer.throw(emptyString); +}); assert.sameValue(returnCalls, 0);