Bug 777093 - Long script urls still confuse the debugger menulist, r=rcampbell

This commit is contained in:
Victor Porof 2012-08-01 23:25:46 +03:00
Родитель 9546b4fd36
Коммит 53d3e8120a
5 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -11,6 +11,7 @@ const Cu = Components.utils;
const FRAME_STEP_CACHE_DURATION = 100; // ms
const DBG_STRINGS_URI = "chrome://browser/locale/devtools/debugger.properties";
const SCRIPTS_URL_MAX_LENGTH = 64; // chars
const SYNTAX_HIGHLIGHT_MAX_FILE_SIZE = 1048576; // 1 MB in bytes
Cu.import("resource:///modules/source-editor.jsm");
@ -1088,7 +1089,12 @@ SourceScripts.prototype = {
* The simplified label.
*/
getScriptLabel: function SS_getScriptLabel(aUrl, aHref) {
return this._labelsCache[aUrl] || (this._labelsCache[aUrl] = this._trimUrl(aUrl));
let label = this._trimUrl(aUrl);
if (label.length > SCRIPTS_URL_MAX_LENGTH) {
let ellipsis = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString);
label = label.substring(0, SCRIPTS_URL_MAX_LENGTH) + ellipsis.data;
}
return this._labelsCache[aUrl] || (this._labelsCache[aUrl] = label);
},
/**

Просмотреть файл

@ -40,6 +40,9 @@ function testScriptLabelShortening() {
is(ss.trimUrlQuery("a/b/c.d?test=1&random=4#reference"), "a/b/c.d",
"Trimming the url query isn't done properly.");
let ellipsis = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString);
let nanana = new Array(20).join(NaN);
let urls = [
{ href: "http://some.address.com/random/", leaf: "subrandom/" },
{ href: "http://some.address.com/random/", leaf: "suprandom/?a=1" },
@ -62,7 +65,9 @@ function testScriptLabelShortening() {
{ href: "file://random/", leaf: "script_t2_3.js&b" },
{ href: "resource://random/", leaf: "script_t3_1.js#id?a=1&b=2" },
{ href: "resource://random/", leaf: "script_t3_2.js?a=1&b=2#id" },
{ href: "resource://random/", leaf: "script_t3_3.js&a=1&b=2#id" }
{ href: "resource://random/", leaf: "script_t3_3.js&a=1&b=2#id" },
{ href: nanana, leaf: "Batman!" + "{trim me, now and forevermore}" }
];
urls.forEach(function(url) {
@ -121,6 +126,9 @@ function testScriptLabelShortening() {
ok(gDebugger.DebuggerView.Scripts.containsLabel("script_t3_3.js"),
"Script (14) label is incorrect.");
ok(gDebugger.DebuggerView.Scripts.containsLabel(nanana + "Batman!" + ellipsis),
"Script (15) label is incorrect.");
is(vs._scripts.itemCount, urls.filter(function(url) !url.dupe).length,
"Didn't get the correct number of scripts in the list.");

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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