Bug 585043 - Improve Inspector DOM panel unittests, r=dietrich, a=tests

This commit is contained in:
Mihai Sucan 2010-10-13 10:57:48 -03:00
Родитель a386c5150c
Коммит 6f2f896926
1 изменённых файлов: 47 добавлений и 2 удалений

Просмотреть файл

@ -22,6 +22,7 @@
*
* Contributor(s):
* Rob Campbell <rcampbell@mozilla.com>
* Mihai Șucan <mihai.sucan@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -39,6 +40,7 @@
let doc;
let testGen;
let newProperty;
function createDocument()
{
@ -63,15 +65,26 @@ function createDocument()
function nodeGenerator()
{
let body = doc.body;
newProperty = "rand" + Date.now();
body[newProperty] = Math.round(Math.random() * 100);
InspectorUI.inspectNode(body);
yield;
let h1 = doc.querySelector("h1");
newProperty = "rand2" + Date.now();
h1[newProperty] = "test" + Math.random();
InspectorUI.inspectNode(h1);
yield;
let first = doc.getElementById("first");
newProperty = "rand3" + Date.now();
first[newProperty] = null;
InspectorUI.inspectNode(first);
yield;
let closing = doc.getElementById("closing");
newProperty = "bazbaz" + Date.now();
closing[newProperty] = false;
InspectorUI.inspectNode(closing);
yield;
}
@ -86,16 +99,48 @@ function runDOMTests()
testGen.next();
}
function findInDOMPanel(aString)
{
let treeView = InspectorUI.domTreeView;
let row;
for (let i = 0, n = treeView.rowCount; i < n; i++) {
row = treeView.getCellText(i, 0);
if (row && row.indexOf(aString) != -1) {
return true;
}
}
return false;
}
function performTestComparisons(evt)
{
InspectorUI._log("performTestComparisons");
if (evt.target.id != "highlighter-panel")
return true;
ok(InspectorUI.selection, "selection");
let selection = InspectorUI.selection;
ok(selection, "selection");
ok(InspectorUI.isDOMPanelOpen, "DOM panel is open?");
ok(InspectorUI.highlighter.isHighlighting, "panel is highlighting");
ok(InspectorUI.domTreeView.rowCount > 0, "domBox has items");
let value = selection[newProperty];
if (typeof value == "string") {
value = '"' + value + '"';
}
ok(findInDOMPanel(newProperty + ': ' + value),
"domPanel shows the correct value for " + newProperty);
ok(findInDOMPanel('tagName: "' + selection.tagName + '"'),
"domPanel shows the correct tagName");
if (selection.id) {
ok(findInDOMPanel('id: "' + selection.id + '"'),
"domPanel shows the correct id");
}
try {
testGen.next();