Bug 891357 - iframes don't appear in breadcrumbs. r=robcee
authorDave Camp <dcamp@mozilla.com>
Tue, 23 Jul 2013 14:42:12 -0700
changeset 152074 fb7d20306b6777ba8159d1d570f447d509373e7b
parent 152073 2da93943c857a73547aa846d2fca64a5fce791aa
child 152075 6f7b49cd25124fa1100d0d9c18dece4c3d2c16d7
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrobcee
bugs891357
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 891357 - iframes don't appear in breadcrumbs. r=robcee
browser/devtools/inspector/breadcrumbs.js
browser/devtools/inspector/test/browser_inspector_iframeTest.js
--- a/browser/devtools/inspector/breadcrumbs.js
+++ b/browser/devtools/inspector/breadcrumbs.js
@@ -479,21 +479,23 @@ HTMLBreadcrumbs.prototype = {
       let fragment = this.chromeDoc.createDocumentFragment();
       let toAppend = aNode;
       let lastButtonInserted = null;
       let originalLength = this.nodeHierarchy.length;
       let stopNode = null;
       if (originalLength > 0) {
         stopNode = this.nodeHierarchy[originalLength - 1].node;
       }
-      while (toAppend && toAppend.tagName && toAppend != stopNode) {
-        let button = this.buildButton(toAppend);
-        fragment.insertBefore(button, lastButtonInserted);
-        lastButtonInserted = button;
-        this.nodeHierarchy.splice(originalLength, 0, {node: toAppend, button: button});
+      while (toAppend && toAppend != stopNode) {
+        if (toAppend.tagName) {
+          let button = this.buildButton(toAppend);
+          fragment.insertBefore(button, lastButtonInserted);
+          lastButtonInserted = button;
+          this.nodeHierarchy.splice(originalLength, 0, {node: toAppend, button: button});
+        }
         toAppend = toAppend.parentNode();
       }
       this.container.appendChild(fragment, this.container.firstChild);
   },
 
   /**
    * Get a child of a node that can be displayed in the breadcrumbs
    * and that is probably visible. See LOW_PRIORITY_ELEMENTS.
--- a/browser/devtools/inspector/test/browser_inspector_iframeTest.js
+++ b/browser/devtools/inspector/test/browser_inspector_iframeTest.js
@@ -69,17 +69,38 @@ function performTestComparisons1()
 
 function performTestComparisons2()
 {
   let i = getActiveInspector();
 
   is(i.selection.node, div2, "selection matches div2 node");
   is(getHighlitNode(), div2, "highlighter matches selection");
 
-  finish();
+  selectRoot();
+}
+
+function selectRoot()
+{
+  // Select the root document element to clear the breadcrumbs.
+  let i = getActiveInspector();
+  i.selection.setNode(doc.documentElement);
+  i.once("inspector-updated", selectIframe);
+}
+
+function selectIframe()
+{
+  // Directly select an element in an iframe (without navigating to it
+  // with mousemoves).
+  let i = getActiveInspector();
+  i.selection.setNode(div2);
+  i.once("inspector-updated", () => {
+    let breadcrumbs = i.breadcrumbs;
+    is(breadcrumbs.nodeHierarchy.length, 9, "Should have 9 items");
+    finish();
+  });
 }
 
 function test() {
   waitForExplicitFinish();
 
   gBrowser.selectedTab = gBrowser.addTab();
   gBrowser.selectedBrowser.addEventListener("load", function() {
     gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);