Commit 1161fe86 authored by Gus Caplan's avatar Gus Caplan Committed by Commit Bot

[api] add v8::Object::IsUndetectable

This will enable people to check if an object is
document.all without having to use tricks like
`typeof v === 'undefined' && v !== undefined`.

Change-Id: I74670e4d3886fcd90f0f3cef9c3644a24ee08fda
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2067681Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66412}
parent 8158c216
......@@ -4025,6 +4025,13 @@ class V8_EXPORT Object : public Value {
*/
bool IsApiWrapper();
/**
* True if this object was created from an object template which was marked
* as undetectable. See v8::ObjectTemplate::MarkAsUndetectable for more
* information.
*/
bool IsUndetectable();
/**
* Call an Object as a function if a callback is set by the
* ObjectTemplate::SetCallAsFunctionHandler method.
......
......@@ -4859,6 +4859,11 @@ bool v8::Object::IsApiWrapper() {
return self->IsApiWrapper();
}
bool v8::Object::IsUndetectable() {
auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
return self->IsUndetectable();
}
MaybeLocal<Value> Object::CallAsFunction(Local<Context> context,
Local<Value> recv, int argc,
Local<Value> argv[]) {
......
......@@ -6842,6 +6842,9 @@ THREADED_TEST(UndetectableObject) {
.ToLocalChecked()
->NewInstance(env.local())
.ToLocalChecked();
CHECK(obj->IsUndetectable());
CHECK(
env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust());
......
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