diff --git a/browser/base/content/inspector.js b/browser/base/content/inspector.js index c432e3cad17..618f2f179ca 100644 --- a/browser/base/content/inspector.js +++ b/browser/base/content/inspector.js @@ -732,15 +732,18 @@ var InspectorUI = { } if (node instanceof GetSVGDocument) { - // then the node is a frame - if (index == 0) { - if (!this.embeddedBrowserParents) - this.embeddedBrowserParents = {}; - let skipChild = node.getSVGDocument().documentElement; - this.embeddedBrowserParents[skipChild] = node; - return skipChild; // the node's SVGElement + let svgDocument = node.getSVGDocument(); + if (svgDocument) { + // then the node is a frame + if (index == 0) { + if (!this.embeddedBrowserParents) + this.embeddedBrowserParents = {}; + let skipChild = svgDocument.documentElement; + this.embeddedBrowserParents[skipChild] = node; + return skipChild; // the node's SVGElement + } + return null; } - return null; } let child = null; diff --git a/browser/base/content/test/inspector/Makefile.in b/browser/base/content/test/inspector/Makefile.in index 156850c8ea7..00905f99673 100644 --- a/browser/base/content/test/inspector/Makefile.in +++ b/browser/base/content/test/inspector/Makefile.in @@ -54,6 +54,7 @@ _BROWSER_FILES = \ browser_inspector_treePanel_output.js \ browser_inspector_treePanel_input.html \ browser_inspector_treePanel_result.html \ + browser_inspector_bug_665880.js \ $(NULL) libs:: $(_BROWSER_FILES) diff --git a/browser/base/content/test/inspector/browser_inspector_bug_665880.js b/browser/base/content/test/inspector/browser_inspector_bug_665880.js new file mode 100644 index 00000000000..29b2f17eae5 --- /dev/null +++ b/browser/base/content/test/inspector/browser_inspector_bug_665880.js @@ -0,0 +1,62 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + + +function test() +{ + waitForExplicitFinish(); + + let doc; + let objectNode; + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function() { + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); + doc = content.document; + waitForFocus(setupObjectInspectionTest, content); + }, true); + + content.location = "data:text/html,

foobar

"; + + function setupObjectInspectionTest() + { + objectNode = doc.querySelector("object"); + ok(objectNode, "we have the object node"); + Services.obs.addObserver(runObjectInspectionTest, + INSPECTOR_NOTIFICATIONS.OPENED, false); + InspectorUI.toggleInspectorUI(); + } + + function runObjectInspectionTest() + { + Services.obs.removeObserver(runObjectInspectionTest, + INSPECTOR_NOTIFICATIONS.OPENED); + + executeSoon(function() { + Services.obs.addObserver(performTestComparison, + INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false); + + InspectorUI.inspectNode(objectNode); + }); + } + + function performTestComparison() + { + Services.obs.removeObserver(performTestComparison, + INSPECTOR_NOTIFICATIONS.HIGHLIGHTING); + + is(InspectorUI.selection, objectNode, "selection matches node"); + + Services.obs.addObserver(finishUp, + INSPECTOR_NOTIFICATIONS.CLOSED, false); + InspectorUI.closeInspectorUI(); + } + + + function finishUp() { + Services.obs.removeObserver(finishUp, INSPECTOR_NOTIFICATIONS.CLOSED); + doc = objectNode = null; + gBrowser.removeCurrentTab(); + finish(); + } +}