mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-13 04:21:54 +00:00
LibJS: Mark sync module evaluation promise as handled
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This is a normative change in the ECMA-262 spec. See:
0fb1859
As noted in the PR for this change, this is not actually testable via
either test262 or WPT.
This commit is contained in:
parent
7c36a82129
commit
01791c5a52
Notes:
github-actions[bot]
2025-05-05 05:51:09 +00:00
Author: https://github.com/trflynn89
Commit: 01791c5a52
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4593
2 changed files with 32 additions and 12 deletions
|
@ -6,6 +6,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/GenericShorthands.h>
|
||||
#include <LibJS/CyclicModule.h>
|
||||
#include <LibJS/Module.h>
|
||||
#include <LibJS/Runtime/ModuleEnvironment.h>
|
||||
|
@ -38,6 +39,33 @@ void Module::visit_edges(Cell::Visitor& visitor)
|
|||
m_host_defined->visit_host_defined_self(visitor);
|
||||
}
|
||||
|
||||
// 16.2.1.5.1 EvaluateModuleSync ( module ), https://tc39.es/ecma262/#sec-EvaluateModuleSync
|
||||
ThrowCompletionOr<void> Module::evaluate_module_sync(VM& vm)
|
||||
{
|
||||
// 1. Assert: module is not a Cyclic Module Record.
|
||||
// 2. Let promise be module.Evaluate().
|
||||
auto promise = TRY(evaluate(vm));
|
||||
|
||||
// 3. Assert: promise.[[PromiseState]] is either FULFILLED or REJECTED.
|
||||
VERIFY(first_is_one_of(promise->state(), Promise::State::Fulfilled, Promise::State::Rejected));
|
||||
|
||||
// 4. If promise.[[PromiseState]] is REJECTED, then
|
||||
if (promise->state() == Promise::State::Rejected) {
|
||||
// a. If promise.[[PromiseIsHandled]] is false, perform HostPromiseRejectionTracker(promise, "handle").
|
||||
if (!promise->is_handled())
|
||||
vm.host_promise_rejection_tracker(promise, Promise::RejectionOperation::Handle);
|
||||
|
||||
// b. Set promise.[[PromiseIsHandled]] to true.
|
||||
promise->set_is_handled();
|
||||
|
||||
// c. Return ThrowCompletion(promise.[[PromiseResult]]).
|
||||
return throw_completion(promise->result());
|
||||
}
|
||||
|
||||
// 5. Return UNUSED.
|
||||
return {};
|
||||
}
|
||||
|
||||
// 16.2.1.5.1.1 InnerModuleLinking ( module, stack, index ), https://tc39.es/ecma262/#sec-InnerModuleLinking
|
||||
ThrowCompletionOr<u32> Module::inner_module_linking(VM& vm, Vector<Module*>&, u32 index)
|
||||
{
|
||||
|
@ -52,19 +80,10 @@ ThrowCompletionOr<u32> Module::inner_module_linking(VM& vm, Vector<Module*>&, u3
|
|||
ThrowCompletionOr<u32> Module::inner_module_evaluation(VM& vm, Vector<Module*>&, u32 index)
|
||||
{
|
||||
// 1. If module is not a Cyclic Module Record, then
|
||||
// a. Let promise be module.Evaluate().
|
||||
auto promise = TRY(evaluate(vm));
|
||||
// a. Perform ? EvaluateModuleSync(module).
|
||||
TRY(evaluate_module_sync(vm));
|
||||
|
||||
// b. Assert: promise.[[PromiseState]] is not pending.
|
||||
VERIFY(promise->state() != Promise::State::Pending);
|
||||
|
||||
// c. If promise.[[PromiseState]] is rejected, then
|
||||
if (promise->state() == Promise::State::Rejected) {
|
||||
// i. Return ThrowCompletion(promise.[[PromiseResult]]).
|
||||
return throw_completion(promise->result());
|
||||
}
|
||||
|
||||
// d. Return index.
|
||||
// b. Return index.
|
||||
return index;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue