blob: aba3cd9d59b0c26ec1ce3c469ba11e5118029ac2 [file] [log] [blame]
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/elements-test.js"></script>
<script>
var el1;
var el2;
function createDynamicElements()
{
var mainDoc = document;
var frameDoc = window.frames[0].document;
el1 = mainDoc.createElement('div');
el1.id = "main-frame-div";
el2 = frameDoc.createElement('div');
el2.id = "iframe-div";
el1.innerHTML = 'Element created via &lt;main document>.createElement';
el2.innerHTML = 'Element created via &lt;frame document>.createElement';
frameDoc.body.appendChild(el1);
frameDoc.body.appendChild(el2);
}
function test()
{
//InspectorTest.selectNodeWithId("main-frame-div", step1);
InspectorTest.evaluateInPage("createDynamicElements()", step1);
function selectedNodeId()
{
var selectedElement = WebInspector.panels.elements.treeOutline.selectedTreeElement;
if (!selectedElement)
return "<no selected node>";
return selectedElement.representedObject.getAttribute("id");
}
function step1()
{
InspectorTest.evaluateInConsole("inspect(el1)", step2);
}
function step2()
{
InspectorTest.runAfterPendingDispatches(step3);
}
function step3()
{
var id = selectedNodeId();
if (id === "main-frame-div")
InspectorTest.addResult("PASS: selected node with id '" + id + "'");
else
InspectorTest.addResult("FAIL: unexpected selection " + id);
InspectorTest.evaluateInConsole("inspect(el2)", step4);
}
function step4()
{
InspectorTest.runAfterPendingDispatches(step5);
}
function step5()
{
var id = selectedNodeId();
if (id === "iframe-div")
InspectorTest.addResult("PASS: selected node with id '" + id + "'");
else
InspectorTest.addResult("FAIL: unexpected selection " + id);
InspectorTest.completeTest();
}
}
</script>
</head>
<body onload="runTest()">
<p>Test that web inspector can select element in an iframe even if the element was created
via <code>createElement</code> of <code>document</code> other than iframe's <code>document</code>.
<a href="https://bugs.webkit.org/show_bug.cgi?id=60031">Bug 60031</a>
</p>
<iframe style="width:400px"></iframe>
</body>
</html>