2016-10-07 01:16:10 +00:00
|
|
|
// Copyright 2016 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.
|
2019-02-26 22:09:31 +00:00
|
|
|
//
|
|
|
|
// Flags: --harmony-class-fields
|
2016-10-07 01:16:10 +00:00
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start("Check internal properties reported in object preview.");
|
2016-10-07 01:16:10 +00:00
|
|
|
|
|
|
|
Protocol.Debugger.enable();
|
|
|
|
Protocol.Runtime.enable();
|
|
|
|
Protocol.Runtime.onConsoleAPICalled(dumpInternalPropertiesAndEntries);
|
|
|
|
|
2017-08-25 23:13:23 +00:00
|
|
|
contextGroup.setupInjectedScriptEnvironment();
|
|
|
|
|
2016-10-07 01:16:10 +00:00
|
|
|
InspectorTest.runTestSuite([
|
|
|
|
function boxedObjects(next)
|
|
|
|
{
|
|
|
|
checkExpression("new Number(239)")
|
|
|
|
.then(() => checkExpression("new Boolean(false)"))
|
|
|
|
.then(() => checkExpression("new String(\"abc\")"))
|
|
|
|
.then(() => checkExpression("Object(Symbol(42))"))
|
2018-03-09 18:23:37 +00:00
|
|
|
.then(() => checkExpression("Object(BigInt(2))"))
|
2016-10-07 01:16:10 +00:00
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function promise(next)
|
|
|
|
{
|
|
|
|
checkExpression("Promise.resolve(42)")
|
|
|
|
.then(() => checkExpression("new Promise(() => undefined)"))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function generatorObject(next)
|
|
|
|
{
|
|
|
|
checkExpression("(function* foo() { yield 1 })()")
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function entriesInMapAndSet(next)
|
|
|
|
{
|
|
|
|
checkExpression("new Map([[1,2]])")
|
|
|
|
.then(() => checkExpression("new Set([1])"))
|
|
|
|
.then(() => checkExpression("new WeakMap([[{}, 42]])"))
|
|
|
|
.then(() => checkExpression("new WeakSet([{}])"))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function iteratorObject(next)
|
|
|
|
{
|
|
|
|
checkExpression("(new Map([[1,2]])).entries()")
|
2019-01-21 14:56:16 +00:00
|
|
|
.then(() => checkExpression("(new Set([1,2])).entries()"))
|
2016-10-07 01:16:10 +00:00
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function noPreviewForFunctionObject(next)
|
|
|
|
{
|
|
|
|
var expression = "(function foo(){})";
|
|
|
|
InspectorTest.log(expression);
|
|
|
|
Protocol.Runtime.evaluate({ expression: expression, generatePreview: true})
|
|
|
|
.then(message => InspectorTest.logMessage(message))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function otherObjects(next)
|
|
|
|
{
|
|
|
|
checkExpression("[1,2,3]")
|
|
|
|
.then(() => checkExpression("/123/"))
|
|
|
|
.then(() => checkExpression("({})"))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function overridenArrayGetter(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ expression: "Array.prototype.__defineGetter__(\"0\",() => { throw new Error() }) "})
|
|
|
|
.then(() => checkExpression("Promise.resolve(42)"))
|
|
|
|
.then(next);
|
2019-02-26 22:09:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
function privateNames(next)
|
|
|
|
{
|
|
|
|
checkExpression("new class { #foo = 1; #bar = 2; baz = 3;}")
|
|
|
|
.then(() => checkExpression("new class extends class { #baz = 3; } { #foo = 1; #bar = 2; }"))
|
|
|
|
.then(() => checkExpression("new class extends class { constructor() { return new Proxy({}, {}); } } { #foo = 1; #bar = 2; }"))
|
|
|
|
.then(next);
|
2019-08-21 07:55:47 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
function functionProxy(next)
|
|
|
|
{
|
|
|
|
checkExpression("new Proxy(() => {}, { get: () => x++ })")
|
|
|
|
.then(next);
|
2016-10-07 01:16:10 +00:00
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
|
|
|
function checkExpression(expression)
|
|
|
|
{
|
|
|
|
InspectorTest.log(`expression: ${expression}`);
|
|
|
|
// console.table has higher limits for internal properties amount in preview.
|
|
|
|
return Protocol.Runtime.evaluate({ expression: `console.table(${expression})`, generatePreview: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
function dumpInternalPropertiesAndEntries(message)
|
|
|
|
{
|
|
|
|
var properties;
|
|
|
|
var entries;
|
|
|
|
try {
|
|
|
|
var preview = message.params.args[0].preview;
|
|
|
|
properties = preview.properties;
|
|
|
|
entries = preview.entries;
|
|
|
|
} catch (e) {
|
|
|
|
InspectorTest.logMessage(message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!properties) {
|
|
|
|
InspectorTest.logMessage(message);
|
|
|
|
return;
|
|
|
|
}
|
2017-08-25 22:33:01 +00:00
|
|
|
for (var property of properties)
|
|
|
|
InspectorTest.logMessage(property);
|
2016-10-07 01:16:10 +00:00
|
|
|
if (entries) {
|
|
|
|
InspectorTest.log("[[Entries]]:");
|
|
|
|
InspectorTest.logMessage(entries);
|
|
|
|
}
|
|
|
|
InspectorTest.log("");
|
|
|
|
}
|