Bug 991376 - The variables inspection popup shouldn't opening when hovering js literals. r=past

This commit is contained in:
Victor Porof 2014-04-02 19:38:07 -04:00
parent 4a6cb4cded
commit f436e48f5f
6 changed files with 55 additions and 12 deletions

View File

@ -931,7 +931,7 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
/** /**
* Called when the add breakpoint key sequence was pressed. * Called when the add breakpoint key sequence was pressed.
*/ */
_onCmdAddBreakpoint: function() { _onCmdAddBreakpoint: function(e) {
let url = DebuggerView.Sources.selectedValue; let url = DebuggerView.Sources.selectedValue;
let line = DebuggerView.editor.getCursor().line + 1; let line = DebuggerView.editor.getCursor().line + 1;
let location = { url: url, line: line }; let location = { url: url, line: line };
@ -1807,6 +1807,12 @@ VariableBubbleView.prototype = {
this._editorContainer.removeEventListener("mouseleave", this._onMouseLeave, false); this._editorContainer.removeEventListener("mouseleave", this._onMouseLeave, false);
}, },
/**
* Specifies whether literals can be (redundantly) inspected in a popup.
* This behavior is deprecated, but still tested in a few places.
*/
_ignoreLiterals: true,
/** /**
* Searches for an identifier underneath the specified position in the * Searches for an identifier underneath the specified position in the
* source editor, and if found, opens a VariablesView inspection popup. * source editor, and if found, opens a VariablesView inspection popup.
@ -1846,7 +1852,8 @@ VariableBubbleView.prototype = {
let identifierInfo = parsedSource.getIdentifierAt({ let identifierInfo = parsedSource.getIdentifierAt({
line: scriptLine + 1, line: scriptLine + 1,
column: scriptColumn, column: scriptColumn,
scriptIndex: scriptInfo.index scriptIndex: scriptInfo.index,
ignoreLiterals: this._ignoreLiterals
}); });
// If the info is null, we're not hovering any identifier. // If the info is null, we're not hovering any identifier.

View File

@ -57,7 +57,7 @@
<command id="globalSearchCommand" <command id="globalSearchCommand"
oncommand="DebuggerView.Filtering._doGlobalSearch()"/> oncommand="DebuggerView.Filtering._doGlobalSearch()"/>
<command id="functionSearchCommand" <command id="functionSearchCommand"
oncommand="DebuggerView.Filtering._doFunctionSearch()"/> oncommand="DepbuggerView.Filtering._doFunctionSearch()"/>
<command id="tokenSearchCommand" <command id="tokenSearchCommand"
oncommand="DebuggerView.Filtering._doTokenSearch()"/> oncommand="DebuggerView.Filtering._doTokenSearch()"/>
<command id="lineSearchCommand" <command id="lineSearchCommand"

View File

@ -278,6 +278,7 @@ support-files =
[browser_dbg_variables-view-popup-12.js] [browser_dbg_variables-view-popup-12.js]
[browser_dbg_variables-view-popup-13.js] [browser_dbg_variables-view-popup-13.js]
[browser_dbg_variables-view-popup-14.js] [browser_dbg_variables-view-popup-14.js]
[browser_dbg_variables-view-popup-15.js]
[browser_dbg_variables-view-reexpand-01.js] [browser_dbg_variables-view-reexpand-01.js]
[browser_dbg_variables-view-reexpand-02.js] [browser_dbg_variables-view-reexpand-02.js]
[browser_dbg_variables-view-webidl.js] [browser_dbg_variables-view-webidl.js]

View File

@ -15,6 +15,8 @@ function test() {
let bubble = win.DebuggerView.VariableBubble; let bubble = win.DebuggerView.VariableBubble;
let tooltip = bubble._tooltip.panel; let tooltip = bubble._tooltip.panel;
bubble._ignoreLiterals = false;
function verifyContents(textContent, className) { function verifyContents(textContent, className) {
is(tooltip.querySelectorAll(".variables-view-container").length, 0, is(tooltip.querySelectorAll(".variables-view-container").length, 0,
"There should be no variables view containers added to the tooltip."); "There should be no variables view containers added to the tooltip.");

View File

@ -0,0 +1,33 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests opening the variable inspection popup directly on literals.
*/
const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
function test() {
Task.spawn(function() {
let [tab, debuggee, panel] = yield initDebugger(TAB_URL);
let win = panel.panelWin;
let bubble = win.DebuggerView.VariableBubble;
let tooltip = bubble._tooltip.panel;
// Allow this generator function to yield first.
executeSoon(() => debuggee.start());
yield waitForSourceAndCaretAndScopes(panel, ".html", 24);
yield openVarPopup(panel, { line: 15, ch: 12 });
ok(true, "The variable inspection popup was shown for the real variable.");
once(tooltip, "popupshown").then(() => {
ok(false, "The variable inspection popup shouldn't have been opened.");
});
reopenVarPopup(panel, { line: 17, ch: 27 });
yield waitForTime(1000);
yield resumeDebuggerThenCloseAndFinish(panel);
});
}

View File

@ -136,8 +136,8 @@ SyntaxTreesPool.prototype = {
/** /**
* @see SyntaxTree.prototype.getIdentifierAt * @see SyntaxTree.prototype.getIdentifierAt
*/ */
getIdentifierAt: function({ line, column, scriptIndex }) { getIdentifierAt: function({ line, column, scriptIndex, ignoreLiterals }) {
return this._call("getIdentifierAt", scriptIndex, line, column)[0]; return this._call("getIdentifierAt", scriptIndex, line, column, ignoreLiterals)[0];
}, },
/** /**
@ -256,11 +256,13 @@ SyntaxTree.prototype = {
* The line in the source. * The line in the source.
* @param number aColumn * @param number aColumn
* The column in the source. * The column in the source.
* @param boolean aIgnoreLiterals
* Specifies if alone literals should be ignored.
* @return object * @return object
* An object containing identifier information as { name, location, * An object containing identifier information as { name, location,
* evalString } properties, or null if nothing is found. * evalString } properties, or null if nothing is found.
*/ */
getIdentifierAt: function(aLine, aColumn) { getIdentifierAt: function(aLine, aColumn, aIgnoreLiterals) {
let info = null; let info = null;
SyntaxTreeVisitor.walk(this.AST, { SyntaxTreeVisitor.walk(this.AST, {
@ -286,7 +288,9 @@ SyntaxTree.prototype = {
* @param Node aNode * @param Node aNode
*/ */
onLiteral: function(aNode) { onLiteral: function(aNode) {
this.onIdentifier(aNode); if (!aIgnoreLiterals) {
this.onIdentifier(aNode);
}
}, },
/** /**
@ -705,11 +709,7 @@ let ParserHelpers = {
case "Identifier": case "Identifier":
return aNode.name; return aNode.name;
case "Literal": case "Literal":
if (typeof aNode.value == "string") { return uneval(aNode.value);
return "\"" + aNode.value + "\"";
} else {
return aNode.value + "";
}
default: default:
return ""; return "";
} }