blob: 224bbccc73b70541ad39b3565b300aa43433b258 [file] [log] [blame]
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/elements-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>
<script>
var globalObject = {
foo: {
bar: {
baz: 2012
}
}
};
var windowAlias = window;
var test = function()
{
var watchExpressionsSection;
// We need to initialize scripts panel so that watch expressions section is created.
WebInspector.showPanel("scripts");
InspectorTest.startDebuggerTest(step1);
function step1()
{
var watchExpressionsPane = WebInspector.panels.scripts.sidebarPanes.watchExpressions;
watchExpressionsPane.expand();
watchExpressionsSection = watchExpressionsPane.section;
watchExpressionsSection.watchExpressions = [];
watchExpressionsSection.watchExpressions.push("globalObject");
watchExpressionsSection.watchExpressions.push("windowAlias");
InspectorTest.addSniffer(WebInspector.WatchExpressionsSection.prototype, "updateProperties", step2);
watchExpressionsSection.update();
}
function expandProperty(parent, path, callback)
{
if (!path.length) return callback();
var childName = path.shift();
var child = InspectorTest._findChildPropertyTreeElement(parent, childName);
if (!child) {
InspectorTest.addResult("Child not found: " + childName);
InspectorTest.completeTest()
return;
}
InspectorTest.addResult("expanded " + childName + " " + child.property.value);
function afterGetOwnProperties() {
InspectorTest.runAfterPendingDispatches(expandProperty.bind(this, child, path, callback));
}
InspectorTest.addSniffer(child.property.value, "getOwnProperties", afterGetOwnProperties.bind(this));
child.expand();
}
function dumpObjectPropertiesTreeElement(treeElement, indent)
{
if (treeElement.property)
InspectorTest.addResult(indent + treeElement.property.name + ": " + treeElement.property.value._description);
for (var i = 0; i < treeElement.children.length; i++)
dumpObjectPropertiesTreeElement(treeElement.children[i], " " + indent);
}
function step2()
{
InspectorTest.addResult("Watch expressions added.");
expandProperty(watchExpressionsSection.propertiesTreeOutline, ["globalObject", "foo", "bar"], step3);
}
function step3()
{
InspectorTest.addResult("Watch expressions expanded.");
dumpObjectPropertiesTreeElement(watchExpressionsSection.propertiesTreeOutline, "");
InspectorTest.reloadPage(step4);
}
function step4()
{
InspectorTest.addResult("Watch expressions after page reload:");
dumpObjectPropertiesTreeElement(watchExpressionsSection.propertiesTreeOutline, "");
// Clear watch expressions after execution.
watchExpressionsSection.watchExpressions = [];
watchExpressionsSection.update();
InspectorTest.completeDebuggerTest();
}
}
</script>
</head>
<body onload="runTest()">
<p>Test that watch expressions expansion state is restored after update.</p>
<a href="https://bugs.webkit.org/show_bug.cgi?id=99304">Bug 99304</a>
</body>
</html>