mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
add option to disable javascript. Fixes #688
This commit is contained in:
@@ -39,6 +39,7 @@ removeFiles("test/browser", /test-runner-[a-zA-Z-]*\.htm$/);
|
||||
createTestRunnerPage("", /javascript|urls/, "main");
|
||||
createTestRunnerPage("", null, "legacy", "legacy");
|
||||
createTestRunnerPage("", /javascript/, "errors", "errors");
|
||||
createTestRunnerPage("", null, "no-js-errors", "no-js-errors");
|
||||
createTestRunnerPage("browser", null, "browser");
|
||||
createTestRunnerPage("browser", null, "relative-urls", "relative-urls");
|
||||
createTestRunnerPage("browser", null, "rootpath", "rootpath");
|
||||
|
||||
6
test/browser/runner-no-js-errors.js
Normal file
6
test/browser/runner-no-js-errors.js
Normal file
@@ -0,0 +1,6 @@
|
||||
less.strictUnits = true;
|
||||
less.javascriptEnabled = false;
|
||||
|
||||
describe("less.js javascript disabled error tests", function() {
|
||||
testLessErrorsInDocument();
|
||||
});
|
||||
@@ -26,8 +26,34 @@ less.tree.functions._color = function (str) {
|
||||
sys.puts("\n" + stylize("LESS", 'underline') + "\n");
|
||||
|
||||
runTestSet({strictMath: true, relativeUrls: true, silent: true});
|
||||
runTestSet({strictMath: true, strictUnits: true}, "errors/",
|
||||
testErrors, null, getErrorPathReplacementFunction("errors"));
|
||||
runTestSet({strictMath: true, strictUnits: true, javascriptEnabled: false}, "no-js-errors/",
|
||||
testErrors, null, getErrorPathReplacementFunction("no-js-errors"));
|
||||
runTestSet({strictMath: true, dumpLineNumbers: 'comments'}, "debug/", null,
|
||||
function(name) { return name + '-comments'; });
|
||||
runTestSet({strictMath: true, dumpLineNumbers: 'mediaquery'}, "debug/", null,
|
||||
function(name) { return name + '-mediaquery'; });
|
||||
runTestSet({strictMath: true, dumpLineNumbers: 'all'}, "debug/", null,
|
||||
function(name) { return name + '-all'; });
|
||||
runTestSet({strictMath: true, relativeUrls: false, rootpath: "folder (1)/"}, "static-urls/");
|
||||
runTestSet({strictMath: true, compress: true}, "compression/");
|
||||
runTestSet({strictMath: false}, "legacy/");
|
||||
|
||||
runTestSet({strictMath: true, strictUnits: true}, "errors/", function(name, err, compiledLess, doReplacements) {
|
||||
testNoOptions();
|
||||
|
||||
function getErrorPathReplacementFunction(dir) {
|
||||
return function(input) {
|
||||
return input.replace(
|
||||
"{path}", path.join(process.cwd(), "/test/less/" + dir + "/"))
|
||||
.replace("{pathrel}", path.join("test", "less", dir + "/"))
|
||||
.replace("{pathhref}", "")
|
||||
.replace("{404status}", "")
|
||||
.replace(/\r\n/g, '\n');
|
||||
};
|
||||
}
|
||||
|
||||
function testErrors(name, err, compiledLess, doReplacements) {
|
||||
fs.readFile(path.join('test/less/', name) + '.txt', 'utf8', function (e, expectedErr) {
|
||||
sys.print("- " + name + ": ");
|
||||
expectedErr = doReplacements(expectedErr, 'test/less/errors/');
|
||||
@@ -40,31 +66,14 @@ runTestSet({strictMath: true, strictUnits: true}, "errors/", function(name, err,
|
||||
} else {
|
||||
var errMessage = less.formatError(err);
|
||||
if (errMessage === expectedErr) {
|
||||
ok('OK');
|
||||
ok('OK');
|
||||
} else {
|
||||
difference("FAIL", expectedErr, errMessage);
|
||||
}
|
||||
}
|
||||
sys.puts("");
|
||||
});}, null, function(input, directory) {
|
||||
return input.replace(
|
||||
"{path}", path.join(process.cwd(), "/test/less/errors/"))
|
||||
.replace("{pathrel}", path.join("test", "less", "errors/"))
|
||||
.replace("{pathhref}", "")
|
||||
.replace("{404status}", "")
|
||||
.replace(/\r\n/g, '\n');
|
||||
});
|
||||
|
||||
runTestSet({strictMath: true, dumpLineNumbers: 'comments'}, "debug/", null,
|
||||
function(name) { return name + '-comments'; });
|
||||
runTestSet({strictMath: true, dumpLineNumbers: 'mediaquery'}, "debug/", null,
|
||||
function(name) { return name + '-mediaquery'; });
|
||||
runTestSet({strictMath: true, dumpLineNumbers: 'all'}, "debug/", null,
|
||||
function(name) { return name + '-all'; });
|
||||
runTestSet({strictMath: true, relativeUrls: false, rootpath: "folder (1)/"}, "static-urls/");
|
||||
runTestSet({strictMath: true, compress: true}, "compression/");
|
||||
runTestSet({strictMath: false}, "legacy/");
|
||||
testNoOptions();
|
||||
}
|
||||
|
||||
function globalReplacements(input, directory) {
|
||||
var p = path.join(process.cwd(), directory),
|
||||
|
||||
3
test/less/no-js-errors/no-js-errors.less
Normal file
3
test/less/no-js-errors/no-js-errors.less
Normal file
@@ -0,0 +1,3 @@
|
||||
.a {
|
||||
a: `1 + 1`;
|
||||
}
|
||||
4
test/less/no-js-errors/no-js-errors.txt
Normal file
4
test/less/no-js-errors/no-js-errors.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
SyntaxError: You are using JavaScript, which has been disabled. in {path}no-js-errors.less on line 2, column 6:
|
||||
1 .a {
|
||||
2 a: `1 + 1`;
|
||||
3 }
|
||||
Reference in New Issue
Block a user