2011-08-02 14:08:38 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
let doc;
|
|
|
|
let node1;
|
|
|
|
let node2;
|
|
|
|
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.selectedBrowser.addEventListener("load", function onload() {
|
|
|
|
gBrowser.selectedBrowser.removeEventListener("load", onload, true);
|
|
|
|
doc = content.document;
|
|
|
|
waitForFocus(setupTest, content);
|
|
|
|
}, true);
|
|
|
|
|
2011-09-26 09:59:23 -07:00
|
|
|
content.location = 'data:text/html,<div style="width: 200px; height: 200px"><p></p></div>';
|
2011-08-02 14:08:38 -07:00
|
|
|
|
|
|
|
function setupTest() {
|
|
|
|
node1 = doc.querySelector("div");
|
|
|
|
node2 = doc.querySelector("p");
|
2011-09-26 10:11:22 -07:00
|
|
|
Services.obs.addObserver(runTests, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
2011-08-02 14:08:38 -07:00
|
|
|
InspectorUI.toggleInspectorUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
function runTests() {
|
2011-09-26 10:11:22 -07:00
|
|
|
Services.obs.removeObserver(runTests, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
|
|
|
Services.obs.addObserver(testNode1, InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
2011-09-26 09:59:23 -07:00
|
|
|
InspectorUI.select(node1, true, true, true);
|
|
|
|
InspectorUI.openTreePanel();
|
2011-08-02 14:08:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function testNode1() {
|
2011-09-26 10:11:22 -07:00
|
|
|
Services.obs.removeObserver(testNode1, InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
2011-09-26 09:59:23 -07:00
|
|
|
is(InspectorUI.selection, node1, "selection matches node");
|
2011-12-06 09:23:20 -08:00
|
|
|
is(getHighlitNode(), node1, "selection matches node");
|
2011-09-26 09:59:23 -07:00
|
|
|
testNode2();
|
2011-08-02 14:08:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function testNode2() {
|
2011-12-06 09:23:20 -08:00
|
|
|
InspectorUI.highlighter.addListener("nodeselected", testHighlightingNode2);
|
2011-09-26 09:59:23 -07:00
|
|
|
InspectorUI.treePanelSelect("node2");
|
|
|
|
}
|
|
|
|
|
|
|
|
function testHighlightingNode2() {
|
2011-12-06 09:23:20 -08:00
|
|
|
InspectorUI.highlighter.removeListener("nodeselected", testHighlightingNode2);
|
2011-09-26 09:59:23 -07:00
|
|
|
is(InspectorUI.selection, node2, "selection matches node");
|
2011-12-06 09:23:20 -08:00
|
|
|
is(getHighlitNode(), node2, "selection matches node");
|
2011-09-26 10:11:22 -07:00
|
|
|
Services.obs.addObserver(finishUp, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
2011-09-26 09:59:23 -07:00
|
|
|
InspectorUI.closeInspectorUI();
|
2011-08-02 14:08:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function finishUp() {
|
2011-09-26 10:11:22 -07:00
|
|
|
Services.obs.removeObserver(finishUp, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED);
|
2011-08-02 14:08:38 -07:00
|
|
|
doc = node1 = node2 = null;
|
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|