Backed out changeset 48cfe823a5da

This commit is contained in:
Paul Rouget 2012-09-26 12:49:42 +01:00
Родитель 83dcc5791e
Коммит 7ab6608ebf
5 изменённых файлов: 1300 добавлений и 1283 удалений

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

@ -28,82 +28,79 @@ gcli.addCommand({
description: gcli.lookup('jsbUrlDesc')
},
{
group: gcli.lookup("jsbOptionsDesc"),
params: [
{
name: 'indentSize',
type: 'number',
description: gcli.lookup('jsbIndentSizeDesc'),
manual: gcli.lookup('jsbIndentSizeManual'),
defaultValue: 2
},
{
name: 'indentChar',
type: {
name: 'selection',
lookup: [
{ name: "space", value: " " },
{ name: "tab", value: "\t" }
]
},
description: gcli.lookup('jsbIndentCharDesc'),
manual: gcli.lookup('jsbIndentCharManual'),
defaultValue: ' ',
},
{
name: 'doNotPreserveNewlines',
type: 'boolean',
description: gcli.lookup('jsbDoNotPreserveNewlinesDesc')
},
{
name: 'preserveMaxNewlines',
type: 'number',
description: gcli.lookup('jsbPreserveMaxNewlinesDesc'),
manual: gcli.lookup('jsbPreserveMaxNewlinesManual'),
defaultValue: -1
},
{
name: 'jslintHappy',
type: 'boolean',
description: gcli.lookup('jsbJslintHappyDesc'),
manual: gcli.lookup('jsbJslintHappyManual')
},
{
name: 'braceStyle',
type: {
name: 'selection',
data: ['collapse', 'expand', 'end-expand', 'expand-strict']
},
description: gcli.lookup('jsbBraceStyleDesc'),
manual: gcli.lookup('jsbBraceStyleManual'),
defaultValue: "collapse"
},
{
name: 'noSpaceBeforeConditional',
type: 'boolean',
description: gcli.lookup('jsbNoSpaceBeforeConditionalDesc')
},
{
name: 'unescapeStrings',
type: 'boolean',
description: gcli.lookup('jsbUnescapeStringsDesc'),
manual: gcli.lookup('jsbUnescapeStringsManual')
}
]
name: 'indentSize',
type: 'number',
description: gcli.lookup('jsbIndentSizeDesc'),
manual: gcli.lookup('jsbIndentSizeManual'),
defaultValue: 2
},
{
name: 'indentChar',
type: {
name: 'selection',
lookup: [
{ name: "space", value: " " },
{ name: "tab", value: "\t" }
]
},
description: gcli.lookup('jsbIndentCharDesc'),
manual: gcli.lookup('jsbIndentCharManual'),
defaultValue: ' ',
},
{
name: 'preserveNewlines',
type: 'boolean',
description: gcli.lookup('jsbPreserveNewlinesDesc'),
manual: gcli.lookup('jsbPreserveNewlinesManual')
},
{
name: 'preserveMaxNewlines',
type: 'number',
description: gcli.lookup('jsbPreserveMaxNewlinesDesc'),
manual: gcli.lookup('jsbPreserveMaxNewlinesManual'),
defaultValue: -1
},
{
name: 'jslintHappy',
type: 'boolean',
description: gcli.lookup('jsbJslintHappyDesc'),
manual: gcli.lookup('jsbJslintHappyManual')
},
{
name: 'braceStyle',
type: {
name: 'selection',
data: ['collapse', 'expand', 'end-expand', 'expand-strict']
},
description: gcli.lookup('jsbBraceStyleDesc'),
manual: gcli.lookup('jsbBraceStyleManual'),
defaultValue: "collapse"
},
{
name: 'spaceBeforeConditional',
type: 'boolean',
description: gcli.lookup('jsbSpaceBeforeConditionalDesc'),
manual: gcli.lookup('jsbSpaceBeforeConditionalManual')
},
{
name: 'unescapeStrings',
type: 'boolean',
description: gcli.lookup('jsbUnescapeStringsDesc'),
manual: gcli.lookup('jsbUnescapeStringsManual')
}
],
exec: function(args, context) {
let opts = {
indent_size: args.indentSize,
indent_char: args.indentChar,
preserve_newlines: !args.doNotPreserveNewlines,
preserve_newlines: args.preserveNewlines,
max_preserve_newlines: args.preserveMaxNewlines == -1 ?
undefined : args.preserveMaxNewlines,
jslint_happy: args.jslintHappy,
brace_style: args.braceStyle,
space_before_conditional: !args.noSpaceBeforeConditional,
space_before_conditional: args.spaceBeforeConditional,
unescape_strings: args.unescapeStrings
};
}
let xhr = new XMLHttpRequest();
@ -120,15 +117,13 @@ gcli.addCommand({
if (xhr.status == 200 || xhr.status == 0) {
let browserDoc = context.environment.chromeDocument;
let browserWindow = browserDoc.defaultView;
let gBrowser = browserWindow.gBrowser;
let result = js_beautify(xhr.responseText, opts);
// FIXME: btoa currently only works with ISO-8859-1
// Remove "unescape(encodeURIComponent(" when Bug 213047 is fixed.
gBrowser.selectedTab = gBrowser.addTab("data:text/plain;base64," +
browserWindow.btoa(unescape(encodeURIComponent(result))));
let browser = browserWindow.gBrowser;
browser.selectedTab = browser.addTab("data:text/plain;base64," +
browserWindow.btoa(js_beautify(xhr.responseText, opts)));
promise.resolve();
} else {
}
else {
promise.resolve("Unable to load page to beautify: " + args.url + " " +
xhr.status + " " + xhr.statusText);
}

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

@ -7,14 +7,14 @@ const TEST_URI = "http://example.com/browser/browser/devtools/commandline/" +
"test/browser_cmd_jsb_script.jsi";
function test() {
DeveloperToolbarTest.test("about:blank", [ GJT_test ]);
DeveloperToolbarTest.test("about:blank", [ /*GJT_test*/ ]);
}
function GJT_test() {
helpers.setInput('jsb');
helpers.check({
input: 'jsb',
hints: ' <url> [options]',
hints: ' <url> [indentSize] [indentChar] [preserveNewlines] [preserveMaxNewlines] [jslintHappy] [braceStyle] [spaceBeforeConditional] [unescapeStrings]',
markup: 'VVV',
status: 'ERROR'
});
@ -30,21 +30,28 @@ function GJT_test() {
result = result.replace(/[\r\n]]/g, "\n");
let correct = "function somefunc() {\n" +
" if (true) // Some comment\n" +
" doSomething();\n" +
" for (let n = 0; n < 500; n++) {\n" +
" if (n % 2 == 1) {\n" +
" console.log(n);\n" +
" console.log(n + 1);\n" +
" for (let n = 0; n < 500; n++) {\n" +
" if (n % 2 == 1) {\n" +
" console.log(n);\n" +
" console.log(n + 1);\n" +
" }\n" +
" }\n" +
" }\n" +
"}";
is(result, correct, "JS has been correctly prettified");
})
});
info("Checking beautification");
helpers.setInput('jsb ' + TEST_URI);
/*
helpers.check({
input: 'jsb',
hints: ' [options]',
markup: 'VVV',
status: 'VALID'
});
*/
DeveloperToolbarTest.exec({ completed: false });
}

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

@ -1,2 +1 @@
function somefunc(){if (true) // Some comment
doSomething();for(let n=0;n<500;n++){if(n%2==1){console.log(n);console.log(n+1);}}}
function somefunc(){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.
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
# shown in a menu alongside the command name, which is why it should be as short
# as possible.
jsbDoNotPreserveNewlinesDesc=Do not preserve line breaks
# LOCALIZATION NOTE (jsbPreserveNewlinesDesc) A very short description of the
# 'jsb <jsbPreserveNewlines>' parameter. This string is designed to be shown
# in a menu alongside the command name, which is why it should be as short as
# possible.
jsbPreserveNewlinesDesc=Keep existing line breaks?
# LOCALIZATION NOTE (jsbPreserveNewlinesManual) A fuller description of the
# '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.
jsbBraceStyleManual=The coding style of braces. Either collapse, expand, end-expand or expand-strict
# LOCALIZATION NOTE (jsbNoSpaceBeforeConditionalDesc) A very short description
# of the 'jsb <noSpaceBeforeConditional>' parameter. This string is designed to
# be shown in a menu alongside the command name, which is why it should be as
# short as possible.
jsbNoSpaceBeforeConditionalDesc=No space before conditional statements
# LOCALIZATION NOTE (jsbSpaceBeforeConditionalDesc) A very short description of
# the 'jsb <spaceBeforeConditional>' parameter. This string is designed to be
# shown in a menu alongside the command name, which is why it should be as short
# as possible.
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
# '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.
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
# '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.