diff --git a/browser/base/content/test/browser_inspector_domPanel.js b/browser/base/content/test/browser_inspector_domPanel.js index e2e3eb26be8..4d3f80fcd7c 100644 --- a/browser/base/content/test/browser_inspector_domPanel.js +++ b/browser/base/content/test/browser_inspector_domPanel.js @@ -22,6 +22,7 @@ * * Contributor(s): * Rob Campbell + * Mihai Șucan * * 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();