Bug 901733 - Add "--invert" flag to the "dbg blackbox" command; r=fitzgen

This commit is contained in:
Oprea Victor Andrei 2013-08-12 13:58:22 -07:00
parent 158edb6e48
commit 48d351efc5
4 changed files with 48 additions and 2 deletions

View File

@ -465,6 +465,11 @@ gcli.addCommand({
type: "string",
description: lookup("GlobDesc"),
defaultValue: null
},
{
name: "invert",
type: "boolean",
description: lookup("InvertDesc")
}
],
returnType: "dom",
@ -484,8 +489,9 @@ gcli.addCommand({
// Filter the sources down to those that we will need to black box.
function shouldBlackBox(source) {
return globRegExp && globRegExp.test(source.url)
var value = globRegExp && globRegExp.test(source.url)
|| args.source && source.url == args.source;
return args.invert ? !value : value;
}
const toBlackBox = [s.attachment.source

View File

@ -56,6 +56,8 @@ function test() {
.then(testUnBlackBoxSource)
.then(testBlackBoxGlob)
.then(testUnBlackBoxGlob)
.then(testBlackBoxInvert)
.then(testUnBlackBoxInvert)
.then(null, function (error) {
ok(false, "Got an error: " + error.message + "\n" + error.stack);
})
@ -124,6 +126,36 @@ function testUnBlackBoxGlob() {
});
}
function testBlackBoxInvert() {
return cmd("dbg blackbox --invert --glob *blackboxing_t*.js", 3,
[/blackboxing_three\.js/g, /blackboxing_two\.js/g])
.then(function () {
ok(!getBlackBoxCheckbox(BLACKBOXME_URL).checked,
"blackboxme should be black boxed because it doesn't match the glob");
ok(!getBlackBoxCheckbox(BLACKBOXONE_URL).checked,
"blackbox_one should be black boxed because it doesn't match the glob");
ok(!getBlackBoxCheckbox(TEST_URL).checked,
"TEST_URL should be black boxed because it doesn't match the glob");
ok(getBlackBoxCheckbox(BLACKBOXTWO_URL).checked,
"blackbox_two should not be black boxed because it matches the glob");
ok(getBlackBoxCheckbox(BLACKBOXTHREE_URL).checked,
"blackbox_three should not be black boxed because it matches the glob");
});
}
function testUnBlackBoxInvert() {
return cmd("dbg unblackbox --invert --glob *blackboxing_t*.js", 3)
.then(function () {
ok(getBlackBoxCheckbox(BLACKBOXME_URL).checked,
"blackboxme should be un-black boxed because it does not match the glob");
ok(getBlackBoxCheckbox(BLACKBOXONE_URL).checked,
"blackbox_one should be un-black boxed because it does not match the glob");
ok(getBlackBoxCheckbox(TEST_URL).checked,
"TEST_URL should be un-black boxed because it doesn't match the glob");
});
}
function finishUp() {
gTarget = null;
gPanel = null;

View File

@ -12,7 +12,7 @@ let Services = tempScope.Services;
// Disable logging for faster test runs. Set this pref to true if you want to
// debug a test in your try runs.
let gEnableLogging = Services.prefs.getBoolPref("devtools.debugger.log");
Services.prefs.setBoolPref("devtools.debugger.log", false);
Services.prefs.setBoolPref("devtools.debugger.log", true);
Cu.import("resource://gre/modules/devtools/dbg-server.jsm", tempScope);
Cu.import("resource://gre/modules/devtools/dbg-client.jsm", tempScope);

View File

@ -427,6 +427,10 @@ dbgBlackBoxSourceDesc=A specific source to black box
# 'glob' parameter to the 'dbg blackbox' command.
dbgBlackBoxGlobDesc=Black box all sources that match this glob (for example: "*.min.js")
# LOCALIZATION NOTE (dbgBlackBoxInvertDesc) A very short string used to describe the
# 'invert' parameter to the 'dbg blackbox' command.
dbgBlackBoxInvertDesc=Invert matching, so that we black box every source that is not the source provided or does not match the provided glob pattern.
# LOCALIZATION NOTE (dbgBlackBoxEmptyDesc) A very short string used to let the
# user know that no sources were black boxed.
dbgBlackBoxEmptyDesc=(No sources black boxed)
@ -465,6 +469,10 @@ dbgUnBlackBoxNonEmptyDesc=Stopped black boxing the following sources:
# text).
dbgUnBlackBoxErrorDesc=Error stopping black boxing:
# LOCALIZATION NOTE (dbgUnBlackBoxInvertDesc) A very short string used to describe the
# 'invert' parameter to the 'dbg unblackbox' command.
dbgUnBlackBoxInvertDesc=Invert matching, so that we stop black boxing every source that is not the source provided or does not match the provided glob pattern.
# LOCALIZATION NOTE (consolecloseDesc) A very short description of the
# 'console close' command. This string is designed to be shown in a menu
# alongside the command name, which is why it should be as short as possible.