Bug 989629: Show class names of DOM elements in variables view. r=past

--HG--
extra : rebase_source : ec90d5954d005f8077180f6ff5f96b4736ad5030
This commit is contained in:
Sami Jaktholm 2014-05-29 10:50:00 +03:00
parent 2ef4dffe43
commit 6ea8da45be
3 changed files with 61 additions and 0 deletions

View File

@ -3698,6 +3698,10 @@ VariablesView.stringifiers.byObjectKind = {
if (attrs.id) {
result += "#" + attrs.id;
}
if (attrs.class) {
result += "." + attrs.class.trim().replace(/\s+/, ".");
}
return result + ">";
}

View File

@ -143,6 +143,7 @@ support-files =
[browser_console_optimized_out_vars.js]
[browser_console_private_browsing.js]
[browser_console_variables_view.js]
[browser_console_variables_view_dom_nodes.js]
[browser_console_variables_view_dont_sort_non_sortable_classes_properties.js]
[browser_console_variables_view_while_debugging.js]
[browser_console_variables_view_while_debugging_and_inspecting.js]

View File

@ -0,0 +1,56 @@
/* -*- js2-basic-offset: 2; indent-tabs-mode: nil; -*- */
/* vim: set 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 ensures DOM nodes are rendered correctly in VariablesView. */
function test() {
const TEST_URI = 'data:text/html;charset=utf-8, \
<html> \
<head> \
<title>Test for DOM nodes in variables view</title> \
</head> \
<body> \
<div></div> \
<div id="testID"></div> \
<div class="single-class"></div> \
<div class="multiple-classes another-class"></div> \
<div class="class-and-id" id="class-and-id"></div> \
<div class="multiple-classes-and-id another-class" \
id="multiple-classes-and-id"></div> \
<div class=" whitespace-start"></div> \
<div class="whitespace-end "></div> \
<div class="multiple spaces"></div> \
</body> \
</html>';
Task.spawn(runner).then(finishTest);
function* runner() {
const {tab} = yield loadTab(TEST_URI);
const hud = yield openConsole(tab);
const jsterm = hud.jsterm;
let deferred = promise.defer();
jsterm.once("variablesview-fetched", (_, aVar) => deferred.resolve(aVar));
jsterm.execute("inspect(document.querySelectorAll('div'))");
let variableScope = yield deferred.promise;
ok(variableScope, "Variables view opened");
yield findVariableViewProperties(variableScope, [
{ name: "0", value: "<div>"},
{ name: "1", value: "<div#testID>"},
{ name: "2", value: "<div.single-class>"},
{ name: "3", value: "<div.multiple-classes.another-class>"},
{ name: "4", value: "<div#class-and-id.class-and-id>"},
{ name: "5", value: "<div#multiple-classes-and-id.multiple-classes-and-id.another-class>"},
{ name: "6", value: "<div.whitespace-start>"},
{ name: "7", value: "<div.whitespace-end>"},
{ name: "8", value: "<div.multiple.spaces>"},
], { webconsole: hud});
}
}