Bug 1035198 - VariablesView: handle instances of nsIDOMNode.DOCUMENT_NODE without URLs properly. r=robcee
authorSami Jaktholm <sjakthol@outlook.com>
Sat, 19 Jul 2014 00:17:00 +0200
changeset 217035 1006faf779585133ee80643e634387e2783dbb15
parent 217034 7c3b1a192e647687618d7cb93cbdaa78c0f0edf8
child 217036 2f82f5227f21b975598a4d5f7e6be9c608fd11c1
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrobcee
bugs1035198
milestone34.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 1035198 - VariablesView: handle instances of nsIDOMNode.DOCUMENT_NODE without URLs properly. r=robcee
browser/devtools/shared/widgets/VariablesView.jsm
browser/devtools/webconsole/test/browser.ini
browser/devtools/webconsole/test/browser_webconsole_inspect-parsed-documents.js
browser/devtools/webconsole/test/head.js
--- a/browser/devtools/shared/widgets/VariablesView.jsm
+++ b/browser/devtools/shared/widgets/VariablesView.jsm
@@ -3638,19 +3638,24 @@ VariablesView.stringifiers.byObjectKind 
     return result + " {" + props.join(", ") + "}";
   }, // DOMEvent
 
   DOMNode: function(aGrip, {concise}) {
     let {preview} = aGrip;
 
     switch (preview.nodeType) {
       case Ci.nsIDOMNode.DOCUMENT_NODE: {
-        let location = WebConsoleUtils.abbreviateSourceURL(preview.location,
-                                                           { onlyCropQuery: !concise });
-        return aGrip.class + " \u2192 " + location;
+        let result = aGrip.class;
+        if (preview.location) {
+          let location = WebConsoleUtils.abbreviateSourceURL(preview.location,
+                                                            { onlyCropQuery: !concise });
+          result += " \u2192 " + location;
+        }
+
+        return result;
       }
 
       case Ci.nsIDOMNode.ATTRIBUTE_NODE: {
         let value = VariablesView.getString(preview.value, { noStringQuotes: true });
         return preview.nodeName + '="' + escapeHTML(value) + '"';
       }
 
       case Ci.nsIDOMNode.TEXT_NODE:
--- a/browser/devtools/webconsole/test/browser.ini
+++ b/browser/devtools/webconsole/test/browser.ini
@@ -245,16 +245,17 @@ run-if = os == "mac"
 [browser_webconsole_console_extras.js]
 [browser_webconsole_console_logging_api.js]
 [browser_webconsole_count.js]
 [browser_webconsole_dont_navigate_on_doubleclick.js]
 [browser_webconsole_execution_scope.js]
 [browser_webconsole_for_of.js]
 [browser_webconsole_history.js]
 [browser_webconsole_input_field_focus_on_panel_select.js]
+[browser_webconsole_inspect-parsed-documents.js]
 [browser_webconsole_js_input_expansion.js]
 [browser_webconsole_jsterm.js]
 [browser_webconsole_live_filtering_of_message_types.js]
 [browser_webconsole_live_filtering_on_search_strings.js]
 [browser_webconsole_message_node_id.js]
 [browser_webconsole_netlogging.js]
 [browser_webconsole_network_panel.js]
 [browser_webconsole_notifications.js]
new file mode 100644
--- /dev/null
+++ b/browser/devtools/webconsole/test/browser_webconsole_inspect-parsed-documents.js
@@ -0,0 +1,33 @@
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+// Test that dynamically created (HTML|XML|SVG)Documents can be inspected by
+// clicking on the object in console (bug 1035198).
+
+const TEST_CASES = [
+  {
+    input: '(new DOMParser()).parseFromString("<a />", "text/html")',
+    output: "HTMLDocument",
+    inspectable: true,
+  },
+  {
+    input: '(new DOMParser()).parseFromString("<a />", "application/xml")',
+    output: "XMLDocument",
+    inspectable: true,
+  },
+  {
+    input: '(new DOMParser()).parseFromString("<svg></svg>", "image/svg+xml")',
+    output: "SVGDocument",
+    inspectable: true,
+  },
+];
+
+const TEST_URI = "data:text/html;charset=utf8," +
+  "browser_webconsole_inspect-parsed-documents.js";
+let test = asyncTest(function* () {
+    let {tab} = yield loadTab(TEST_URI);
+    let hud = yield openConsole(tab);
+    yield checkOutputForInputs(hud, TEST_CASES);
+});
--- a/browser/devtools/webconsole/test/head.js
+++ b/browser/devtools/webconsole/test/head.js
@@ -39,16 +39,23 @@ const GROUP_INDENT = 12;
 const WEBCONSOLE_STRINGS_URI = "chrome://browser/locale/devtools/webconsole.properties";
 let WCU_l10n = new WebConsoleUtils.l10n(WEBCONSOLE_STRINGS_URI);
 
 gDevTools.testing = true;
 SimpleTest.registerCleanupFunction(() => {
   gDevTools.testing = false;
 });
 
+/**
+ * Define an async test based on a generator function
+ */
+function asyncTest(generator) {
+  return () => Task.spawn(generator).then(null, ok.bind(null, false)).then(finishTest);
+}
+
 function log(aMsg)
 {
   dump("*** WebConsoleTest: " + aMsg + "\n");
 }
 
 function pprint(aObj)
 {
   for (let prop in aObj) {