зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 48cfe823a5da
This commit is contained in:
Родитель
83dcc5791e
Коммит
7ab6608ebf
|
@ -28,82 +28,79 @@ gcli.addCommand({
|
||||||
description: gcli.lookup('jsbUrlDesc')
|
description: gcli.lookup('jsbUrlDesc')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
group: gcli.lookup("jsbOptionsDesc"),
|
name: 'indentSize',
|
||||||
params: [
|
type: 'number',
|
||||||
{
|
description: gcli.lookup('jsbIndentSizeDesc'),
|
||||||
name: 'indentSize',
|
manual: gcli.lookup('jsbIndentSizeManual'),
|
||||||
type: 'number',
|
defaultValue: 2
|
||||||
description: gcli.lookup('jsbIndentSizeDesc'),
|
},
|
||||||
manual: gcli.lookup('jsbIndentSizeManual'),
|
{
|
||||||
defaultValue: 2
|
name: 'indentChar',
|
||||||
},
|
type: {
|
||||||
{
|
name: 'selection',
|
||||||
name: 'indentChar',
|
lookup: [
|
||||||
type: {
|
{ name: "space", value: " " },
|
||||||
name: 'selection',
|
{ name: "tab", value: "\t" }
|
||||||
lookup: [
|
]
|
||||||
{ name: "space", value: " " },
|
},
|
||||||
{ name: "tab", value: "\t" }
|
description: gcli.lookup('jsbIndentCharDesc'),
|
||||||
]
|
manual: gcli.lookup('jsbIndentCharManual'),
|
||||||
},
|
defaultValue: ' ',
|
||||||
description: gcli.lookup('jsbIndentCharDesc'),
|
},
|
||||||
manual: gcli.lookup('jsbIndentCharManual'),
|
{
|
||||||
defaultValue: ' ',
|
name: 'preserveNewlines',
|
||||||
},
|
type: 'boolean',
|
||||||
{
|
description: gcli.lookup('jsbPreserveNewlinesDesc'),
|
||||||
name: 'doNotPreserveNewlines',
|
manual: gcli.lookup('jsbPreserveNewlinesManual')
|
||||||
type: 'boolean',
|
},
|
||||||
description: gcli.lookup('jsbDoNotPreserveNewlinesDesc')
|
{
|
||||||
},
|
name: 'preserveMaxNewlines',
|
||||||
{
|
type: 'number',
|
||||||
name: 'preserveMaxNewlines',
|
description: gcli.lookup('jsbPreserveMaxNewlinesDesc'),
|
||||||
type: 'number',
|
manual: gcli.lookup('jsbPreserveMaxNewlinesManual'),
|
||||||
description: gcli.lookup('jsbPreserveMaxNewlinesDesc'),
|
defaultValue: -1
|
||||||
manual: gcli.lookup('jsbPreserveMaxNewlinesManual'),
|
},
|
||||||
defaultValue: -1
|
{
|
||||||
},
|
name: 'jslintHappy',
|
||||||
{
|
type: 'boolean',
|
||||||
name: 'jslintHappy',
|
description: gcli.lookup('jsbJslintHappyDesc'),
|
||||||
type: 'boolean',
|
manual: gcli.lookup('jsbJslintHappyManual')
|
||||||
description: gcli.lookup('jsbJslintHappyDesc'),
|
},
|
||||||
manual: gcli.lookup('jsbJslintHappyManual')
|
{
|
||||||
},
|
name: 'braceStyle',
|
||||||
{
|
type: {
|
||||||
name: 'braceStyle',
|
name: 'selection',
|
||||||
type: {
|
data: ['collapse', 'expand', 'end-expand', 'expand-strict']
|
||||||
name: 'selection',
|
},
|
||||||
data: ['collapse', 'expand', 'end-expand', 'expand-strict']
|
description: gcli.lookup('jsbBraceStyleDesc'),
|
||||||
},
|
manual: gcli.lookup('jsbBraceStyleManual'),
|
||||||
description: gcli.lookup('jsbBraceStyleDesc'),
|
defaultValue: "collapse"
|
||||||
manual: gcli.lookup('jsbBraceStyleManual'),
|
},
|
||||||
defaultValue: "collapse"
|
{
|
||||||
},
|
name: 'spaceBeforeConditional',
|
||||||
{
|
type: 'boolean',
|
||||||
name: 'noSpaceBeforeConditional',
|
description: gcli.lookup('jsbSpaceBeforeConditionalDesc'),
|
||||||
type: 'boolean',
|
manual: gcli.lookup('jsbSpaceBeforeConditionalManual')
|
||||||
description: gcli.lookup('jsbNoSpaceBeforeConditionalDesc')
|
},
|
||||||
},
|
{
|
||||||
{
|
name: 'unescapeStrings',
|
||||||
name: 'unescapeStrings',
|
type: 'boolean',
|
||||||
type: 'boolean',
|
description: gcli.lookup('jsbUnescapeStringsDesc'),
|
||||||
description: gcli.lookup('jsbUnescapeStringsDesc'),
|
manual: gcli.lookup('jsbUnescapeStringsManual')
|
||||||
manual: gcli.lookup('jsbUnescapeStringsManual')
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
exec: function(args, context) {
|
exec: function(args, context) {
|
||||||
let opts = {
|
let opts = {
|
||||||
indent_size: args.indentSize,
|
indent_size: args.indentSize,
|
||||||
indent_char: args.indentChar,
|
indent_char: args.indentChar,
|
||||||
preserve_newlines: !args.doNotPreserveNewlines,
|
preserve_newlines: args.preserveNewlines,
|
||||||
max_preserve_newlines: args.preserveMaxNewlines == -1 ?
|
max_preserve_newlines: args.preserveMaxNewlines == -1 ?
|
||||||
undefined : args.preserveMaxNewlines,
|
undefined : args.preserveMaxNewlines,
|
||||||
jslint_happy: args.jslintHappy,
|
jslint_happy: args.jslintHappy,
|
||||||
brace_style: args.braceStyle,
|
brace_style: args.braceStyle,
|
||||||
space_before_conditional: !args.noSpaceBeforeConditional,
|
space_before_conditional: args.spaceBeforeConditional,
|
||||||
unescape_strings: args.unescapeStrings
|
unescape_strings: args.unescapeStrings
|
||||||
};
|
}
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest();
|
let xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
|
@ -120,15 +117,13 @@ gcli.addCommand({
|
||||||
if (xhr.status == 200 || xhr.status == 0) {
|
if (xhr.status == 200 || xhr.status == 0) {
|
||||||
let browserDoc = context.environment.chromeDocument;
|
let browserDoc = context.environment.chromeDocument;
|
||||||
let browserWindow = browserDoc.defaultView;
|
let browserWindow = browserDoc.defaultView;
|
||||||
let gBrowser = browserWindow.gBrowser;
|
let browser = browserWindow.gBrowser;
|
||||||
let result = js_beautify(xhr.responseText, opts);
|
|
||||||
|
browser.selectedTab = browser.addTab("data:text/plain;base64," +
|
||||||
// FIXME: btoa currently only works with ISO-8859-1
|
browserWindow.btoa(js_beautify(xhr.responseText, opts)));
|
||||||
// Remove "unescape(encodeURIComponent(" when Bug 213047 is fixed.
|
|
||||||
gBrowser.selectedTab = gBrowser.addTab("data:text/plain;base64," +
|
|
||||||
browserWindow.btoa(unescape(encodeURIComponent(result))));
|
|
||||||
promise.resolve();
|
promise.resolve();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
promise.resolve("Unable to load page to beautify: " + args.url + " " +
|
promise.resolve("Unable to load page to beautify: " + args.url + " " +
|
||||||
xhr.status + " " + xhr.statusText);
|
xhr.status + " " + xhr.statusText);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,14 @@ const TEST_URI = "http://example.com/browser/browser/devtools/commandline/" +
|
||||||
"test/browser_cmd_jsb_script.jsi";
|
"test/browser_cmd_jsb_script.jsi";
|
||||||
|
|
||||||
function test() {
|
function test() {
|
||||||
DeveloperToolbarTest.test("about:blank", [ GJT_test ]);
|
DeveloperToolbarTest.test("about:blank", [ /*GJT_test*/ ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function GJT_test() {
|
function GJT_test() {
|
||||||
helpers.setInput('jsb');
|
helpers.setInput('jsb');
|
||||||
helpers.check({
|
helpers.check({
|
||||||
input: 'jsb',
|
input: 'jsb',
|
||||||
hints: ' <url> [options]',
|
hints: ' <url> [indentSize] [indentChar] [preserveNewlines] [preserveMaxNewlines] [jslintHappy] [braceStyle] [spaceBeforeConditional] [unescapeStrings]',
|
||||||
markup: 'VVV',
|
markup: 'VVV',
|
||||||
status: 'ERROR'
|
status: 'ERROR'
|
||||||
});
|
});
|
||||||
|
@ -30,21 +30,28 @@ function GJT_test() {
|
||||||
result = result.replace(/[\r\n]]/g, "\n");
|
result = result.replace(/[\r\n]]/g, "\n");
|
||||||
|
|
||||||
let correct = "function somefunc() {\n" +
|
let correct = "function somefunc() {\n" +
|
||||||
" if (true) // Some comment\n" +
|
" for (let n = 0; n < 500; n++) {\n" +
|
||||||
" doSomething();\n" +
|
" if (n % 2 == 1) {\n" +
|
||||||
" for (let n = 0; n < 500; n++) {\n" +
|
" console.log(n);\n" +
|
||||||
" if (n % 2 == 1) {\n" +
|
" console.log(n + 1);\n" +
|
||||||
" console.log(n);\n" +
|
" }\n" +
|
||||||
" console.log(n + 1);\n" +
|
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" }\n" +
|
|
||||||
"}";
|
"}";
|
||||||
is(result, correct, "JS has been correctly prettified");
|
is(result, correct, "JS has been correctly prettified");
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
info("Checking beautification");
|
info("Checking beautification");
|
||||||
|
|
||||||
helpers.setInput('jsb ' + TEST_URI);
|
helpers.setInput('jsb ' + TEST_URI);
|
||||||
|
/*
|
||||||
|
helpers.check({
|
||||||
|
input: 'jsb',
|
||||||
|
hints: ' [options]',
|
||||||
|
markup: 'VVV',
|
||||||
|
status: 'VALID'
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
DeveloperToolbarTest.exec({ completed: false });
|
DeveloperToolbarTest.exec({ completed: false });
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
function somefunc(){if (true) // Some comment
|
function somefunc(){for(let n=0;n<500;n++){if(n%2==1){console.log(n);console.log(n+1);}}}
|
||||||
doSomething();for(let n=0;n<500;n++){if(n%2==1){console.log(n);console.log(n+1);}}}
|
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -809,10 +809,11 @@ jsbIndentCharDesc=The chars used to indent each line
|
||||||
# does.
|
# does.
|
||||||
jsbIndentCharManual=The chars used to indent each line. The possible choices are space or tab.
|
jsbIndentCharManual=The chars used to indent each line. The possible choices are space or tab.
|
||||||
|
|
||||||
# the 'jsb <doNotPreserveNewlines>' parameter. This string is designed to be
|
# LOCALIZATION NOTE (jsbPreserveNewlinesDesc) A very short description of the
|
||||||
# shown in a menu alongside the command name, which is why it should be as short
|
# 'jsb <jsbPreserveNewlines>' parameter. This string is designed to be shown
|
||||||
# as possible.
|
# in a menu alongside the command name, which is why it should be as short as
|
||||||
jsbDoNotPreserveNewlinesDesc=Do not preserve line breaks
|
# possible.
|
||||||
|
jsbPreserveNewlinesDesc=Keep existing line breaks?
|
||||||
|
|
||||||
# LOCALIZATION NOTE (jsbPreserveNewlinesManual) A fuller description of the
|
# LOCALIZATION NOTE (jsbPreserveNewlinesManual) A fuller description of the
|
||||||
# 'jsb <jsbPreserveNewlines>' parameter, displayed when the user asks for help
|
# 'jsb <jsbPreserveNewlines>' parameter, displayed when the user asks for help
|
||||||
|
@ -852,11 +853,16 @@ jsbBraceStyleDesc=Collapse, expand, end-expand, expand-strict
|
||||||
# on what it does.
|
# on what it does.
|
||||||
jsbBraceStyleManual=The coding style of braces. Either collapse, expand, end-expand or expand-strict
|
jsbBraceStyleManual=The coding style of braces. Either collapse, expand, end-expand or expand-strict
|
||||||
|
|
||||||
# LOCALIZATION NOTE (jsbNoSpaceBeforeConditionalDesc) A very short description
|
# LOCALIZATION NOTE (jsbSpaceBeforeConditionalDesc) A very short description of
|
||||||
# of the 'jsb <noSpaceBeforeConditional>' parameter. This string is designed to
|
# the 'jsb <spaceBeforeConditional>' parameter. This string is designed to be
|
||||||
# be shown in a menu alongside the command name, which is why it should be as
|
# shown in a menu alongside the command name, which is why it should be as short
|
||||||
# short as possible.
|
# as possible.
|
||||||
jsbNoSpaceBeforeConditionalDesc=No space before conditional statements
|
jsbSpaceBeforeConditionalDesc=Space before if statements?
|
||||||
|
|
||||||
|
# LOCALIZATION NOTE (jsbSpaceBeforeConditionalManual) A fuller description of
|
||||||
|
# the 'jsb <spaceBeforeConditional>' parameter, displayed when the user asks for
|
||||||
|
# help on what it does.
|
||||||
|
jsbSpaceBeforeConditionalManual=Should a space be added before conditional statements?
|
||||||
|
|
||||||
# LOCALIZATION NOTE (jsbUnescapeStringsDesc) A very short description of the
|
# LOCALIZATION NOTE (jsbUnescapeStringsDesc) A very short description of the
|
||||||
# 'jsb <unescapeStrings>' parameter. This string is designed to be shown
|
# 'jsb <unescapeStrings>' parameter. This string is designed to be shown
|
||||||
|
@ -873,10 +879,6 @@ jsbUnescapeStringsManual=Should printable characters in strings encoded in \\xNN
|
||||||
# the jsb command.
|
# the jsb command.
|
||||||
jsbInvalidURL=Please enter a valid URL
|
jsbInvalidURL=Please enter a valid URL
|
||||||
|
|
||||||
# LOCALIZATION NOTE (jsbOptionsDesc) The title of a set of options to
|
|
||||||
# the 'jsb' command, displayed as a heading to the list of options.
|
|
||||||
jsbOptionsDesc=Options
|
|
||||||
|
|
||||||
# LOCALIZATION NOTE (calllogDesc) A very short description of the
|
# LOCALIZATION NOTE (calllogDesc) A very short description of the
|
||||||
# 'calllog' command. This string is designed to be shown in a menu
|
# 'calllog' 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.
|
# alongside the command name, which is why it should be as short as possible.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче