2016-12-07 22:31:21 +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.
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start("Tests that Runtime.evaluate will generate correct previews.");
|
2016-12-07 22:31:21 +00:00
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.addScript(
|
2016-12-07 22:31:21 +00:00
|
|
|
`
|
2016-12-07 22:33:56 +00:00
|
|
|
var f1 = function(){};
|
|
|
|
|
2016-12-07 22:31:21 +00:00
|
|
|
Object.prototype[0] = 'default-first';
|
2016-12-07 22:33:56 +00:00
|
|
|
var obj = {p1: {a:1}, p2: {b:'foo'}, p3: f1};
|
2016-12-07 22:31:21 +00:00
|
|
|
Object.defineProperties(obj, {
|
2016-12-07 22:33:56 +00:00
|
|
|
p4: {
|
2016-12-07 22:31:21 +00:00
|
|
|
get() { return 2 }
|
|
|
|
},
|
2016-12-07 22:33:56 +00:00
|
|
|
p5: {
|
2016-12-07 22:31:21 +00:00
|
|
|
set(x) { return x }
|
|
|
|
},
|
2016-12-07 22:33:56 +00:00
|
|
|
p6: {
|
2016-12-07 22:31:21 +00:00
|
|
|
get() { return 2 },
|
|
|
|
set(x) { return x }
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Array.prototype[0] = 'default-first';
|
2016-12-07 22:33:56 +00:00
|
|
|
var arr = [,, 1, [2], f1];
|
2016-12-07 22:31:21 +00:00
|
|
|
Object.defineProperties(arr, {
|
2016-12-07 22:33:56 +00:00
|
|
|
5: {
|
2016-12-07 22:31:21 +00:00
|
|
|
get() { return 2 }
|
|
|
|
},
|
2016-12-07 22:33:56 +00:00
|
|
|
6: {
|
2016-12-07 22:31:21 +00:00
|
|
|
set(x) { return x }
|
|
|
|
},
|
2016-12-07 22:33:56 +00:00
|
|
|
7: {
|
2016-12-07 22:31:21 +00:00
|
|
|
get() { return 2 },
|
|
|
|
set(x) { return x }
|
|
|
|
}
|
|
|
|
});
|
2016-12-07 22:33:56 +00:00
|
|
|
arr.nonEntryFunction = f1;
|
|
|
|
|
|
|
|
var inheritingObj = {};
|
|
|
|
var inheritingArr = [];
|
|
|
|
inheritingObj.prototype = obj;
|
|
|
|
inheritingArr.prototype = arr;
|
2017-03-03 19:30:40 +00:00
|
|
|
|
|
|
|
var shortTypedArray = new Uint8Array(3);
|
|
|
|
var longTypedArray = new Uint8Array(500001);
|
|
|
|
var set = new Set([1, 2, 3]);
|
|
|
|
var bigSet = new Set();
|
|
|
|
var mixedSet = new Set();
|
|
|
|
for (var i = 0; i < 10; i++) {
|
|
|
|
bigSet.add(i);
|
|
|
|
mixedSet["_prop_" + i] = 1;
|
|
|
|
mixedSet.add(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
var deterministicNativeFunction = Math.log;
|
|
|
|
var parentObj = {};
|
|
|
|
Object.defineProperty(parentObj, 'propNotNamedProto', {
|
|
|
|
get: deterministicNativeFunction,
|
|
|
|
set: function() {}
|
|
|
|
});
|
|
|
|
var objInheritsGetterProperty = {__proto__: parentObj};
|
2017-04-21 23:41:07 +00:00
|
|
|
inspector.allowAccessorFormatting(objInheritsGetterProperty);
|
2016-12-07 22:31:21 +00:00
|
|
|
`);
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.setupInjectedScriptEnvironment();
|
2017-03-24 17:38:12 +00:00
|
|
|
|
2016-12-07 22:31:21 +00:00
|
|
|
InspectorTest.runTestSuite([
|
|
|
|
function testObjectPropertiesPreview(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "obj", "generatePreview": true })
|
|
|
|
.then(result => InspectorTest.logMessage(result.result.result.preview))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function testArrayPropertiesPreview(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "arr", "generatePreview": true })
|
|
|
|
.then(result => InspectorTest.logMessage(result.result.result.preview))
|
|
|
|
.then(next);
|
2016-12-07 22:33:56 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
function testInheritingObjectPropertiesPreview(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "inheritingObj", "generatePreview": true })
|
|
|
|
.then(result => InspectorTest.logMessage(result.result.result.preview))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function testInheritingArrayPropertiesPreview(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "inheritingArr", "generatePreview": true })
|
|
|
|
.then(result => InspectorTest.logMessage(result.result.result.preview))
|
|
|
|
.then(next);
|
2017-03-03 19:30:40 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
function testShortTypedArrayPropertiesPreview(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "shortTypedArray", "generatePreview": true })
|
|
|
|
.then(result => InspectorTest.logMessage(result.result.result.preview))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function testLongTypedArrayPropertiesPreview(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "longTypedArray", "generatePreview": true })
|
|
|
|
.then(result => InspectorTest.logMessage(result.result.result.preview))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function testSetPropertiesPreview(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "set", "generatePreview": true })
|
|
|
|
.then(result => InspectorTest.logMessage(result.result.result.preview))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function testBigSetPropertiesPreview(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "bigSet", "generatePreview": true })
|
|
|
|
.then(result => InspectorTest.logMessage(result.result.result.preview))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function testMixedSetPropertiesPreview(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "mixedSet", "generatePreview": true })
|
|
|
|
.then(result => InspectorTest.logMessage(result.result.result.preview))
|
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function testObjInheritsGetterProperty(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "objInheritsGetterProperty", "generatePreview": true })
|
|
|
|
.then(result => InspectorTest.logMessage(result.result.result.preview))
|
|
|
|
.then(next);
|
2017-03-24 17:38:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
function testObjWithArrayAsProto(next)
|
|
|
|
{
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "Object.create([1,2])", "generatePreview": true })
|
|
|
|
.then(result => InspectorTest.logMessage(result.result.result.preview))
|
|
|
|
.then(next);
|
2016-12-07 22:31:21 +00:00
|
|
|
}
|
|
|
|
]);
|