Bug 746221 - Pull properties for comparison off the prototype to avoid mismatches with expandos. r=past a=test-only
authorBobby Holley <bobbyholley@gmail.com>
Wed, 18 Apr 2012 10:09:07 +0200
changeset 91906 c209b10216fb5add1f06bd37ceca5770cda30cd1
parent 91905 17d247638c4b277a94d64ffc00cd8659538deb4d
child 91907 81c31a6906b6307f1dd6ccf000e550c9160f30cf
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerspast, test-only
bugs746221
milestone14.0a1
Bug 746221 - Pull properties for comparison off the prototype to avoid mismatches with expandos. r=past a=test-only
browser/devtools/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js
@@ -65,22 +65,27 @@ function autocompletePopupHidden()
   ok(!popup.isOpen, "popup is not open");
   let inputStr = "document.b";
   jsterm.setInputValue(inputStr);
   EventUtils.synthesizeKey("o", {});
   let testStr = inputStr.replace(/./g, " ") + " ";
   is(completeNode.value, testStr + "dy", "completeNode is empty");
   jsterm.setInputValue("");
 
-  // Check the property panel as well.
+  // Check the property panel as well. It's a bit gross to parse the properties
+  // out of the treeView cell text, but nsITreeView doesn't give us a good
+  // structured way to get at the data. :-(
   let propPanel = jsterm.openPropertyPanel("Test", content.document);
-  let docProps = 0;
-  for (let prop in content.document) {
-    docProps++;
-  }
-  is (propPanel.treeView.rowCount, docProps, "all document properties shown in propertyPanel");
+  let propPanelProps = [];
+  for (let idx = 0; idx < propPanel.treeView.rowCount; ++idx)
+    propPanelProps.push(propPanel.treeView.getCellText(idx, null).split(':')[0]);
+  // NB: We pull the properties off the prototype, rather than off object itself,
+  // so that expandos like |constructor|, which the propPanel can't see, are not
+  // included.
+  for (let prop in Object.getPrototypeOf(content.document))
+    ok(propPanelProps.indexOf(prop) != -1, "Property |" + prop + "| should be reflected in propertyPanel");
 
   let treeRows = propPanel.treeView._rows;
   is (treeRows[30].display, "body: Object",  "found document.body");
   propPanel.destroy();
   executeSoon(finishTest);
 }