Commit 2b94e567 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[inspector] Report [[Prototype]] as internal property.

Previously the inspector was trying to add a special `__proto__`
property to every JSObject, which looked and behaved like a real
data property on the object. But this is confusing to developers
since `__proto__` is not a real data property, but usually an
accessor property on the `Object.prototype`.

Additionally all other internal properties are reported using the
[[Name]] notation, with the [[Prototype]] having been the strange
outlier.

Drive-by-cleanup: Use an ArrayList to collect the name/value pairs
inside Runtime::GetInternalProperties(), which makes this function
more readable and easier to add things.

Bug: chromuium:1162229
Fixed: chromium:1197019
Screenshot: https://imgur.com/a/b7TZ32s.png
Change-Id: Ic4c1e35e2e65f90619fcc12bf3a72806cadb0794
Doc: http://doc/1Xetnc9s6r0yy4LnPbqeCwsnsOtBlvJsV4OCdXMZ1wCM
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2814565
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73881}
parent d12bf345
......@@ -1050,78 +1050,57 @@ std::unique_ptr<debug::ScopeIterator> GetWasmScopeIterator(WasmFrame* frame) {
return std::make_unique<DebugWasmScopeIterator>(frame);
}
Handle<JSArray> GetWasmInstanceObjectInternalProperties(
Handle<ArrayList> AddWasmInstanceObjectInternalProperties(
Isolate* isolate, Handle<ArrayList> result,
Handle<WasmInstanceObject> instance) {
Isolate* isolate = instance->GetIsolate();
Handle<FixedArray> result = isolate->factory()->NewFixedArray(2 * 5);
int length = 0;
Handle<String> module_str =
isolate->factory()->NewStringFromAsciiChecked("[[Module]]");
Handle<Object> module_obj = handle(instance->module_object(), isolate);
result->set(length++, *module_str);
result->set(length++, *module_obj);
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[Module]]"),
handle(instance->module_object(), isolate));
if (FunctionsProxy::Count(isolate, instance) != 0) {
Handle<String> functions_str =
isolate->factory()->NewStringFromAsciiChecked("[[Functions]]");
Handle<Object> functions_obj =
GetOrCreateInstanceProxy<FunctionsProxy>(isolate, instance);
result->set(length++, *functions_str);
result->set(length++, *functions_obj);
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[Functions]]"),
GetOrCreateInstanceProxy<FunctionsProxy>(isolate, instance));
}
if (GlobalsProxy::Count(isolate, instance) != 0) {
Handle<String> globals_str =
isolate->factory()->NewStringFromAsciiChecked("[[Globals]]");
Handle<Object> globals_obj =
GetOrCreateInstanceProxy<GlobalsProxy>(isolate, instance);
result->set(length++, *globals_str);
result->set(length++, *globals_obj);
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[Globals]]"),
GetOrCreateInstanceProxy<GlobalsProxy>(isolate, instance));
}
if (MemoriesProxy::Count(isolate, instance) != 0) {
Handle<String> memories_str =
isolate->factory()->NewStringFromAsciiChecked("[[Memories]]");
Handle<Object> memories_obj =
GetOrCreateInstanceProxy<MemoriesProxy>(isolate, instance);
result->set(length++, *memories_str);
result->set(length++, *memories_obj);
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[Memories]]"),
GetOrCreateInstanceProxy<MemoriesProxy>(isolate, instance));
}
if (TablesProxy::Count(isolate, instance) != 0) {
Handle<String> tables_str =
isolate->factory()->NewStringFromAsciiChecked("[[Tables]]");
Handle<Object> tables_obj =
GetOrCreateInstanceProxy<TablesProxy>(isolate, instance);
result->set(length++, *tables_str);
result->set(length++, *tables_obj);
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[Tables]]"),
GetOrCreateInstanceProxy<TablesProxy>(isolate, instance));
}
return isolate->factory()->NewJSArrayWithElements(result, PACKED_ELEMENTS,
length);
return result;
}
Handle<JSArray> GetWasmModuleObjectInternalProperties(
Handle<ArrayList> AddWasmModuleObjectInternalProperties(
Isolate* isolate, Handle<ArrayList> result,
Handle<WasmModuleObject> module_object) {
Isolate* isolate = module_object->GetIsolate();
Handle<FixedArray> result = isolate->factory()->NewFixedArray(2 * 2);
int length = 0;
Handle<String> exports_str =
isolate->factory()->NewStringFromStaticChars("[[Exports]]");
Handle<JSArray> exports_obj = wasm::GetExports(isolate, module_object);
result->set(length++, *exports_str);
result->set(length++, *exports_obj);
Handle<String> imports_str =
isolate->factory()->NewStringFromStaticChars("[[Imports]]");
Handle<JSArray> imports_obj = wasm::GetImports(isolate, module_object);
result->set(length++, *imports_str);
result->set(length++, *imports_obj);
return isolate->factory()->NewJSArrayWithElements(result, PACKED_ELEMENTS,
length);
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromStaticChars("[[Exports]]"),
wasm::GetExports(isolate, module_object));
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromStaticChars("[[Imports]]"),
wasm::GetImports(isolate, module_object));
return result;
}
} // namespace internal
......
......@@ -28,6 +28,7 @@ class WasmValue;
#include "torque-generated/src/debug/debug-wasm-objects-tq.inc"
class ArrayList;
class WasmFrame;
class WasmInstanceObject;
class WasmModuleObject;
......@@ -68,9 +69,11 @@ Handle<JSObject> GetWasmDebugProxy(WasmFrame* frame);
std::unique_ptr<debug::ScopeIterator> GetWasmScopeIterator(WasmFrame* frame);
Handle<JSArray> GetWasmInstanceObjectInternalProperties(
Handle<ArrayList> AddWasmInstanceObjectInternalProperties(
Isolate* isolate, Handle<ArrayList> result,
Handle<WasmInstanceObject> instance);
Handle<JSArray> GetWasmModuleObjectInternalProperties(
Handle<ArrayList> AddWasmModuleObjectInternalProperties(
Isolate* isolate, Handle<ArrayList> result,
Handle<WasmModuleObject> module_object);
} // namespace internal
......
......@@ -1216,7 +1216,6 @@ bool ValueMirror::getProperties(v8::Local<v8::Context> context,
return false;
}
}
bool shouldSkipProto = internalType == V8InternalValueType::kScopeList;
bool formatAccessorsAsProperties =
clientFor(context)->formatAccessorsAsProperties(object);
......@@ -1304,8 +1303,7 @@ bool ValueMirror::getProperties(v8::Local<v8::Context> context,
bool isSymbolDescription =
object->IsSymbol() && name == "description";
if (isSymbolDescription ||
(name != "__proto__" && getterIsNativeFunction &&
formatAccessorsAsProperties &&
(getterIsNativeFunction && formatAccessorsAsProperties &&
!doesAttributeHaveObservableSideEffectOnGet(context, object,
v8Name))) {
v8::TryCatch tryCatch(isolate);
......@@ -1321,7 +1319,6 @@ bool ValueMirror::getProperties(v8::Local<v8::Context> context,
}
}
if (accessorPropertiesOnly && !isAccessorProperty) continue;
if (name == "__proto__") shouldSkipProto = true;
auto mirror = PropertyMirror{name,
writable,
configurable,
......@@ -1340,16 +1337,6 @@ bool ValueMirror::getProperties(v8::Local<v8::Context> context,
return false;
}
}
if (!shouldSkipProto && ownProperties && !object->IsProxy() &&
!accessorPropertiesOnly) {
v8::Local<v8::Value> prototype = object->GetPrototype();
if (prototype->IsObject()) {
accumulator->Add(PropertyMirror{String16("__proto__"), true, true, false,
true, false,
ValueMirror::create(context, prototype),
nullptr, nullptr, nullptr, nullptr});
}
}
return true;
}
......
......@@ -157,11 +157,11 @@ RUNTIME_FUNCTION(Runtime_ScheduleBreak) {
return ReadOnlyRoots(isolate).undefined_value();
}
namespace {
template <class IteratorType>
static MaybeHandle<JSArray> GetIteratorInternalProperties(
Isolate* isolate, Handle<IteratorType> object) {
Factory* factory = isolate->factory();
Handle<IteratorType> iterator = Handle<IteratorType>::cast(object);
static Handle<ArrayList> AddIteratorInternalProperties(
Isolate* isolate, Handle<ArrayList> result, Handle<IteratorType> iterator) {
const char* kind = nullptr;
switch (iterator->map().instance_type()) {
case JS_MAP_KEY_ITERATOR_TYPE:
......@@ -179,62 +179,60 @@ static MaybeHandle<JSArray> GetIteratorInternalProperties(
UNREACHABLE();
}
Handle<FixedArray> result = factory->NewFixedArray(2 * 3);
Handle<String> has_more =
factory->NewStringFromAsciiChecked("[[IteratorHasMore]]");
result->set(0, *has_more);
result->set(1, isolate->heap()->ToBoolean(iterator->HasMore()));
Handle<String> index =
factory->NewStringFromAsciiChecked("[[IteratorIndex]]");
result->set(2, *index);
result->set(3, iterator->index());
Handle<String> iterator_kind =
factory->NewStringFromAsciiChecked("[[IteratorKind]]");
result->set(4, *iterator_kind);
Handle<String> kind_str = factory->NewStringFromAsciiChecked(kind);
result->set(5, *kind_str);
return factory->NewJSArrayWithElements(result);
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[IteratorHasMore]]"),
isolate->factory()->ToBoolean(iterator->HasMore()));
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[IteratorIndex]]"),
handle(iterator->index(), isolate));
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[IteratorKind]]"),
isolate->factory()->NewStringFromAsciiChecked(kind));
return result;
}
} // namespace
MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
Handle<Object> object) {
Factory* factory = isolate->factory();
auto result = ArrayList::New(isolate, 8 * 2);
if (object->IsJSObject()) {
PrototypeIterator iter(isolate, Handle<JSObject>::cast(object));
Handle<Object> prototype = PrototypeIterator::GetCurrent(iter);
if (!prototype->IsNull(isolate)) {
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromStaticChars("[[Prototype]]"),
prototype);
}
}
if (object->IsJSBoundFunction()) {
Handle<JSBoundFunction> function = Handle<JSBoundFunction>::cast(object);
Handle<FixedArray> result = factory->NewFixedArray(2 * 3);
Handle<String> target =
factory->NewStringFromAsciiChecked("[[TargetFunction]]");
result->set(0, *target);
result->set(1, function->bound_target_function());
Handle<String> bound_this =
factory->NewStringFromAsciiChecked("[[BoundThis]]");
result->set(2, *bound_this);
result->set(3, function->bound_this());
Handle<String> bound_args =
factory->NewStringFromAsciiChecked("[[BoundArgs]]");
result->set(4, *bound_args);
Handle<FixedArray> bound_arguments =
factory->CopyFixedArray(handle(function->bound_arguments(), isolate));
Handle<JSArray> arguments_array =
factory->NewJSArrayWithElements(bound_arguments);
result->set(5, *arguments_array);
return factory->NewJSArrayWithElements(result);
}
if (object->IsJSMapIterator()) {
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[TargetFunction]]"),
handle(function->bound_target_function(), isolate));
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[BoundThis]]"),
handle(function->bound_this(), isolate));
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[BoundArgs]]"),
isolate->factory()->NewJSArrayWithElements(
isolate->factory()->CopyFixedArray(
handle(function->bound_arguments(), isolate))));
} else if (object->IsJSMapIterator()) {
Handle<JSMapIterator> iterator = Handle<JSMapIterator>::cast(object);
return GetIteratorInternalProperties(isolate, iterator);
}
if (object->IsJSSetIterator()) {
result = AddIteratorInternalProperties(isolate, result, iterator);
} else if (object->IsJSSetIterator()) {
Handle<JSSetIterator> iterator = Handle<JSSetIterator>::cast(object);
return GetIteratorInternalProperties(isolate, iterator);
}
if (object->IsJSGeneratorObject()) {
result = AddIteratorInternalProperties(isolate, result, iterator);
} else if (object->IsJSGeneratorObject()) {
Handle<JSGeneratorObject> generator =
Handle<JSGeneratorObject>::cast(object);
......@@ -247,163 +245,131 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
DCHECK(generator->is_suspended());
}
Handle<FixedArray> result = factory->NewFixedArray(2 * 3);
Handle<String> generator_status =
factory->NewStringFromAsciiChecked("[[GeneratorState]]");
result->set(0, *generator_status);
Handle<String> status_str = factory->NewStringFromAsciiChecked(status);
result->set(1, *status_str);
Handle<String> function =
factory->NewStringFromAsciiChecked("[[GeneratorFunction]]");
result->set(2, *function);
result->set(3, generator->function());
Handle<String> receiver =
factory->NewStringFromAsciiChecked("[[GeneratorReceiver]]");
result->set(4, *receiver);
result->set(5, generator->receiver());
return factory->NewJSArrayWithElements(result);
}
if (object->IsJSPromise()) {
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[GeneratorState]]"),
isolate->factory()->NewStringFromAsciiChecked(status));
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[GeneratorFunction]]"),
handle(generator->function(), isolate));
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[GeneratorReceiver]]"),
handle(generator->receiver(), isolate));
} else if (object->IsJSPromise()) {
Handle<JSPromise> promise = Handle<JSPromise>::cast(object);
const char* status = JSPromise::Status(promise->status());
Handle<FixedArray> result = factory->NewFixedArray(2 * 2);
Handle<String> promise_status =
factory->NewStringFromAsciiChecked("[[PromiseState]]");
result->set(0, *promise_status);
Handle<String> status_str = factory->NewStringFromAsciiChecked(status);
result->set(1, *status_str);
Handle<Object> value_obj(promise->status() == Promise::kPending
? ReadOnlyRoots(isolate).undefined_value()
: promise->result(),
isolate);
Handle<String> promise_value =
factory->NewStringFromAsciiChecked("[[PromiseResult]]");
result->set(2, *promise_value);
result->set(3, *value_obj);
return factory->NewJSArrayWithElements(result);
}
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());
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[PromiseState]]"),
isolate->factory()->NewStringFromAsciiChecked(
JSPromise::Status(promise->status())));
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[PromiseResult]]"),
promise->status() == Promise::kPending
? isolate->factory()->undefined_value()
: handle(promise->result(), isolate));
} else if (object->IsJSProxy()) {
Handle<JSProxy> js_proxy = Handle<JSProxy>::cast(object);
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);
}
if (object->IsJSPrimitiveWrapper()) {
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[Handler]]"),
handle(js_proxy->handler(), isolate));
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[Target]]"),
handle(js_proxy->target(), isolate));
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[IsRevoked]]"),
isolate->factory()->ToBoolean(js_proxy->IsRevoked()));
} else if (object->IsJSPrimitiveWrapper()) {
Handle<JSPrimitiveWrapper> js_value =
Handle<JSPrimitiveWrapper>::cast(object);
Handle<FixedArray> result = factory->NewFixedArray(2);
Handle<String> primitive_value =
factory->NewStringFromAsciiChecked("[[PrimitiveValue]]");
result->set(0, *primitive_value);
result->set(1, js_value->value());
return factory->NewJSArrayWithElements(result);
}
if (object->IsJSArrayBuffer()) {
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[PrimitiveValue]]"),
handle(js_value->value(), isolate));
} else if (object->IsJSArrayBuffer()) {
Handle<JSArrayBuffer> js_array_buffer = Handle<JSArrayBuffer>::cast(object);
if (js_array_buffer->was_detached()) {
// Mark a detached JSArrayBuffer and such and don't even try to
// create views for it, since the TypedArray constructors will
// throw a TypeError when the underlying buffer is detached.
Handle<FixedArray> result = factory->NewFixedArray(1 * 2);
Handle<String> is_detached_str =
factory->NewStringFromAsciiChecked("[[IsDetached]]");
result->set(0, *is_detached_str);
result->set(1, isolate->heap()->ToBoolean(true));
return factory->NewJSArrayWithElements(result, PACKED_ELEMENTS);
}
const size_t byte_length = js_array_buffer->byte_length();
static const ExternalArrayType kTypes[] = {
kExternalInt8Array,
kExternalUint8Array,
kExternalInt16Array,
kExternalInt32Array,
};
Handle<FixedArray> result =
factory->NewFixedArray((3 + arraysize(kTypes)) * 2);
int index = 0;
for (auto type : kTypes) {
switch (type) {
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype) \
case kExternal##Type##Array: { \
if ((byte_length % sizeof(ctype)) != 0) continue; \
Handle<String> typed_array_str = \
factory->NewStringFromStaticChars("[[" #Type "Array]]"); \
Handle<JSTypedArray> js_typed_array = \
factory->NewJSTypedArray(kExternal##Type##Array, js_array_buffer, 0, \
byte_length / sizeof(ctype)); \
result->set(index++, *typed_array_str); \
result->set(index++, *js_typed_array); \
break; \
}
TYPED_ARRAYS(TYPED_ARRAY_CASE)
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[IsDetached]]"),
isolate->factory()->true_value());
} else {
const size_t byte_length = js_array_buffer->byte_length();
static const ExternalArrayType kTypes[] = {
kExternalInt8Array,
kExternalUint8Array,
kExternalInt16Array,
kExternalInt32Array,
};
for (auto type : kTypes) {
switch (type) {
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype) \
case kExternal##Type##Array: { \
if ((byte_length % sizeof(ctype)) != 0) continue; \
result = ArrayList::Add( \
isolate, result, \
isolate->factory()->NewStringFromStaticChars("[[" #Type "Array]]"), \
isolate->factory()->NewJSTypedArray(kExternal##Type##Array, \
js_array_buffer, 0, \
byte_length / sizeof(ctype))); \
break; \
}
TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
default:
UNREACHABLE();
}
}
result =
ArrayList::Add(isolate, result,
isolate->factory()->NewStringFromAsciiChecked(
"[[ArrayBufferByteLength]]"),
isolate->factory()->NewNumberFromSize(byte_length));
// Use the backing store pointer as a unique ID
EmbeddedVector<char, 32> buffer_data_vec;
int len =
SNPrintF(buffer_data_vec, V8PRIxPTR_FMT,
reinterpret_cast<Address>(js_array_buffer->backing_store()));
result = ArrayList::Add(
isolate, result,
isolate->factory()->NewStringFromAsciiChecked("[[ArrayBufferData]]"),
isolate->factory()->InternalizeUtf8String(
buffer_data_vec.SubVector(0, len)));
Handle<Symbol> memory_symbol =
isolate->factory()->array_buffer_wasm_memory_symbol();
Handle<Object> memory_object =
JSObject::GetDataProperty(js_array_buffer, memory_symbol);
if (!memory_object->IsUndefined(isolate)) {
result = ArrayList::Add(isolate, result,
isolate->factory()->NewStringFromAsciiChecked(
"[[WebAssemblyMemory]]"),
memory_object);
}
}
Handle<String> byte_length_str =
factory->NewStringFromAsciiChecked("[[ArrayBufferByteLength]]");
Handle<Object> byte_length_obj = factory->NewNumberFromSize(byte_length);
result->set(index++, *byte_length_str);
result->set(index++, *byte_length_obj);
Handle<String> buffer_data_str =
factory->NewStringFromAsciiChecked("[[ArrayBufferData]]");
// Use the backing store pointer as a unique ID
EmbeddedVector<char, 32> buffer_data_vec;
int len =
SNPrintF(buffer_data_vec, V8PRIxPTR_FMT,
reinterpret_cast<Address>(js_array_buffer->backing_store()));
Handle<String> buffer_data_obj =
factory->InternalizeUtf8String(buffer_data_vec.SubVector(0, len));
result->set(index++, *buffer_data_str);
result->set(index++, *buffer_data_obj);
#if V8_ENABLE_WEBASSEMBLY
Handle<Symbol> memory_symbol = factory->array_buffer_wasm_memory_symbol();
Handle<Object> memory_object =
JSObject::GetDataProperty(js_array_buffer, memory_symbol);
if (!memory_object->IsUndefined(isolate)) {
Handle<String> buffer_memory_str =
factory->NewStringFromAsciiChecked("[[WebAssemblyMemory]]");
Handle<WasmMemoryObject> buffer_memory_obj =
Handle<WasmMemoryObject>::cast(memory_object);
result->set(index++, *buffer_memory_str);
result->set(index++, *buffer_memory_obj);
}
} else if (object->IsWasmInstanceObject()) {
result = AddWasmInstanceObjectInternalProperties(
isolate, result, Handle<WasmInstanceObject>::cast(object));
} else if (object->IsWasmModuleObject()) {
result = AddWasmModuleObjectInternalProperties(
isolate, result, Handle<WasmModuleObject>::cast(object));
#endif // V8_ENABLE_WEBASSEMBLY
return factory->NewJSArrayWithElements(result, PACKED_ELEMENTS, index);
}
#if V8_ENABLE_WEBASSEMBLY
if (object->IsWasmInstanceObject()) {
return GetWasmInstanceObjectInternalProperties(
Handle<WasmInstanceObject>::cast(object));
}
if (object->IsWasmModuleObject()) {
return GetWasmModuleObjectInternalProperties(
Handle<WasmModuleObject>::cast(object));
}
#endif // V8_ENABLE_WEBASSEMBLY
return factory->NewJSArray(0);
return isolate->factory()->NewJSArrayWithElements(
ArrayList::Elements(isolate, result), PACKED_ELEMENTS);
}
RUNTIME_FUNCTION(Runtime_GetGeneratorScopeCount) {
......
......@@ -463,7 +463,12 @@ class DebugWrapper {
"Runtime.getProperties", { objectId : objectId, ownProperties: true });
this.sendMessage(msg);
const reply = this.takeReplyChecked(msgid);
return Object(reply.result.internalProperties[0].value.value);
for (const internalProperty of reply.result.internalProperties) {
if (internalProperty.name === '[[PrimitiveValue]]') {
return Object(internalProperty.value.value);
}
}
throw new Error('Remote object is not a value wrapper');
}
reconstructRemoteObject(obj) {
......
Checks Runtime.getProperties method while debugger is paused.
Running test: testObject5
__proto__ own object undefined
foo own string cat
Internal properties
[[PrimitiveValue]] number 5
[[Prototype]] object undefined
Running test: testNotOwn
__defineGetter__ inherited function undefined
......@@ -23,6 +23,8 @@ Running test: testNotOwn
toLocaleString inherited function undefined
toString inherited function undefined
valueOf inherited function undefined
Internal properties
[[Prototype]] object undefined
Running test: testAccessorsOnly
b own no value, getter, setter
......@@ -32,31 +34,34 @@ Running test: testArray
0 own string red
1 own string green
2 own string blue
__proto__ own object undefined
length own number 3
Internal properties
[[Prototype]] object undefined
Running test: testBound
__proto__ own function undefined
length own number 0
name own string bound Number
Internal properties
[[BoundArgs]] object undefined
[[BoundThis]] object undefined
[[Prototype]] function undefined
[[TargetFunction]] function undefined
Running test: testObjectThrowsLength
__proto__ own object undefined
length own no value, getter
Internal properties
[[Prototype]] object undefined
Running test: testTypedArrayWithoutLength
__proto__ own object undefined
Internal properties
[[Prototype]] object undefined
Running test: testArrayBuffer
Running test: testArrayBufferWithBrokenUintCtor
__proto__ own object undefined
Internal properties
[[ArrayBufferByteLength]] number 7
[[ArrayBufferData]] string 0x...
[[Int8Array]] object undefined
[[Prototype]] object undefined
[[Uint8Array]] object undefined
......@@ -42,8 +42,6 @@ let { Protocol } = InspectorTest.start('Checks Runtime.getProperties method whil
let objectId = await evaluateToObjectId('new Uint8Array([1, 1, 1, 1, 1, 1, 1, 1]).buffer');
let props = await Protocol.Runtime.getProperties({ objectId, ownProperties: true });
for (let prop of props.result.result) {
if (prop.name === '__proto__')
continue;
InspectorTest.log(prop.name);
await logGetPropertiesResult(prop.value.objectId);
}
......
......@@ -54,6 +54,17 @@ Running test: testSetVariableValueMain
{
id : <messageId>
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
]
result : [
[0] : {
configurable : true
......@@ -67,19 +78,6 @@ Running test: testSetVariableValueMain
}
writable : true
}
[1] : {
configurable : true
enumerable : false
isOwn : true
name : __proto__
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
writable : true
}
]
}
}
......@@ -98,6 +96,18 @@ Running test: testSetVariableValueMain
{
id : <messageId>
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Array
description : Array(0)
objectId : <objectId>
subtype : array
type : object
}
}
]
result : [
[0] : {
configurable : true
......@@ -144,20 +154,6 @@ Running test: testSetVariableValueMain
}
writable : true
}
[4] : {
configurable : true
enumerable : false
isOwn : true
name : __proto__
value : {
className : Array
description : Array(0)
objectId : <objectId>
subtype : array
type : object
}
writable : true
}
]
}
}
......@@ -175,6 +171,17 @@ Running test: testSetVariableValueMain
{
id : <messageId>
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
]
result : [
[0] : {
configurable : true
......@@ -188,19 +195,6 @@ Running test: testSetVariableValueMain
}
writable : true
}
[1] : {
configurable : true
enumerable : false
isOwn : true
name : __proto__
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
writable : true
}
]
}
}
......
......@@ -824,6 +824,11 @@ Running test: testObjInheritsGetterProperty
type : number
value : NaN
}
[1] : {
name : __proto__
type : object
value : Object
}
]
type : object
}
......
Checks Runtime.getProperties method
Running test: testObject5
__proto__ own object undefined
foo own string cat
Internal properties
[[PrimitiveValue]] number 5
[[Prototype]] object undefined
Running test: testNotOwn
__defineGetter__ inherited function undefined
......@@ -23,6 +23,8 @@ Running test: testNotOwn
toLocaleString inherited function undefined
toString inherited function undefined
valueOf inherited function undefined
Internal properties
[[Prototype]] object undefined
Running test: testAccessorsOnly
b own no value, getter, setter
......@@ -32,33 +34,38 @@ Running test: testArray
0 own string red
1 own string green
2 own string blue
__proto__ own object undefined
length own number 3
Internal properties
[[Prototype]] object undefined
Running test: testBound
__proto__ own function undefined
length own number 0
name own string bound Number
Internal properties
[[BoundArgs]] object undefined
[[BoundThis]] object undefined
[[Prototype]] function undefined
[[TargetFunction]] function undefined
Running test: testObjectThrowsLength
__proto__ own object undefined
length own no value, getter
Internal properties
[[Prototype]] object undefined
Running test: testTypedArrayWithoutLength
__proto__ own object undefined
Internal properties
[[Prototype]] object undefined
Running test: testClassWithPrivateFields
__proto__ own object undefined
baz own number 4
Internal properties
[[Prototype]] object undefined
Private properties
#bar number 3
#foo number 2
__proto__ own object undefined
baz own number 4
Internal properties
[[Prototype]] object undefined
Private properties
#bar number 3
#baz number 1
......@@ -72,6 +79,13 @@ Private properties
#foo number 2
Running test: testArrayBuffer
[[Prototype]]
Symbol(Symbol.toStringTag) own string ArrayBuffer
byteLength own no value, getter
constructor own function undefined
slice own function undefined
Internal properties
[[Prototype]] object undefined
[[Int8Array]]
0 own number 1
1 own number 1
......@@ -81,7 +95,8 @@ Running test: testArrayBuffer
5 own number 1
6 own number 1
7 own number 1
__proto__ own object undefined
Internal properties
[[Prototype]] object undefined
[[Uint8Array]]
0 own number 1
1 own number 1
......@@ -91,21 +106,31 @@ Running test: testArrayBuffer
5 own number 1
6 own number 1
7 own number 1
__proto__ own object undefined
Internal properties
[[Prototype]] object undefined
[[Int16Array]]
0 own number 257
1 own number 257
2 own number 257
3 own number 257
__proto__ own object undefined
Internal properties
[[Prototype]] object undefined
[[Int32Array]]
0 own number 16843009
1 own number 16843009
__proto__ own object undefined
Internal properties
[[Prototype]] object undefined
[[ArrayBufferByteLength]]
[[ArrayBufferData]]
Running test: testArrayBufferFromWebAssemblyMemory
[[Prototype]]
Symbol(Symbol.toStringTag) own string ArrayBuffer
byteLength own no value, getter
constructor own function undefined
slice own function undefined
Internal properties
[[Prototype]] object undefined
[[Int8Array]]
[[Uint8Array]]
[[Int16Array]]
......@@ -113,18 +138,22 @@ Running test: testArrayBufferFromWebAssemblyMemory
[[ArrayBufferByteLength]]
[[ArrayBufferData]]
[[WebAssemblyMemory]]
__proto__ own object undefined
Internal properties
[[Prototype]] object undefined
Running test: testDetachedArrayBuffer
[[Prototype]] undefined
[[IsDetached]] true
Running test: testArrayBufferWithBrokenUintCtor
__proto__ own object undefined
Internal properties
[[ArrayBufferByteLength]] number 7
[[ArrayBufferData]] string 0x...
[[Int8Array]] object undefined
[[Prototype]] object undefined
[[Uint8Array]] object undefined
Running test: testObjectWithProtoProperty
__proto__ own object undefined
Internal properties
[[Prototype]] object undefined
......@@ -45,8 +45,6 @@ InspectorTest.runAsyncTestSuite([
let objectId = await evaluateToObjectId('new Uint8Array([1, 1, 1, 1, 1, 1, 1, 1]).buffer');
let props = await Protocol.Runtime.getProperties({ objectId, ownProperties: true });
for (let prop of props.result.result) {
if (prop.name === '__proto__')
continue;
InspectorTest.log(prop.name);
await logGetPropertiesResult(prop.value.objectId);
}
......@@ -61,8 +59,6 @@ InspectorTest.runAsyncTestSuite([
let objectId = await evaluateToObjectId('new WebAssembly.Memory({initial: 1}).buffer');
let props = await Protocol.Runtime.getProperties({ objectId, ownProperties: true });
for (let prop of props.result.result) {
if (prop.name === '__proto__')
continue;
InspectorTest.log(prop.name);
await logGetPropertiesResult(prop.value.objectId);
}
......@@ -84,8 +80,6 @@ InspectorTest.runAsyncTestSuite([
await Protocol.Runtime.evaluate({ expression: 'b', generatePreview: true })
let props = await Protocol.Runtime.getProperties({ objectId, ownProperties: true });
for (let prop of props.result.result) {
if (prop.name === '__proto__')
continue;
InspectorTest.log(prop.name);
await logGetPropertiesResult(prop.value.objectId);
}
......
......@@ -27,6 +27,15 @@ expression: (function* foo() { yield 1 })
}
}
[2] : {
name : [[Prototype]]
value : {
className : GeneratorFunction
description : GeneratorFunction
objectId : <objectId>
type : object
}
}
[3] : {
name : [[Scopes]]
value : {
className : Array
......@@ -60,6 +69,15 @@ expression: (function foo() {})
}
}
[1] : {
name : [[Prototype]]
value : {
className : Function
description : function () { [native code] }
objectId : <objectId>
type : function
}
}
[2] : {
name : [[Scopes]]
value : {
className : Array
......@@ -80,6 +98,15 @@ expression: new Number(239)
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Number
description : Number
objectId : <objectId>
type : object
}
}
[1] : {
name : [[PrimitiveValue]]
value : {
description : 239
......@@ -96,6 +123,15 @@ expression: new Boolean(false)
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Boolean
description : Boolean
objectId : <objectId>
type : object
}
}
[1] : {
name : [[PrimitiveValue]]
value : {
type : boolean
......@@ -111,6 +147,15 @@ expression: new String('abc')
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : String
description : String
objectId : <objectId>
type : object
}
}
[1] : {
name : [[PrimitiveValue]]
value : {
type : string
......@@ -126,6 +171,15 @@ expression: Object(Symbol(42))
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Symbol
description : Symbol
objectId : <objectId>
type : object
}
}
[1] : {
name : [[PrimitiveValue]]
value : {
description : Symbol(42)
......@@ -142,6 +196,15 @@ expression: Object(BigInt(2))
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : BigInt
description : BigInt
objectId : <objectId>
type : object
}
}
[1] : {
name : [[PrimitiveValue]]
value : {
description : 2n
......@@ -160,13 +223,22 @@ expression: Promise.resolve(42)
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Promise
description : Promise
objectId : <objectId>
type : object
}
}
[1] : {
name : [[PromiseState]]
value : {
type : string
value : fulfilled
}
}
[1] : {
[2] : {
name : [[PromiseResult]]
value : {
description : 42
......@@ -183,13 +255,22 @@ expression: new Promise(() => undefined)
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Promise
description : Promise
objectId : <objectId>
type : object
}
}
[1] : {
name : [[PromiseState]]
value : {
type : string
value : pending
}
}
[1] : {
[2] : {
name : [[PromiseResult]]
value : {
type : undefined
......@@ -219,13 +300,22 @@ expression: gen1
}
}
[1] : {
name : [[Prototype]]
value : {
className : Generator
description : Generator
objectId : <objectId>
type : object
}
}
[2] : {
name : [[GeneratorState]]
value : {
type : string
value : suspended
}
}
[2] : {
[3] : {
name : [[GeneratorFunction]]
value : {
className : GeneratorFunction
......@@ -234,7 +324,7 @@ expression: gen1
type : function
}
}
[3] : {
[4] : {
name : [[GeneratorReceiver]]
value : {
className : global
......@@ -243,7 +333,7 @@ expression: gen1
type : object
}
}
[4] : {
[5] : {
name : [[Scopes]]
value : {
className : Array
......@@ -275,13 +365,22 @@ expression: gen1.next();gen1
}
}
[1] : {
name : [[Prototype]]
value : {
className : Generator
description : Generator
objectId : <objectId>
type : object
}
}
[2] : {
name : [[GeneratorState]]
value : {
type : string
value : suspended
}
}
[2] : {
[3] : {
name : [[GeneratorFunction]]
value : {
className : GeneratorFunction
......@@ -290,7 +389,7 @@ expression: gen1.next();gen1
type : function
}
}
[3] : {
[4] : {
name : [[GeneratorReceiver]]
value : {
className : global
......@@ -299,7 +398,7 @@ expression: gen1.next();gen1
type : object
}
}
[4] : {
[5] : {
name : [[Scopes]]
value : {
className : Array
......@@ -331,13 +430,22 @@ expression: gen1.next();gen1
}
}
[1] : {
name : [[Prototype]]
value : {
className : Generator
description : Generator
objectId : <objectId>
type : object
}
}
[2] : {
name : [[GeneratorState]]
value : {
type : string
value : closed
}
}
[2] : {
[3] : {
name : [[GeneratorFunction]]
value : {
className : GeneratorFunction
......@@ -346,7 +454,7 @@ expression: gen1.next();gen1
type : function
}
}
[3] : {
[4] : {
name : [[GeneratorReceiver]]
value : {
className : global
......@@ -379,13 +487,22 @@ expression: gen2
}
}
[1] : {
name : [[Prototype]]
value : {
className : Generator
description : Generator
objectId : <objectId>
type : object
}
}
[2] : {
name : [[GeneratorState]]
value : {
type : string
value : suspended
}
}
[2] : {
[3] : {
name : [[GeneratorFunction]]
value : {
className : GeneratorFunction
......@@ -394,7 +511,7 @@ expression: gen2
type : function
}
}
[3] : {
[4] : {
name : [[GeneratorReceiver]]
value : {
className : global
......@@ -403,7 +520,7 @@ expression: gen2
type : object
}
}
[4] : {
[5] : {
name : [[Scopes]]
value : {
className : Array
......@@ -435,13 +552,22 @@ expression: gen2.next();gen2
}
}
[1] : {
name : [[Prototype]]
value : {
className : Generator
description : Generator
objectId : <objectId>
type : object
}
}
[2] : {
name : [[GeneratorState]]
value : {
type : string
value : suspended
}
}
[2] : {
[3] : {
name : [[GeneratorFunction]]
value : {
className : GeneratorFunction
......@@ -450,7 +576,7 @@ expression: gen2.next();gen2
type : function
}
}
[3] : {
[4] : {
name : [[GeneratorReceiver]]
value : {
className : global
......@@ -459,7 +585,7 @@ expression: gen2.next();gen2
type : object
}
}
[4] : {
[5] : {
name : [[Scopes]]
value : {
className : Array
......@@ -491,13 +617,22 @@ expression: gen2.next();gen2
}
}
[1] : {
name : [[Prototype]]
value : {
className : Generator
description : Generator
objectId : <objectId>
type : object
}
}
[2] : {
name : [[GeneratorState]]
value : {
type : string
value : closed
}
}
[2] : {
[3] : {
name : [[GeneratorFunction]]
value : {
className : GeneratorFunction
......@@ -506,7 +641,7 @@ expression: gen2.next();gen2
type : function
}
}
[3] : {
[4] : {
name : [[GeneratorReceiver]]
value : {
className : global
......@@ -526,13 +661,22 @@ expression: (new Map([[1,2]])).entries()
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Map Iterator
description : Map Iterator
objectId : <objectId>
type : object
}
}
[1] : {
name : [[IteratorHasMore]]
value : {
type : boolean
value : true
}
}
[1] : {
[2] : {
name : [[IteratorIndex]]
value : {
description : 0
......@@ -540,14 +684,14 @@ expression: (new Map([[1,2]])).entries()
value : 0
}
}
[2] : {
[3] : {
name : [[IteratorKind]]
value : {
type : string
value : entries
}
}
[3] : {
[4] : {
name : [[Entries]]
value : {
className : Array
......@@ -566,13 +710,22 @@ expression: (new Set([[1,2]])).entries()
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Set Iterator
description : Set Iterator
objectId : <objectId>
type : object
}
}
[1] : {
name : [[IteratorHasMore]]
value : {
type : boolean
value : true
}
}
[1] : {
[2] : {
name : [[IteratorIndex]]
value : {
description : 0
......@@ -580,14 +733,14 @@ expression: (new Set([[1,2]])).entries()
value : 0
}
}
[2] : {
[3] : {
name : [[IteratorKind]]
value : {
type : string
value : entries
}
}
[3] : {
[4] : {
name : [[Entries]]
value : {
className : Array
......
......@@ -4,6 +4,17 @@ Running test: testObject
{
id : <messageId>
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
]
result : [
[0] : {
configurable : true
......@@ -17,25 +28,23 @@ Running test: testObject
}
writable : true
}
[1] : {
configurable : true
enumerable : false
isOwn : true
name : __proto__
]
}
}
{
id : <messageId>
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
writable : true
}
]
}
}
{
id : <messageId>
result : {
result : [
[0] : {
configurable : false
......@@ -120,19 +129,6 @@ Running test: testObject
}
writable : false
}
[6] : {
configurable : true
enumerable : false
isOwn : true
name : __proto__
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
writable : true
}
]
}
}
......@@ -5,6 +5,17 @@ Retrieving properties in 2
{
id : <messageId>
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
]
result : [
[0] : {
configurable : true
......@@ -18,26 +29,24 @@ Retrieving properties in 2
}
writable : true
}
[1] : {
configurable : true
enumerable : false
isOwn : true
name : __proto__
]
}
}
Retrieving properties in 1
{
id : <messageId>
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
writable : true
}
]
}
}
Retrieving properties in 1
{
id : <messageId>
result : {
result : [
[0] : {
configurable : true
......@@ -51,19 +60,6 @@ Retrieving properties in 1
}
writable : true
}
[1] : {
configurable : true
enumerable : false
isOwn : true
name : __proto__
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
writable : true
}
]
}
}
......@@ -72,6 +68,17 @@ Retrieving properties in 1
{
id : <messageId>
result : {
internalProperties : [
[0] : {
name : [[Prototype]]
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
}
]
result : [
[0] : {
configurable : true
......@@ -85,19 +92,6 @@ Retrieving properties in 1
}
writable : true
}
[1] : {
configurable : true
enumerable : false
isOwn : true
name : __proto__
value : {
className : Object
description : Object
objectId : <objectId>
type : object
}
writable : true
}
]
}
}
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