blob: 1dbb844edda726fa9459158856a68880fd32ce59 [file] [log] [blame]
<!doctype html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
// ------------------------------
// Setup Test Prototype Chain
// ------------------------------
function SuperBar() { this._bar = 10; }
SuperBar.prototype = {
__proto__: Object.prototype,
constructor: SuperBar,
BAR_CONSTANT: 99,
get getterProperty() { return 20; },
get bar() { return this._bar; },
set setterOnly(x) {},
};
function SuperFoo() { SuperBar.call(this); this._foo = 5; }
SuperFoo.prototype = {
__proto__: SuperBar.prototype,
constructor: SuperFoo,
get getterProperty() { return 10; },
get foo() { return this._foo; }
};
function ClassWithBadGetter() {}
ClassWithBadGetter.prototype = {
__proto__: Object.prototype,
constructor: ClassWithBadGetter,
get badGetter() { throw "throw in getter"; }
};
// --------------------
// Objects to Debug
// --------------------
// window.loadEvent is set inside of <body onload="..."> below.
var simpleObject = {a:1, b:"string"};
var simpleArray = [1, "two", /three/];
var arrayProto = [].__proto__;
var complexObject = new SuperFoo;
var badGetterObject = new ClassWithBadGetter;
var unboundFunction = function() { console.log(arguments); }
var boundFunction = unboundFunction.bind(document.body, 1, 2, 3);
var objectWithSymbolProperties = {prop:1, [Symbol()]:2, [Symbol('sym')]:3, [Symbol('sym')]:4, [Symbol()]: Symbol(), prop2: 5};
// --------
// test
// --------
function test()
{
var currentStepIndex = 0;
var steps = [
{expression: "window.simpleObject"},
{expression: "window.simpleArray"},
{expression: "window.arrayProto"},
{expression: "window.loadEvent"},
{expression: "window.complexObject"},
{expression: "window.badGetterObject"},
{expression: "window.unboundFunction"},
{expression: "window.boundFunction"},
{expression: "window.objectWithSymbolProperties"},
{expression: "document.getElementById('my-select').options"},
]
function runNextStep() {
if (currentStepIndex >= steps.length) {
InspectorTest.log("DONE");
InspectorTest.completeTest();
return;
}
var step = steps[currentStepIndex++];
InspectorTest.log("");
InspectorTest.log("-----------------------------------------------------");
InspectorTest.log("EXPRESSION: " + step.expression);
WI.runtimeManager.evaluateInInspectedWindow(step.expression, {objectGroup: "test", doNotPauseOnExceptionsAndMuteConsole: true}, function(remoteObject, wasThrown) {
InspectorTest.assert(remoteObject instanceof WI.RemoteObject);
InspectorTest.log("type: " + remoteObject.type);
if (remoteObject.subtype)
InspectorTest.log("subtype: " + remoteObject.subtype);
InspectorTest.log("description: " + remoteObject.description);
const options = {
ownProperties: true,
};
remoteObject.getPropertyDescriptors(function(properties) {
InspectorTest.log("\nOWN PROPERTIES:");
for (var property of properties) {
InspectorTest.assert(property instanceof WI.PropertyDescriptor);
InspectorTest.log(" " + property.name);
}
}, options);
remoteObject.getDisplayablePropertyDescriptors(function(properties) {
InspectorTest.log("\nDISPLAYABLE PROPERTIES:");
for (var property of properties) {
InspectorTest.assert(property instanceof WI.PropertyDescriptor);
InspectorTest.log(" " + property.name);
}
});
remoteObject.getPropertyDescriptors(function(properties) {
InspectorTest.log("\nALL PROPERTIES:");
for (var property of properties) {
InspectorTest.assert(property instanceof WI.PropertyDescriptor);
InspectorTest.log(" " + property.name);
}
InspectorTest.log("-----------------------------------------------------");
runNextStep();
});
});
}
runNextStep();
}
</script>
</head>
<body onload="window.loadEvent = event; runTest()">
<select id="my-select" style="display: none">
<option name="1" id="attr_1" value="1"></option>
</select>
</body>
</html>