diff --git a/common.gypi b/common.gypi index 57a7b72c91b2e4..2a40282d211747 100644 --- a/common.gypi +++ b/common.gypi @@ -30,7 +30,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.15', + 'v8_embedder_string': '-node.16', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 5ac9aec0479277..94b1179d5db8bf 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -9950,6 +9950,47 @@ debug::TypeProfile::ScriptData debug::TypeProfile::GetScriptData( return ScriptData(i, type_profile_); } +v8::MaybeLocal debug::WeakMap::Get(v8::Local context, + v8::Local key) { + PREPARE_FOR_EXECUTION(context, WeakMap, Get, Value); + auto self = Utils::OpenHandle(this); + Local result; + i::Handle argv[] = {Utils::OpenHandle(*key)}; + has_pending_exception = + !ToLocal(i::Execution::Call(isolate, isolate->weakmap_get(), self, + arraysize(argv), argv), + &result); + RETURN_ON_FAILED_EXECUTION(Value); + RETURN_ESCAPED(result); +} + +v8::MaybeLocal debug::WeakMap::Set( + v8::Local context, v8::Local key, + v8::Local value) { + PREPARE_FOR_EXECUTION(context, WeakMap, Set, WeakMap); + auto self = Utils::OpenHandle(this); + i::Handle result; + i::Handle argv[] = {Utils::OpenHandle(*key), + Utils::OpenHandle(*value)}; + has_pending_exception = !i::Execution::Call(isolate, isolate->weakmap_set(), + self, arraysize(argv), argv) + .ToHandle(&result); + RETURN_ON_FAILED_EXECUTION(WeakMap); + RETURN_ESCAPED(Local::Cast(Utils::ToLocal(result))); +} + +Local debug::WeakMap::New(v8::Isolate* isolate) { + i::Isolate* i_isolate = reinterpret_cast(isolate); + LOG_API(i_isolate, WeakMap, New); + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); + i::Handle obj = i_isolate->factory()->NewJSWeakMap(); + return ToApiHandle(obj); +} + +debug::WeakMap* debug::WeakMap::Cast(v8::Value* value) { + return static_cast(value); +} + const char* CpuProfileNode::GetFunctionNameStr() const { const i::ProfileNode* node = reinterpret_cast(this); return node->entry()->name(); diff --git a/deps/v8/src/api.h b/deps/v8/src/api.h index ae0ce350a4aaac..e5f5c7da70f9e0 100644 --- a/deps/v8/src/api.h +++ b/deps/v8/src/api.h @@ -116,6 +116,7 @@ class RegisteredExtension { V(Proxy, JSProxy) \ V(debug::GeneratorObject, JSGeneratorObject) \ V(debug::Script, Script) \ + V(debug::WeakMap, JSWeakMap) \ V(Promise, JSPromise) \ V(Primitive, Object) \ V(PrimitiveArray, FixedArray) \ diff --git a/deps/v8/src/bootstrapper.cc b/deps/v8/src/bootstrapper.cc index 30450b133b0ad5..b181f3839c3958 100644 --- a/deps/v8/src/bootstrapper.cc +++ b/deps/v8/src/bootstrapper.cc @@ -3435,8 +3435,9 @@ void Genesis::InitializeGlobal(Handle global_object, SimpleInstallFunction(isolate_, prototype, "delete", Builtins::kWeakMapPrototypeDelete, 1, true); - SimpleInstallFunction(isolate_, prototype, "get", Builtins::kWeakMapGet, 1, - true); + Handle weakmap_get = SimpleInstallFunction( + isolate_, prototype, "get", Builtins::kWeakMapGet, 1, true); + native_context()->set_weakmap_get(*weakmap_get); SimpleInstallFunction(isolate_, prototype, "has", Builtins::kWeakMapHas, 1, true); Handle weakmap_set = SimpleInstallFunction( diff --git a/deps/v8/src/contexts.h b/deps/v8/src/contexts.h index 709ae6164af6f1..f89b28dadc8dcc 100644 --- a/deps/v8/src/contexts.h +++ b/deps/v8/src/contexts.h @@ -112,6 +112,7 @@ enum ContextLookupFlags { V(WASM_RUNTIME_ERROR_FUNCTION_INDEX, JSFunction, \ wasm_runtime_error_function) \ V(WEAKMAP_SET_INDEX, JSFunction, weakmap_set) \ + V(WEAKMAP_GET_INDEX, JSFunction, weakmap_get) \ V(WEAKSET_ADD_INDEX, JSFunction, weakset_add) #define NATIVE_CONTEXT_FIELDS(V) \ diff --git a/deps/v8/src/counters.h b/deps/v8/src/counters.h index fed7edb44a5878..5e913139d8e17b 100644 --- a/deps/v8/src/counters.h +++ b/deps/v8/src/counters.h @@ -750,6 +750,9 @@ class RuntimeCallTimer final { V(Map_Has) \ V(Map_New) \ V(Map_Set) \ + V(WeakMap_Get) \ + V(WeakMap_Set) \ + V(WeakMap_New) \ V(Message_GetEndColumn) \ V(Message_GetLineNumber) \ V(Message_GetSourceLine) \ diff --git a/deps/v8/src/debug/debug-interface.h b/deps/v8/src/debug/debug-interface.h index ac8073e02c793a..afc2b96e5ab6a5 100644 --- a/deps/v8/src/debug/debug-interface.h +++ b/deps/v8/src/debug/debug-interface.h @@ -502,6 +502,20 @@ class PostponeInterruptsScope { std::unique_ptr scope_; }; +class WeakMap : public v8::Object { + public: + V8_WARN_UNUSED_RESULT v8::MaybeLocal Get( + v8::Local context, v8::Local key); + V8_WARN_UNUSED_RESULT v8::MaybeLocal Set( + v8::Local context, v8::Local key, + v8::Local value); + + static Local New(v8::Isolate* isolate); + V8_INLINE static WeakMap* Cast(Value* obj); + + private: + WeakMap(); +}; } // namespace debug } // namespace v8 diff --git a/deps/v8/src/inspector/v8-debugger.cc b/deps/v8/src/inspector/v8-debugger.cc index ccc674af4369a6..99811d5ac4584c 100644 --- a/deps/v8/src/inspector/v8-debugger.cc +++ b/deps/v8/src/inspector/v8-debugger.cc @@ -751,11 +751,37 @@ v8::MaybeLocal V8Debugger::generatorScopes( return getTargetScopes(context, generator, GENERATOR); } +v8::MaybeLocal V8Debugger::stableObjectId( + v8::Local context, v8::Local value) { + DCHECK(value->IsObject()); + if (m_stableObjectId.IsEmpty()) { + m_stableObjectId.Reset(m_isolate, v8::debug::WeakMap::New(m_isolate)); + } + v8::Local stableObjectId = + m_stableObjectId.Get(m_isolate); + v8::Local idValue; + if (!stableObjectId->Get(context, value).ToLocal(&idValue) || + !idValue->IsUint32()) { + idValue = v8::Integer::NewFromUnsigned(m_isolate, ++m_lastStableObjectId); + stableObjectId->Set(context, value, idValue).ToLocalChecked(); + } + return idValue.As(); +} + v8::MaybeLocal V8Debugger::internalProperties( v8::Local context, v8::Local value) { v8::Local properties; if (!v8::debug::GetInternalProperties(m_isolate, value).ToLocal(&properties)) return v8::MaybeLocal(); + if (value->IsObject()) { + v8::Local id; + if (stableObjectId(context, value).ToLocal(&id)) { + createDataProperty( + context, properties, properties->Length(), + toV8StringInternalized(m_isolate, "[[StableObjectId]]")); + createDataProperty(context, properties, properties->Length(), id); + } + } if (value->IsFunction()) { v8::Local function = value.As(); v8::Local location; diff --git a/deps/v8/src/inspector/v8-debugger.h b/deps/v8/src/inspector/v8-debugger.h index 72962dde316354..7b48134d7ab880 100644 --- a/deps/v8/src/inspector/v8-debugger.h +++ b/deps/v8/src/inspector/v8-debugger.h @@ -189,6 +189,9 @@ class V8Debugger : public v8::debug::DebugDelegate, int currentContextGroupId(); bool asyncStepOutOfFunction(int targetContextGroupId, bool onlyAtReturn); + v8::MaybeLocal stableObjectId(v8::Local, + v8::Local); + v8::Isolate* m_isolate; V8InspectorImpl* m_inspector; int m_enableCount; @@ -245,6 +248,9 @@ class V8Debugger : public v8::debug::DebugDelegate, std::unique_ptr m_terminateExecutionCallback; + uint32_t m_lastStableObjectId = 0; + v8::Global m_stableObjectId; + WasmTranslation m_wasmTranslation; DISALLOW_COPY_AND_ASSIGN(V8Debugger); diff --git a/deps/v8/test/inspector/debugger/eval-scopes-expected.txt b/deps/v8/test/inspector/debugger/eval-scopes-expected.txt index 71d6618c8e8387..4c93498c68f134 100644 --- a/deps/v8/test/inspector/debugger/eval-scopes-expected.txt +++ b/deps/v8/test/inspector/debugger/eval-scopes-expected.txt @@ -2,6 +2,12 @@ Tests that variables introduced in eval scopes are accessible { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true diff --git a/deps/v8/test/inspector/debugger/scope-skip-variables-with-empty-name-expected.txt b/deps/v8/test/inspector/debugger/scope-skip-variables-with-empty-name-expected.txt index 626f9787c37993..6fbe355eff54c1 100644 --- a/deps/v8/test/inspector/debugger/scope-skip-variables-with-empty-name-expected.txt +++ b/deps/v8/test/inspector/debugger/scope-skip-variables-with-empty-name-expected.txt @@ -2,6 +2,12 @@ Tests that scopes do not report variables with empty names { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true diff --git a/deps/v8/test/inspector/protocol-test.js b/deps/v8/test/inspector/protocol-test.js index a9412806727583..73516a89d2e5fa 100644 --- a/deps/v8/test/inspector/protocol-test.js +++ b/deps/v8/test/inspector/protocol-test.js @@ -45,6 +45,8 @@ InspectorTest.logMessage = function(originalMessage) { var objects = [ message ]; while (objects.length) { var object = objects.shift(); + if (object && object.name === '[[StableObjectId]]') + object.value = ''; for (var key in object) { if (nonStableFields.has(key)) object[key] = `<${key}>`; diff --git a/deps/v8/test/inspector/runtime/es6-module-expected.txt b/deps/v8/test/inspector/runtime/es6-module-expected.txt index 25ba52e0341c2e..051ef6ceae183c 100644 --- a/deps/v8/test/inspector/runtime/es6-module-expected.txt +++ b/deps/v8/test/inspector/runtime/es6-module-expected.txt @@ -128,6 +128,12 @@ console.log(239) { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true diff --git a/deps/v8/test/inspector/runtime/get-properties-expected.txt b/deps/v8/test/inspector/runtime/get-properties-expected.txt index 8b48e65c3b7060..5707ffc5afd2de 100644 --- a/deps/v8/test/inspector/runtime/get-properties-expected.txt +++ b/deps/v8/test/inspector/runtime/get-properties-expected.txt @@ -5,6 +5,7 @@ Running test: testObject5 foo own string cat Internal properties [[PrimitiveValue]] number 5 + [[StableObjectId]]: Running test: testNotOwn __defineGetter__ inherited function undefined @@ -23,6 +24,8 @@ Running test: testNotOwn toLocaleString inherited function undefined toString inherited function undefined valueOf inherited function undefined +Internal properties + [[StableObjectId]]: Running test: testAccessorsOnly b own no value, getter, setter @@ -34,6 +37,8 @@ Running test: testArray 2 own string blue __proto__ own object undefined length own number 3 +Internal properties + [[StableObjectId]]: Running test: testBound __proto__ own function undefined @@ -42,14 +47,19 @@ Running test: testBound Internal properties [[BoundArgs]] object undefined [[BoundThis]] object undefined + [[StableObjectId]]: [[TargetFunction]] function undefined Running test: testObjectThrowsLength __proto__ own object undefined length own no value, getter +Internal properties + [[StableObjectId]]: Running test: testTypedArrayWithoutLength __proto__ own object undefined +Internal properties + [[StableObjectId]]: Running test: testArrayBuffer [[Int8Array]] @@ -62,6 +72,8 @@ Running test: testArrayBuffer 6 own number 1 7 own number 1 __proto__ own object undefined +Internal properties + [[StableObjectId]]: [[Uint8Array]] 0 own number 1 1 own number 1 @@ -72,18 +84,26 @@ Running test: testArrayBuffer 6 own number 1 7 own number 1 __proto__ own object undefined +Internal properties + [[StableObjectId]]: [[Int16Array]] 0 own number 257 1 own number 257 2 own number 257 3 own number 257 __proto__ own object undefined +Internal properties + [[StableObjectId]]: [[Int32Array]] 0 own number 16843009 1 own number 16843009 __proto__ own object undefined +Internal properties + [[StableObjectId]]: Running test: testArrayBufferWithBrokenUintCtor [[Int8Array]] own object undefined [[Uint8Array]] own object undefined __proto__ own object undefined +Internal properties + [[StableObjectId]]: diff --git a/deps/v8/test/inspector/runtime/get-properties-on-proxy-expected.txt b/deps/v8/test/inspector/runtime/get-properties-on-proxy-expected.txt index a0437f4af6d644..efde782ae32b78 100644 --- a/deps/v8/test/inspector/runtime/get-properties-on-proxy-expected.txt +++ b/deps/v8/test/inspector/runtime/get-properties-on-proxy-expected.txt @@ -54,6 +54,10 @@ Testing regular Proxy value : false } } + [3] : { + name : [[StableObjectId]] + value : + } ] result : [ ] @@ -114,6 +118,10 @@ Testing revocable Proxy value : false } } + [3] : { + name : [[StableObjectId]] + value : + } ] result : [ ] @@ -166,6 +174,10 @@ Testing revocable Proxy value : true } } + [3] : { + name : [[StableObjectId]] + value : + } ] result : [ ] diff --git a/deps/v8/test/inspector/runtime/get-properties.js b/deps/v8/test/inspector/runtime/get-properties.js index d2b2c754a311e2..0386fdea6d87c5 100644 --- a/deps/v8/test/inspector/runtime/get-properties.js +++ b/deps/v8/test/inspector/runtime/get-properties.js @@ -94,7 +94,10 @@ async function logGetPropertiesResult(objectId, flags = { ownProperties: true }) for (var i = 0; i < internalPropertyArray.length; i++) { var p = internalPropertyArray[i]; var v = p.value; - InspectorTest.log(" " + p.name + " " + v.type + " " + v.value); + if (p.name !== '[[StableObjectId]]') + InspectorTest.log(" " + p.name + " " + v.type + " " + v.value); + else + InspectorTest.log(" [[StableObjectId]]: "); } } diff --git a/deps/v8/test/inspector/runtime/internal-properties-entries-expected.txt b/deps/v8/test/inspector/runtime/internal-properties-entries-expected.txt index d395067efe72b1..1d09e8dc1ebe77 100644 --- a/deps/v8/test/inspector/runtime/internal-properties-entries-expected.txt +++ b/deps/v8/test/inspector/runtime/internal-properties-entries-expected.txt @@ -15,6 +15,12 @@ expression: new Map([[1,2],[3,4]]) { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -65,6 +71,12 @@ expression: new Map() { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : false @@ -97,6 +109,12 @@ expression: new Map([[1,2],[3,4]]).entries() { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -151,6 +169,12 @@ expression: it = new Map([[1,2],[3,4]]).entries(); it.next(); it { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -190,6 +214,12 @@ expression: it = new Map([[1,2],[3,4]]).keys(); it.next(); it { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -229,6 +259,12 @@ expression: it = new Map([[1,2],[3,4]]).values(); it.next(); it { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -265,6 +301,12 @@ expression: it = new Map([[1,2],[3,4]]).entries(); it.next(); it.next(); it { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : false @@ -295,6 +337,12 @@ expression: new Set([1,2]) { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -345,6 +393,12 @@ expression: new Set() { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : false @@ -375,6 +429,12 @@ expression: new Set([1,2]).values() { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -428,6 +488,12 @@ expression: it = new Set([1,2]).values(); it.next(); it { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -467,6 +533,12 @@ expression: it = new Set([1,2]).keys(); it.next(); it { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -506,6 +578,12 @@ expression: it = new Set([1,2]).entries(); it.next(); it { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -542,6 +620,12 @@ expression: it = new Set([1,2]).values(); it.next(); it.next(); it { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : false @@ -566,6 +650,12 @@ expression: new WeakMap() { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : false @@ -594,6 +684,12 @@ expression: new WeakMap([[{ a: 2 }, 42]]) { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -632,6 +728,12 @@ expression: new WeakSet() { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : false @@ -659,6 +761,12 @@ expression: new WeakSet([{a:2}]) { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true diff --git a/deps/v8/test/inspector/runtime/internal-properties-expected.txt b/deps/v8/test/inspector/runtime/internal-properties-expected.txt index a2e38ab013f472..c114696eb81352 100644 --- a/deps/v8/test/inspector/runtime/internal-properties-expected.txt +++ b/deps/v8/test/inspector/runtime/internal-properties-expected.txt @@ -7,6 +7,10 @@ expression: (function* foo() { yield 1 }) result : { internalProperties : [ [0] : { + name : [[StableObjectId]] + value : + } + [1] : { name : [[FunctionLocation]] value : { description : Object @@ -19,14 +23,14 @@ expression: (function* foo() { yield 1 }) } } } - [1] : { + [2] : { name : [[IsGenerator]] value : { type : boolean value : true } } - [2] : { + [3] : { name : [[Scopes]] value : { className : Array @@ -47,6 +51,10 @@ expression: (function foo() {}) result : { internalProperties : [ [0] : { + name : [[StableObjectId]] + value : + } + [1] : { name : [[FunctionLocation]] value : { description : Object @@ -59,7 +67,7 @@ expression: (function foo() {}) } } } - [1] : { + [2] : { name : [[Scopes]] value : { className : Array @@ -87,6 +95,10 @@ expression: new Number(239) value : 239 } } + [1] : { + name : [[StableObjectId]] + value : + } ] } } @@ -102,6 +114,10 @@ expression: new Boolean(false) value : false } } + [1] : { + name : [[StableObjectId]] + value : + } ] } } @@ -117,6 +133,10 @@ expression: new String('abc') value : abc } } + [1] : { + name : [[StableObjectId]] + value : + } ] } } @@ -133,6 +153,10 @@ expression: Object(Symbol(42)) type : symbol } } + [1] : { + name : [[StableObjectId]] + value : + } ] } } @@ -149,6 +173,10 @@ expression: Object(BigInt(2)) unserializableValue : 2n } } + [1] : { + name : [[StableObjectId]] + value : + } ] } } @@ -174,6 +202,10 @@ expression: Promise.resolve(42) value : 42 } } + [2] : { + name : [[StableObjectId]] + value : + } ] } } @@ -195,6 +227,10 @@ expression: new Promise(() => undefined) type : undefined } } + [2] : { + name : [[StableObjectId]] + value : + } ] } } @@ -231,6 +267,10 @@ expression: gen1 } } [3] : { + name : [[StableObjectId]] + value : + } + [4] : { name : [[GeneratorLocation]] value : { description : Object @@ -243,7 +283,7 @@ expression: gen1 } } } - [4] : { + [5] : { name : [[Scopes]] value : { className : Array @@ -287,6 +327,10 @@ expression: gen1.next();gen1 } } [3] : { + name : [[StableObjectId]] + value : + } + [4] : { name : [[GeneratorLocation]] value : { description : Object @@ -299,7 +343,7 @@ expression: gen1.next();gen1 } } } - [4] : { + [5] : { name : [[Scopes]] value : { className : Array @@ -343,6 +387,10 @@ expression: gen1.next();gen1 } } [3] : { + name : [[StableObjectId]] + value : + } + [4] : { name : [[GeneratorLocation]] value : { description : Object @@ -391,6 +439,10 @@ expression: gen2 } } [3] : { + name : [[StableObjectId]] + value : + } + [4] : { name : [[GeneratorLocation]] value : { description : Object @@ -403,7 +455,7 @@ expression: gen2 } } } - [4] : { + [5] : { name : [[Scopes]] value : { className : Array @@ -447,6 +499,10 @@ expression: gen2.next();gen2 } } [3] : { + name : [[StableObjectId]] + value : + } + [4] : { name : [[GeneratorLocation]] value : { description : Object @@ -459,7 +515,7 @@ expression: gen2.next();gen2 } } } - [4] : { + [5] : { name : [[Scopes]] value : { className : Array @@ -503,6 +559,10 @@ expression: gen2.next();gen2 } } [3] : { + name : [[StableObjectId]] + value : + } + [4] : { name : [[GeneratorLocation]] value : { description : Object @@ -548,6 +608,10 @@ expression: (new Map([[1,2]])).entries() } } [3] : { + name : [[StableObjectId]] + value : + } + [4] : { name : [[Entries]] value : { className : Array @@ -588,6 +652,10 @@ expression: (new Set([[1,2]])).entries() } } [3] : { + name : [[StableObjectId]] + value : + } + [4] : { name : [[Entries]] value : { className : Array diff --git a/deps/v8/test/inspector/runtime/stable-object-id-expected.txt b/deps/v8/test/inspector/runtime/stable-object-id-expected.txt new file mode 100644 index 00000000000000..937727e1089f59 --- /dev/null +++ b/deps/v8/test/inspector/runtime/stable-object-id-expected.txt @@ -0,0 +1,14 @@ +Checks that protocol returns the same RemoteObjectId for the same object + +Running test: testGlobal +Compare global evaluated twice: true + +Running test: testObject +Compare object evaluated twice: true + +Running test: testObjectInArray +Compare first and second element: true + +Running test: testObjectOnPause +Compare global and this: true +Compare a and a on pause: true diff --git a/deps/v8/test/inspector/runtime/stable-object-id.js b/deps/v8/test/inspector/runtime/stable-object-id.js new file mode 100644 index 00000000000000..9a65e67d7f6855 --- /dev/null +++ b/deps/v8/test/inspector/runtime/stable-object-id.js @@ -0,0 +1,77 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +let {session, contextGroup, Protocol} = InspectorTest.start( + 'Checks that protocol returns the same RemoteObjectId for the same object'); + +InspectorTest.runAsyncTestSuite([ + async function testGlobal() { + const {result:{result:{objectId:firstId}}} = + await Protocol.Runtime.evaluate({expression: 'this'}); + const firstStableId = await stableObjectId(firstId); + const {result:{result:{objectId:secondId}}} = + await Protocol.Runtime.evaluate({expression: 'this'}); + const secondStableId = await stableObjectId(secondId); + InspectorTest.log( + `Compare global evaluated twice: ${firstStableId === secondStableId}`); + }, + + async function testObject() { + const {result:{result:{objectId:firstId}}} = + await Protocol.Runtime.evaluate({expression: 'this.a = {}, this.a'}); + const firstStableId = await stableObjectId(firstId); + const {result:{result:{objectId:secondId}}} = + await Protocol.Runtime.evaluate({expression: 'this.a'}); + const secondStableId = await stableObjectId(secondId); + InspectorTest.log( + `Compare object evaluated twice: ${firstStableId === secondStableId}`); + }, + + async function testObjectInArray() { + await Protocol.Runtime.evaluate({expression: 'this.b = [this.a, this.a]'}); + const {result:{result:{objectId:firstId}}} = + await Protocol.Runtime.evaluate({expression: 'this.b[0]'}); + const firstStableId = await stableObjectId(firstId); + const {result:{result:{objectId:secondId}}} = + await Protocol.Runtime.evaluate({expression: 'this.b[1]'}); + const secondStableId = await stableObjectId(secondId); + InspectorTest.log( + `Compare first and second element: ${firstStableId === secondStableId}`); + }, + + async function testObjectOnPause() { + const {result:{result:{objectId:globalId}}} = + await Protocol.Runtime.evaluate({expression: 'this'}); + const globalStableId = await stableObjectId(globalId); + const {result:{result:{objectId:aId}}} = + await Protocol.Runtime.evaluate({expression: 'this.a'}); + const aStableId = await stableObjectId(aId); + await Protocol.Debugger.enable(); + Protocol.Runtime.evaluate({expression: 'debugger'}); + const {params:{callFrames:[topFrame]}} = + await Protocol.Debugger.oncePaused(); + const topFrameThisStableId = await stableObjectId(topFrame.this.objectId); + InspectorTest.log( + `Compare global and this: ${globalStableId === topFrameThisStableId}`); + + const {result:{result: props}} = await Protocol.Runtime.getProperties({ + objectId: topFrame.scopeChain[0].object.objectId + }); + const {value:{objectId: aIdOnPause}} = props.find(prop => prop.name === 'a'); + const aStableIdOnPause = await stableObjectId(aIdOnPause); + InspectorTest.log(`Compare a and a on pause: ${ + aStableId === aStableIdOnPause}`); + } +]); + +async function stableObjectId(objectId) { + const {result:{ + internalProperties: props + }} = await Protocol.Runtime.getProperties({ + objectId, + ownProperties: true, + generatePreview: false + }); + return props.find(prop => prop.name === '[[StableObjectId]]').value.value; +} diff --git a/deps/v8/test/inspector/sessions/runtime-remote-object-expected.txt b/deps/v8/test/inspector/sessions/runtime-remote-object-expected.txt index a8d0ec0c207895..7c6e69e05d69be 100644 --- a/deps/v8/test/inspector/sessions/runtime-remote-object-expected.txt +++ b/deps/v8/test/inspector/sessions/runtime-remote-object-expected.txt @@ -5,6 +5,12 @@ Retrieving properties in 2 { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -38,6 +44,12 @@ Retrieving properties in 1 { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true @@ -72,6 +84,12 @@ Retrieving properties in 1 { id : result : { + internalProperties : [ + [0] : { + name : [[StableObjectId]] + value : + } + ] result : [ [0] : { configurable : true