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/446106 Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Jochen Eisinger <jochen@chromium.org> Cr-Commit-Position: refs/heads/master@{#43405}
This commit is contained in:
parent
157e1e83ec
commit
d3cc730b45
@ -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
|
||||
|
12
src/api.cc
12
src/api.cc
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user