Skip to content

Fix AsyncGeneratorPrototype routines 'this' argument validation #4811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,18 @@ ecma_builtin_async_generator_prototype_dispatch_routine (uint8_t builtin_routine

if (executable_object_p == NULL)
{
return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR);
const lit_utf8_byte_t *msg_p = ecma_get_error_utf8 (ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR);
lit_utf8_size_t msg_size = ecma_get_error_size (ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR);
ecma_string_t *error_msg_p = ecma_new_ecma_string_from_ascii (msg_p, msg_size);

ecma_object_t *type_error_obj_p = ecma_new_standard_error (JERRY_ERROR_TYPE, error_msg_p);
ecma_deref_ecma_string (error_msg_p);

ecma_value_t promise = ecma_op_create_promise_object (ECMA_VALUE_EMPTY, ECMA_VALUE_UNDEFINED, NULL);
ecma_reject_promise (promise, ecma_make_object_value (type_error_obj_p));
ecma_deref_object (type_error_obj_p);

return promise;
}

if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED)
Expand Down
18 changes: 17 additions & 1 deletion tests/jerry/es.next/function-async-gen1.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ function check_rejected(p, value)
})
}


function check_type_error(p)
{
assert(p instanceof Promise)

p.then(function(v) {
assert(false)
}, function(v) {
assert(v instanceof TypeError);
successCount++
})
}

// Test 1

var gen, r, o
Expand All @@ -65,6 +78,9 @@ check_fulfilled(gen.next("Test2"), 1.5, false)
check_fulfilled(gen.next(2.5), o, true)
check_fulfilled(gen.next(), undefined, true)
check_fulfilled(gen.next(), undefined, true)
check_type_error(gen.next.call(undefined))
check_type_error(gen.throw.call(undefined))
check_type_error(gen.return.call(undefined))

r(1)

Expand Down Expand Up @@ -220,7 +236,7 @@ check_fulfilled(gen.next(), undefined, true)
// END

function __checkAsync() {
assert(successCount === 29)
assert(successCount === 32)
assert(state === 4)
assert(state2 === 4)
}
6 changes: 0 additions & 6 deletions tests/test262-esnext-excludelist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6465,15 +6465,9 @@
<test id="built-ins/AsyncGeneratorFunction/instance-yield-expr-in-param.js"><reason></reason></test>
<test id="built-ins/AsyncGeneratorPrototype/next/request-queue-await-order.js"><reason></reason></test>
<test id="built-ins/AsyncGeneratorPrototype/next/request-queue-promise-resolve-order.js"><reason></reason></test>
<test id="built-ins/AsyncGeneratorPrototype/next/this-val-not-async-generator.js"><reason></reason></test>
<test id="built-ins/AsyncGeneratorPrototype/next/this-val-not-object.js"><reason></reason></test>
<test id="built-ins/AsyncGeneratorPrototype/return/return-state-completed.js"><reason></reason></test>
<test id="built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-promise.js"><reason></reason></test>
<test id="built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-promise.js"><reason></reason></test>
<test id="built-ins/AsyncGeneratorPrototype/return/this-val-not-async-generator.js"><reason></reason></test>
<test id="built-ins/AsyncGeneratorPrototype/return/this-val-not-object.js"><reason></reason></test>
<test id="built-ins/AsyncGeneratorPrototype/throw/this-val-not-async-generator.js"><reason></reason></test>
<test id="built-ins/AsyncGeneratorPrototype/throw/this-val-not-object.js"><reason></reason></test>
<test id="built-ins/FinalizationRegistry/prototype/cleanupSome/return-undefined-with-gc.js"><reason></reason></test>
<test id="built-ins/FinalizationRegistry/prototype/cleanupSome/return-undefined.js"><reason></reason></test>
<test id="language/arguments-object/cls-decl-async-private-gen-meth-args-trailing-comma-multiple.js"><reason></reason></test>
Expand Down