Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: src/objects.cc

Issue 1497483004: [proxies] Make Array.isArray respect proxies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comment. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/array-isarray.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 3f028c62824a35653bdc4ef03b265f6eedd4413e..24237f6f72785e6d5e5858c5cf704ace7370a3bb 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -611,6 +611,23 @@ MaybeHandle<Object> Object::BitwiseXor(Isolate* isolate, Handle<Object> lhs,
}
+Maybe<bool> Object::IsArray(Handle<Object> object) {
+ if (object->IsJSArray()) return Just(true);
+ if (object->IsJSProxy()) {
+ Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
+ Isolate* isolate = proxy->GetIsolate();
+ if (proxy->IsRevoked()) {
+ isolate->Throw(*isolate->factory()->NewTypeError(
+ MessageTemplate::kProxyRevoked,
+ isolate->factory()->NewStringFromAsciiChecked("IsArray")));
+ return Nothing<bool>();
+ }
+ return Object::IsArray(handle(proxy->target(), isolate));
+ }
+ return Just(false);
+}
+
+
bool Object::IsPromise(Handle<Object> object) {
if (!object->IsJSObject()) return false;
auto js_object = Handle<JSObject>::cast(object);
@@ -983,7 +1000,7 @@ MaybeHandle<Object> JSProxy::GetPrototype(Handle<JSProxy> proxy) {
}
-bool JSProxy::IsRevoked() {
+bool JSProxy::IsRevoked() const {
// TODO(neis): Decide on how to represent revocation. For now, revocation is
// unsupported.
DCHECK(target()->IsJSReceiver());
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/array-isarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698