Commit f65e06b9 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[debugger] Add JSProxy support in Runtime::GetInternalProperties

For proxy object this methods returns target value, handler object and is revoked flag.

R=yangguo@chromium.org,cbruni@chromium.org
BUG=chromium:588705
LOG=Y

Review-Url: https://codereview.chromium.org/1938663002
Cr-Commit-Position: refs/heads/master@{#35948}
parent 96746cc7
......@@ -273,6 +273,25 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
result->set(2, *promise_value);
result->set(3, *value_obj);
return factory->NewJSArrayWithElements(result);
} else if (object->IsJSProxy()) {
Handle<JSProxy> js_proxy = Handle<JSProxy>::cast(object);
Handle<FixedArray> result = factory->NewFixedArray(3 * 2);
Handle<String> handler_str =
factory->NewStringFromAsciiChecked("[[Handler]]");
result->set(0, *handler_str);
result->set(1, js_proxy->handler());
Handle<String> target_str =
factory->NewStringFromAsciiChecked("[[Target]]");
result->set(2, *target_str);
result->set(3, js_proxy->target());
Handle<String> is_revoked_str =
factory->NewStringFromAsciiChecked("[[IsRevoked]]");
result->set(4, *is_revoked_str);
result->set(5, isolate->heap()->ToBoolean(js_proxy->IsRevoked()));
return factory->NewJSArrayWithElements(result);
} else if (object->IsJSValue()) {
Handle<JSValue> js_value = Handle<JSValue>::cast(object);
......
......@@ -265,3 +265,27 @@ assertEquals(Number, property_map["[[TargetFunction]]"].value().value());
assertTrue("[[BoundArgs]]" in property_map);
assertEquals("object", property_map["[[BoundArgs]]"].value().type());
assertEquals(1, property_map["[[BoundArgs]]"].value().value().length);
// Test JSProxy internal properties.
var target = {};
var handler = {
get: function (target, name, receiver) {
return target[name];
},
set: function(target, name, value, receiver) {
target[name] = value;
return value;
}
}
ip = debug.ObjectMirror.GetInternalProperties(new Proxy(target, handler));
assertEquals(3, ip.length);
var property_map = {};
for (var i = 0; i < ip.length; i++) {
property_map[ip[i].name()] = ip[i];
}
assertTrue("[[Target]]" in property_map);
assertEquals(target, property_map["[[Target]]"].value().value());
assertTrue("[[Handler]]" in property_map);
assertEquals(handler, property_map["[[Handler]]"].value().value());
assertTrue("[[IsRevoked]]" in property_map);
assertEquals(false, property_map["[[IsRevoked]]"].value().value());
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