Bug 832473 - Variables View: empty variable is rendered wrongly if it is added within scope with label, r=msucan

This commit is contained in:
Victor Porof 2013-01-22 20:00:13 +02:00
parent 4d8ae5f148
commit 94d2ea2efc
2 changed files with 65 additions and 34 deletions

View File

@ -70,6 +70,32 @@ function testVariablesView()
testThirdLevelContents();
testIntegrity(arr, obj);
let fooScope = gVariablesView.addScope("foo");
let anonymousVar = fooScope.addVar();
let anonymousScope = gVariablesView.addScope();
let barVar = anonymousScope.addVar("bar");
is(fooScope.header, true,
"A named scope should have a header visible.");
is(fooScope.target.hasAttribute("non-header"), false,
"The non-header attribute should not be applied to scopes with headers.");
is(anonymousScope.header, false,
"An anonymous scope should have a header visible.");
is(anonymousScope.target.hasAttribute("non-header"), true,
"The non-header attribute should not be applied to scopes without headers.");
is(barVar.header, true,
"A named variable should have a header visible.");
is(barVar.target.hasAttribute("non-header"), false,
"The non-header attribute should not be applied to variables with headers.");
is(anonymousVar.header, false,
"An anonymous variable should have a header visible.");
is(anonymousVar.target.hasAttribute("non-header"), true,
"The non-header attribute should not be applied to variables without headers.");
gVariablesView.clearHierarchy();
is (gVariablesView._prevHierarchy.size, 0,
"The previous hierarchy should have been cleared.");
@ -103,18 +129,18 @@ function testHeader() {
gScope.showHeader();
gVariable.showHeader();
is(gScope.header, true,
"The scope title header should now be visible");
is(gVariable.header, true,
"The variable title header should now be visible");
is(gScope.header, false,
"The scope title header should still not be visible");
is(gVariable.header, false,
"The variable title header should still not be visible");
gScope.hideHeader();
gVariable.hideHeader();
is(gScope.header, false,
"The scope title header should now be hidden");
"The scope title header should now still be hidden");
is(gVariable.header, false,
"The variable title header should now be hidden");
"The variable title header should now still be hidden");
}
function testFirstLevelContents() {

View File

@ -698,7 +698,7 @@ Scope.prototype = {
* Shows the scope's title header.
*/
showHeader: function S_showHeader() {
if (this._isHeaderVisible) {
if (this._isHeaderVisible || !this._nameString) {
return;
}
this._target.removeAttribute("non-header");
@ -1386,7 +1386,9 @@ create({ constructor: Variable, proto: Scope.prototype }, {
get setter() this._initialDescriptor.set,
/**
* Sets the specific grip for this variable.
* Sets the specific grip for this variable (applies the text content and
* class name to the value label).
*
* The grip should contain the value or the type & class, as defined in the
* remote debugger protocol. For convenience, undefined and null are
* both considered types.
@ -1401,23 +1403,18 @@ create({ constructor: Variable, proto: Scope.prototype }, {
* - { type: "object", class: "Object" }
*/
_setGrip: function V__setGrip(aGrip) {
// Don't allow displaying grip information if there's no name available.
if (!this._nameString) {
return;
}
if (aGrip === undefined) {
aGrip = { type: "undefined" };
}
if (aGrip === null) {
aGrip = { type: "null" };
}
this._applyGrip(aGrip);
},
/**
* Applies the necessary text content and class name to a value node based
* on a grip.
*
* @param any aGrip
* @see Variable._setGrip
*/
_applyGrip: function V__applyGrip(aGrip) {
let prevGrip = this._valueGrip;
if (prevGrip) {
this._valueLabel.classList.remove(VariablesView.getClass(prevGrip));
@ -1441,11 +1438,16 @@ create({ constructor: Variable, proto: Scope.prototype }, {
_init: function V__init(aName, aDescriptor) {
this._idString = generateId(this._nameString = aName);
this._displayScope(aName, "variable");
this._displayVariable();
this._customizeVariable();
this._prepareTooltip();
this._setAttributes();
this._addEventListeners();
// Don't allow displaying variable information there's no name available.
if (this._nameString) {
this._displayVariable();
this._customizeVariable();
this._prepareTooltip();
this._setAttributes();
this._addEventListeners();
}
this._onInit(this.ownerView._store.size < LAZY_APPEND_BATCH);
},
@ -1530,18 +1532,16 @@ create({ constructor: Variable, proto: Scope.prototype }, {
let document = this.document;
let tooltip = document.createElement("tooltip");
tooltip.id = "tooltip-" + this.id;
tooltip.id = "tooltip-" + this._idString;
let configurableLabel = document.createElement("label");
configurableLabel.setAttribute("value", "configurable");
let enumerableLabel = document.createElement("label");
enumerableLabel.setAttribute("value", "enumerable");
let writableLabel = document.createElement("label");
configurableLabel.setAttribute("value", "configurable");
enumerableLabel.setAttribute("value", "enumerable");
writableLabel.setAttribute("value", "writable");
tooltip.setAttribute("orient", "horizontal")
tooltip.setAttribute("orient", "horizontal");
tooltip.appendChild(configurableLabel);
tooltip.appendChild(enumerableLabel);
tooltip.appendChild(writableLabel);
@ -1847,11 +1847,16 @@ create({ constructor: Property, proto: Variable.prototype }, {
_init: function P__init(aName, aDescriptor) {
this._idString = generateId(this._nameString = aName);
this._displayScope(aName, "property");
this._displayVariable();
this._customizeVariable();
this._prepareTooltip();
this._setAttributes();
this._addEventListeners();
// Don't allow displaying property information there's no name available.
if (this._nameString) {
this._displayVariable();
this._customizeVariable();
this._prepareTooltip();
this._setAttributes();
this._addEventListeners();
}
this._onInit(this.ownerView._store.size < LAZY_APPEND_BATCH);
},