Bug 771481 - 'No scripts.' should be displayed in the dropdown when there are no scripts matching the search string; r=past

This commit is contained in:
Victor Porof
2012-07-18 16:13:15 +03:00
parent 181fe2f4e7
commit 10c0e4bcfa
9 changed files with 71 additions and 5 deletions

View File

@@ -149,6 +149,8 @@ ScriptsView.prototype = {
*/
empty: function DVS_empty() {
this._scripts.selectedIndex = -1;
this._scripts.setAttribute("label", L10N.getStr("noScriptsText"));
this._scripts.removeAttribute("tooltiptext");
while (this._scripts.firstChild) {
this._scripts.removeChild(this._scripts.firstChild);
@@ -425,9 +427,8 @@ ScriptsView.prototype = {
return;
}
let script = selectedItem.getUserData("sourceScript");
this._preferredScript = script;
DebuggerController.SourceScripts.showScript(script);
this._preferredScript = selectedItem;
DebuggerController.SourceScripts.showScript(selectedItem.getUserData("sourceScript"));
},
/**
@@ -438,8 +439,15 @@ ScriptsView.prototype = {
let scripts = this._scripts;
let [file, line, token] = this._getSearchboxInfo();
// If the webpage has no scripts, searching is redundant.
if (!scripts.itemCount) {
return;
}
// Presume we won't find anything.
scripts.selectedItem = this._preferredScript;
scripts.setAttribute("label", this._preferredScript.label);
scripts.setAttribute("tooltiptext", this._preferredScript.value);
// If we're not searching for a file anymore, unhide all the scripts.
if (!file) {
@@ -447,7 +455,9 @@ ScriptsView.prototype = {
scripts.getItemAtIndex(i).hidden = false;
}
} else {
for (let i = 0, l = scripts.itemCount, found = false; i < l; i++) {
let found = false;
for (let i = 0, l = scripts.itemCount; i < l; i++) {
let item = scripts.getItemAtIndex(i);
let target = item.label.toLowerCase();
@@ -458,6 +468,8 @@ ScriptsView.prototype = {
if (!found) {
found = true;
scripts.selectedItem = item;
scripts.setAttribute("label", item.label);
scripts.setAttribute("tooltiptext", item.value);
}
}
// Hide what doesn't match our search.
@@ -465,6 +477,10 @@ ScriptsView.prototype = {
item.hidden = true;
}
}
if (!found) {
scripts.setAttribute("label", L10N.getStr("noMatchingScriptsText"));
scripts.removeAttribute("tooltiptext");
}
}
if (line > -1) {
editor.setCaretPosition(line - 1);

View File

@@ -64,6 +64,7 @@
tabindex="0"/>
</hbox>
<menulist id="scripts" class="devtools-menulist"
sizetopopup="always"
label="&debuggerUI.emptyScriptText;"/>
<textbox id="scripts-search" type="search"
class="devtools-searchinput"

View File

@@ -67,6 +67,13 @@ function testLocationChange()
is(gDebugger.editor.getText().length, 0,
"The source editor not have any text displayed.");
let menulist = gDebugger.DebuggerView.Scripts._scripts;
let noScripts = gDebugger.L10N.getStr("noScriptsText");
is(menulist.getAttribute("label"), noScripts,
"The menulist should display a notice that there are no scripts availalble.");
is(menulist.getAttribute("tooltiptext"), "",
"The menulist shouldn't have any tooltip text attributed when there are no scripts available.");
closeDebuggerAndFinish();
});
});

View File

@@ -124,10 +124,41 @@ function finalCheck(i, string, token) {
}
clear();
ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (4)");
executeSoon(function() {
let noMatchingScripts = gDebugger.L10N.getStr("noMatchingScriptsText");
is(gScripts.visibleItemsCount, 2,
"Not all the scripts are shown after the searchbox was emptied.");
is(gMenulist.selectedIndex, 1,
"The menulist should have retained its selected index after the searchbox was emptied.");
write("BOGUS");
ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (5)");
is(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should display a notice that no scripts match the searched token.");
is(gScripts.visibleItemsCount, 0,
"No scripts should be displayed in the menulist after a bogus search.");
is(gMenulist.selectedIndex, 1,
"The menulist should retain its selected index after a bogus search.");
clear();
ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (6)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice after the searchbox was emptied.");
is(gScripts.visibleItemsCount, 2,
"Not all the scripts are shown after the searchbox was emptied.");
is(gMenulist.selectedIndex, 1,
"The menulist should have retained its selected index after the searchbox was emptied of a bogus search.");
closeDebuggerAndFinish();
});

View File

@@ -67,4 +67,4 @@
<!-- LOCALIZATION NOTE (emptyScriptText): The text to display in the menulist when
- there are no scripts. -->
<!ENTITY debuggerUI.emptyScriptText "No scripts.">
<!ENTITY debuggerUI.emptyScriptText "No scripts">

View File

@@ -59,6 +59,14 @@ emptyStackText=No stacks to display.
# breakpoints list when there are no breakpoints to display.
emptyBreakpointsText=No breakpoints to display.
# LOCALIZATION NOTE (noScriptsText): The text to display in the menulist when
# there are no scripts.
noScriptsText=No scripts
# LOCALIZATION NOTE (noMatchingScriptsText): The text to display in the
# menulist when there are no matching scripts after filtering.
noMatchingScriptsText=No matching scripts
# LOCALIZATION NOTE (breakpointMenuItem): The text for all the elements that
# are displayed in the breakpoints menu item popup.
breakpointMenuItem.enableSelf=Enable breakpoint

View File

@@ -18,6 +18,7 @@
#scripts {
max-width: 350px;
min-width: 150px;
}
/**

View File

@@ -20,6 +20,7 @@
#scripts {
max-width: 350px;
min-width: 150px;
}
/**

View File

@@ -18,6 +18,7 @@
#scripts {
max-width: 350px;
min-width: 150px;
}
/**