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-24 03:20:19 -07:00
|
|
|
content.location = "data:text/html,<div><p></p></div>";
|
2011-08-02 14:08:38 -07:00
|
|
|
|
|
|
|
function setupTest() {
|
|
|
|
node1 = doc.querySelector("div");
|
|
|
|
node2 = doc.querySelector("p");
|
|
|
|
Services.obs.addObserver(runTests, INSPECTOR_NOTIFICATIONS.OPENED, false);
|
|
|
|
InspectorUI.toggleInspectorUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
function runTests() {
|
|
|
|
Services.obs.removeObserver(runTests, INSPECTOR_NOTIFICATIONS.OPENED);
|
2011-09-24 03:20:19 -07:00
|
|
|
testNode1();
|
2011-08-02 14:08:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function testNode1() {
|
2011-09-24 03:20:19 -07:00
|
|
|
let box = InspectorUI.ioBox.createObjectBox(node1);
|
|
|
|
box.click();
|
|
|
|
executeSoon(function() {
|
|
|
|
is(InspectorUI.selection, node1, "selection matches node");
|
|
|
|
is(InspectorUI.highlighter.node, node1, "selection matches node");
|
|
|
|
testNode2();
|
|
|
|
});
|
2011-08-02 14:08:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function testNode2() {
|
2011-09-24 03:20:19 -07:00
|
|
|
let box = InspectorUI.ioBox.createObjectBox(node2);
|
|
|
|
box.click();
|
|
|
|
executeSoon(function() {
|
|
|
|
is(InspectorUI.selection, node2, "selection matches node");
|
|
|
|
is(InspectorUI.highlighter.node, node2, "selection matches node");
|
|
|
|
Services.obs.addObserver(finishUp, INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
|
|
|
InspectorUI.closeInspectorUI();
|
|
|
|
});
|
2011-08-02 14:08:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function finishUp() {
|
|
|
|
Services.obs.removeObserver(finishUp, INSPECTOR_NOTIFICATIONS.CLOSED);
|
|
|
|
doc = node1 = node2 = null;
|
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|