Commit d3cc730b authored by Jochen Eisinger's avatar Jochen Eisinger Committed by Commit Bot

Add a getter for the last entered context or microtask context

This is used for internal security checks in eval(). Expose this to
enable the embedder to implement similar security checks.

R=yangguo@chromium.org
BUG=

Change-Id: I10819713b19527622de5ffffac313d126a887c05
Reviewed-on: https://chromium-review.googlesource.com/446106Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43405}
parent 157e1e83
......@@ -6808,6 +6808,14 @@ class V8_EXPORT Isolate {
/** Returns the last context entered through V8's C++ API. */
Local<Context> GetEnteredContext();
/**
* Returns either the last context entered through V8's C++ API, or the
* context of the currently running microtask while processing microtasks.
* If a context is entered while executing a microtask, that context is
* returned.
*/
Local<Context> GetEnteredOrMicrotaskContext();
/**
* Schedules an exception to be thrown when returning to JavaScript. When an
* exception has been scheduled it is illegal to invoke any JavaScript
......
......@@ -8030,6 +8030,18 @@ v8::Local<v8::Context> Isolate::GetEnteredContext() {
return Utils::ToLocal(i::Handle<i::Context>::cast(last));
}
v8::Local<v8::Context> Isolate::GetEnteredOrMicrotaskContext() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
i::Handle<i::Object> last;
if (isolate->handle_scope_implementer()
->MicrotaskContextIsLastEnteredContext()) {
last = isolate->handle_scope_implementer()->MicrotaskContext();
} else {
last = isolate->handle_scope_implementer()->LastEnteredContext();
}
if (last.is_null()) return Local<Context>();
return Utils::ToLocal(i::Handle<i::Context>::cast(last));
}
v8::Local<Value> Isolate::ThrowException(v8::Local<v8::Value> value) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
......
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