Commit 7e15bf81 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[modules, api] Restrict GetModuleNamespace to evaluated modules.

Allowing GetModuleNamespace on a not-yet-evaluated module does not make a
lot of sense because accessing the namespace object before evaluation
can lead to surprising behavior.

R=adamk@chromium.org

Bug: v8:1569
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: I3e3feb344f6399bf92b3dabc97c571a61b38bd41
Reviewed-on: https://chromium-review.googlesource.com/613268Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47365}
parent 491d94dc
......@@ -1170,8 +1170,8 @@ class V8_EXPORT Module {
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Evaluate(Local<Context> context);
/**
* Returns the namespace object of this module. The module must have
* been successfully instantiated before and must not be errored.
* Returns the namespace object of this module.
* The module's status must be kEvaluated.
*/
Local<Value> GetModuleNamespace();
};
......
......@@ -2159,10 +2159,9 @@ Location Module::GetModuleRequestLocation(int i) const {
Local<Value> Module::GetModuleNamespace() {
Utils::ApiCheck(
GetStatus() != kErrored && GetStatus() >= kInstantiated,
"v8::Module::GetModuleNamespace",
"GetModuleNamespace should be used on a successfully instantiated"
"module. The current module has not been instantiated or has errored");
GetStatus() == kEvaluated, "v8::Module::GetModuleNamespace",
"v8::Module::GetModuleNamespace can only be used on a module with "
"status kEvaluated");
i::Handle<i::Module> self = Utils::OpenHandle(this);
i::Handle<i::JSModuleNamespace> module_namespace =
i::Module::GetModuleNamespace(self);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment