2012-02-07 09:22:30 -08:00
|
|
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
|
|
|
/*
|
|
|
|
* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
|
|
|
var gPane = null;
|
|
|
|
var gTab = null;
|
|
|
|
var gDebuggee = null;
|
|
|
|
var gDebugger = null;
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
|
|
|
|
gTab = aTab;
|
|
|
|
gDebuggee = aDebuggee;
|
|
|
|
gPane = aPane;
|
2012-05-03 10:36:40 -07:00
|
|
|
gDebugger = gPane.contentWindow;
|
2012-02-07 09:22:30 -08:00
|
|
|
|
|
|
|
testSimpleCall();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function testSimpleCall() {
|
2012-04-08 22:15:47 -07:00
|
|
|
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
2012-02-07 09:22:30 -08:00
|
|
|
Services.tm.currentThread.dispatch({ run: function() {
|
|
|
|
|
2012-05-29 02:08:20 -07:00
|
|
|
testScriptLabelShortening();
|
2012-02-07 09:22:30 -08:00
|
|
|
}}, 0);
|
|
|
|
});
|
|
|
|
|
|
|
|
gDebuggee.simpleCall();
|
|
|
|
}
|
|
|
|
|
2012-05-29 02:08:20 -07:00
|
|
|
function testScriptLabelShortening() {
|
2012-04-08 22:15:47 -07:00
|
|
|
gDebugger.DebuggerController.activeThread.resume(function() {
|
2012-02-29 09:20:02 -08:00
|
|
|
let vs = gDebugger.DebuggerView.Scripts;
|
2012-04-08 22:15:47 -07:00
|
|
|
let ss = gDebugger.DebuggerController.SourceScripts;
|
2012-04-17 11:16:57 -07:00
|
|
|
vs.empty();
|
|
|
|
vs._scripts.removeEventListener("select", vs._onScriptsChange, false);
|
2012-02-29 09:20:02 -08:00
|
|
|
|
2012-06-04 05:35:24 -07:00
|
|
|
is(ss.trimUrlQuery("a/b/c.d?test=1&random=4#reference"), "a/b/c.d",
|
2012-02-29 09:20:02 -08:00
|
|
|
"Trimming the url query isn't done properly.");
|
|
|
|
|
2012-08-01 13:25:46 -07:00
|
|
|
let ellipsis = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString);
|
|
|
|
let nanana = new Array(20).join(NaN);
|
|
|
|
|
2012-08-18 02:29:47 -07:00
|
|
|
let superLargeLabel = new Array(100).join("Beer can in Jamaican sounds like Bacon!");
|
|
|
|
let trimmedLargeLabel = ss.trimUrlLength(superLargeLabel, 1234);
|
|
|
|
is(trimmedLargeLabel.length, 1235,
|
|
|
|
"Trimming large labels isn't done properly.");
|
|
|
|
ok(trimmedLargeLabel.endsWith(ellipsis),
|
|
|
|
"Trimming large labels should add an ellipsis at the end.");
|
|
|
|
|
2012-02-29 09:20:02 -08:00
|
|
|
let urls = [
|
2012-06-04 05:35:24 -07:00
|
|
|
{ href: "http://some.address.com/random/", leaf: "subrandom/" },
|
|
|
|
{ href: "http://some.address.com/random/", leaf: "suprandom/?a=1" },
|
|
|
|
{ href: "http://some.address.com/random/", leaf: "?a=1" },
|
|
|
|
{ href: "https://another.address.org/random/subrandom/", leaf: "page.html" },
|
|
|
|
|
|
|
|
{ href: "ftp://interesting.address.org/random/", leaf: "script.js" },
|
|
|
|
{ href: "ftp://interesting.address.com/random/", leaf: "script.js" },
|
|
|
|
{ href: "ftp://interesting.address.com/random/", leaf: "x/script.js" },
|
|
|
|
{ href: "ftp://interesting.address.com/random/", leaf: "x/y/script.js?a=1" },
|
|
|
|
{ href: "ftp://interesting.address.com/random/x/", leaf: "y/script.js?a=1&b=2", dupe: true },
|
|
|
|
{ href: "ftp://interesting.address.com/random/x/y/", leaf: "script.js?a=1&b=2&c=3", dupe: true },
|
|
|
|
{ href: "ftp://interesting.address.com/random/", leaf: "x/y/script.js?a=2", dupe: true },
|
|
|
|
{ href: "ftp://interesting.address.com/random/x/", leaf: "y/script.js?a=2&b=3", dupe: true },
|
|
|
|
{ href: "ftp://interesting.address.com/random/x/y/", leaf: "script.js?a=2&b=3&c=4", dupe: true },
|
|
|
|
|
|
|
|
{ href: "file://random/", leaf: "script_t1.js&a=1&b=2&c=3" },
|
|
|
|
{ href: "file://random/", leaf: "script_t2_1.js#id" },
|
|
|
|
{ href: "file://random/", leaf: "script_t2_2.js?a" },
|
|
|
|
{ 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" },
|
2012-08-01 13:25:46 -07:00
|
|
|
{ href: "resource://random/", leaf: "script_t3_3.js&a=1&b=2#id" },
|
|
|
|
|
|
|
|
{ href: nanana, leaf: "Batman!" + "{trim me, now and forevermore}" }
|
2012-02-29 09:20:02 -08:00
|
|
|
];
|
|
|
|
|
|
|
|
urls.forEach(function(url) {
|
|
|
|
executeSoon(function() {
|
|
|
|
let loc = url.href + url.leaf;
|
2012-07-14 23:40:37 -07:00
|
|
|
vs.addScript(ss.getScriptLabel(loc, url.href), { url: loc }, true);
|
2012-02-29 09:20:02 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
executeSoon(function() {
|
2012-06-04 05:35:24 -07:00
|
|
|
info("Script labels:");
|
|
|
|
info(vs.scriptLabels.toSource());
|
|
|
|
|
|
|
|
info("Script locations:");
|
|
|
|
info(vs.scriptLocations.toSource());
|
|
|
|
|
2012-05-30 03:43:37 -07:00
|
|
|
urls.forEach(function(url) {
|
|
|
|
let loc = url.href + url.leaf;
|
2012-06-04 05:35:24 -07:00
|
|
|
if (url.dupe) {
|
|
|
|
ok(!vs.contains(loc), "Shouldn't contain script: " + loc);
|
|
|
|
} else {
|
|
|
|
ok(vs.contains(loc), "Should contain script: " + loc);
|
|
|
|
}
|
2012-05-30 03:43:37 -07:00
|
|
|
});
|
2012-02-29 09:20:02 -08:00
|
|
|
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("random/subrandom/"),
|
2012-02-29 09:20:02 -08:00
|
|
|
"Script (0) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("random/suprandom/?a=1"),
|
2012-02-29 09:20:02 -08:00
|
|
|
"Script (1) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("random/?a=1"),
|
2012-02-29 09:20:02 -08:00
|
|
|
"Script (2) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("page.html"),
|
2012-02-29 09:20:02 -08:00
|
|
|
"Script (3) label is incorrect.");
|
2012-06-04 05:35:24 -07:00
|
|
|
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("script.js"),
|
2012-02-29 09:20:02 -08:00
|
|
|
"Script (4) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("random/script.js"),
|
2012-02-29 09:20:02 -08:00
|
|
|
"Script (5) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("random/x/script.js"),
|
2012-05-30 03:43:37 -07:00
|
|
|
"Script (6) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("script.js?a=1"),
|
2012-05-30 03:43:37 -07:00
|
|
|
"Script (7) label is incorrect.");
|
2012-06-04 05:35:24 -07:00
|
|
|
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("script_t1.js"),
|
2012-05-30 03:43:37 -07:00
|
|
|
"Script (8) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("script_t2_1.js"),
|
2012-06-04 05:35:24 -07:00
|
|
|
"Script (9) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("script_t2_2.js"),
|
2012-06-04 05:35:24 -07:00
|
|
|
"Script (10) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("script_t2_3.js"),
|
2012-06-04 05:35:24 -07:00
|
|
|
"Script (11) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("script_t3_1.js"),
|
2012-06-04 05:35:24 -07:00
|
|
|
"Script (12) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("script_t3_2.js"),
|
2012-06-04 05:35:24 -07:00
|
|
|
"Script (13) label is incorrect.");
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel("script_t3_3.js"),
|
2012-06-04 05:35:24 -07:00
|
|
|
"Script (14) label is incorrect.");
|
2012-02-29 09:20:02 -08:00
|
|
|
|
2012-08-18 02:29:47 -07:00
|
|
|
ok(vs.containsLabel(nanana + "Batman!" + ellipsis),
|
2012-08-01 13:25:46 -07:00
|
|
|
"Script (15) label is incorrect.");
|
|
|
|
|
2012-06-04 05:35:24 -07:00
|
|
|
is(vs._scripts.itemCount, urls.filter(function(url) !url.dupe).length,
|
2012-05-30 03:43:37 -07:00
|
|
|
"Didn't get the correct number of scripts in the list.");
|
2012-02-29 09:20:02 -08:00
|
|
|
|
2012-08-18 02:29:47 -07:00
|
|
|
is(vs.getScriptByLocation("http://some.address.com/random/subrandom/").label, "random/subrandom/",
|
|
|
|
"Scripts.getScriptByLocation isn't functioning properly (0).");
|
|
|
|
is(vs.getScriptByLocation("http://some.address.com/random/suprandom/?a=1").label, "random/suprandom/?a=1",
|
|
|
|
"Scripts.getScriptByLocation isn't functioning properly (1).");
|
|
|
|
|
|
|
|
is(vs.getScriptByLabel("random/subrandom/").value, "http://some.address.com/random/subrandom/",
|
|
|
|
"Scripts.getScriptByLabel isn't functioning properly (0).");
|
|
|
|
is(vs.getScriptByLabel("random/suprandom/?a=1").value, "http://some.address.com/random/suprandom/?a=1",
|
|
|
|
"Scripts.getScriptByLabel isn't functioning properly (1).");
|
|
|
|
|
|
|
|
|
2012-05-31 03:01:13 -07:00
|
|
|
closeDebuggerAndFinish();
|
2012-02-29 09:20:02 -08:00
|
|
|
});
|
2012-02-07 09:22:30 -08:00
|
|
|
});
|
|
|
|
}
|
2012-03-06 00:22:17 -08:00
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
removeTab(gTab);
|
|
|
|
gPane = null;
|
|
|
|
gTab = null;
|
|
|
|
gDebuggee = null;
|
|
|
|
gDebugger = null;
|
|
|
|
});
|