less 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/Gemfile +1 -1
- data/less.gemspec +1 -1
- data/lib/less/defaults.rb +3 -3
- data/lib/less/java_script/v8_context.rb +1 -1
- data/lib/less/js/.gitattributes +3 -2
- data/lib/less/js/.gitignore +18 -2
- data/lib/less/js/.jshintrc +11 -0
- data/lib/less/js/CHANGELOG.md +87 -2
- data/lib/less/js/CONTRIBUTING.md +4 -3
- data/lib/less/js/Gruntfile.js +290 -0
- data/lib/less/js/README.md +342 -12
- data/lib/less/js/benchmark/benchmark.less +194 -194
- data/lib/less/js/benchmark/less-benchmark.js +9 -10
- data/lib/less/js/bin/lessc +154 -12
- data/lib/less/js/bower.json +18 -0
- data/lib/less/js/build.gradle +347 -0
- data/lib/less/js/build/README.md +350 -0
- data/lib/less/js/build/browser-header.js +4 -0
- data/lib/less/js/build/build.yml +160 -0
- data/lib/less/js/build/require-rhino.js +7 -2
- data/lib/less/js/build/rhino-header.js +4 -0
- data/lib/less/js/build/rhino-modules.js +131 -0
- data/lib/less/js/build/tasks/.gitkeep +1 -0
- data/lib/less/js/dist/less-1.5.0.js +6914 -0
- data/lib/less/js/dist/less-1.5.0.min.js +13 -0
- data/lib/less/js/dist/less-1.5.1.js +6941 -0
- data/lib/less/js/dist/less-1.5.1.min.js +13 -0
- data/lib/less/js/dist/less-1.6.0.js +7485 -0
- data/lib/less/js/dist/less-1.6.0.min.js +16 -0
- data/lib/less/js/dist/less-1.6.1.js +7513 -0
- data/lib/less/js/dist/less-1.6.1.min.js +16 -0
- data/lib/less/js/dist/less-1.6.2.js +7624 -0
- data/lib/less/js/dist/less-1.6.2.min.js +16 -0
- data/lib/less/js/dist/less-rhino-1.5.1.js +6831 -0
- data/lib/less/js/dist/less-rhino-1.6.2.js +9017 -0
- data/lib/less/js/dist/lessc-rhino-1.6.2.js +449 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/lib/less/js/gradlew +164 -0
- data/lib/less/js/gradlew.bat +90 -0
- data/lib/less/js/lib/less/browser.js +482 -367
- data/lib/less/js/lib/less/colors.js +0 -1
- data/lib/less/js/lib/less/encoder.js +4 -0
- data/lib/less/js/lib/less/env.js +50 -19
- data/lib/less/js/lib/less/extend-visitor.js +66 -41
- data/lib/less/js/lib/less/functions.js +309 -104
- data/lib/less/js/lib/less/import-visitor.js +21 -10
- data/lib/less/js/lib/less/index.js +90 -68
- data/lib/less/js/lib/less/join-selector-visitor.js +11 -4
- data/lib/less/js/lib/less/lessc_helper.js +56 -45
- data/lib/less/js/lib/less/parser.js +830 -460
- data/lib/less/js/lib/less/rhino.js +380 -58
- data/lib/less/js/lib/less/source-map-output.js +141 -0
- data/lib/less/js/lib/less/to-css-visitor.js +215 -0
- data/lib/less/js/lib/less/tree.js +57 -5
- data/lib/less/js/lib/less/tree/alpha.js +13 -5
- data/lib/less/js/lib/less/tree/anonymous.js +11 -5
- data/lib/less/js/lib/less/tree/assignment.js +11 -5
- data/lib/less/js/lib/less/tree/call.js +19 -8
- data/lib/less/js/lib/less/tree/color.js +59 -36
- data/lib/less/js/lib/less/tree/comment.js +17 -4
- data/lib/less/js/lib/less/tree/condition.js +3 -3
- data/lib/less/js/lib/less/tree/dimension.js +161 -153
- data/lib/less/js/lib/less/tree/directive.js +39 -18
- data/lib/less/js/lib/less/tree/element.js +41 -18
- data/lib/less/js/lib/less/tree/expression.js +11 -5
- data/lib/less/js/lib/less/tree/extend.js +11 -1
- data/lib/less/js/lib/less/tree/import.js +34 -20
- data/lib/less/js/lib/less/tree/javascript.js +16 -10
- data/lib/less/js/lib/less/tree/keyword.js +5 -2
- data/lib/less/js/lib/less/tree/media.js +39 -22
- data/lib/less/js/lib/less/tree/mixin.js +135 -56
- data/lib/less/js/lib/less/tree/negative.js +4 -2
- data/lib/less/js/lib/less/tree/operation.js +17 -12
- data/lib/less/js/lib/less/tree/paren.js +5 -2
- data/lib/less/js/lib/less/tree/quoted.js +9 -6
- data/lib/less/js/lib/less/tree/rule.js +39 -21
- data/lib/less/js/lib/less/tree/ruleset.js +229 -145
- data/lib/less/js/lib/less/tree/selector.js +101 -34
- data/lib/less/js/lib/less/tree/unicode-descriptor.js +4 -3
- data/lib/less/js/lib/less/tree/url.js +33 -11
- data/lib/less/js/lib/less/tree/value.js +13 -6
- data/lib/less/js/lib/less/tree/variable.js +13 -8
- data/lib/less/js/lib/less/visitor.js +117 -25
- data/lib/less/js/lib/source-map/source-map-0.1.31.js +1933 -0
- data/lib/less/js/lib/source-map/source-map-footer.js +4 -0
- data/lib/less/js/lib/source-map/source-map-header.js +3 -0
- data/lib/less/js/package.json +30 -15
- data/lib/less/js/test/browser/common.js +131 -56
- data/lib/less/js/test/browser/css/global-vars/simple.css +3 -0
- data/lib/less/js/test/browser/css/modify-vars/simple.css +8 -0
- data/lib/less/js/test/browser/css/relative-urls/urls.css +8 -9
- data/lib/less/js/test/browser/css/rootpath-relative/urls.css +0 -1
- data/lib/less/js/test/browser/css/rootpath/urls.css +0 -1
- data/lib/less/js/test/browser/css/urls.css +18 -14
- data/lib/less/js/test/browser/es5.js +27 -0
- data/lib/less/js/test/{less/errors/color-operation-error.less → browser/less/console-errors/test-error.less} +0 -0
- data/lib/less/js/test/browser/less/console-errors/test-error.txt +2 -0
- data/lib/less/js/test/browser/less/global-vars/simple.less +3 -0
- data/lib/less/js/test/browser/less/modify-vars/imports/simple2.less +4 -0
- data/lib/less/js/test/browser/less/modify-vars/simple.less +8 -0
- data/lib/less/js/test/browser/less/relative-urls/urls.less +1 -1
- data/lib/less/js/test/browser/less/rootpath-relative/urls.less +1 -1
- data/lib/less/js/test/browser/less/rootpath/urls.less +1 -1
- data/lib/less/js/test/browser/less/urls.less +9 -1
- data/lib/less/js/test/browser/phantom-runner.js +112 -103
- data/lib/less/js/test/browser/runner-browser-options.js +42 -0
- data/lib/less/js/test/browser/{runner-browser.js → runner-browser-spec.js} +7 -2
- data/lib/less/js/test/browser/runner-console-errors.js +5 -0
- data/lib/less/js/test/browser/runner-errors-options.js +5 -0
- data/lib/less/js/test/browser/runner-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-options.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-spec.js +3 -0
- data/lib/less/js/test/browser/runner-legacy-options.js +4 -0
- data/lib/less/js/test/browser/{runner-legacy.js → runner-legacy-spec.js} +1 -4
- data/lib/less/js/test/browser/runner-main-options.js +15 -0
- data/lib/less/js/test/browser/runner-main-spec.js +3 -0
- data/lib/less/js/test/browser/runner-modify-vars-options.js +2 -0
- data/lib/less/js/test/browser/runner-modify-vars-spec.js +43 -0
- data/lib/less/js/test/browser/runner-no-js-errors-options.js +4 -0
- data/lib/less/js/test/browser/runner-no-js-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-production-options.js +3 -0
- data/lib/less/js/test/browser/{runner-production.js → runner-production-spec.js} +1 -3
- data/lib/less/js/test/browser/runner-relative-urls-options.js +3 -0
- data/lib/less/js/test/browser/{runner-relative-urls.js → runner-relative-urls-spec.js} +1 -2
- data/lib/less/js/test/browser/runner-rootpath-options.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-relative-options.js +4 -0
- data/lib/less/js/test/browser/{runner-rootpath-relative.js → runner-rootpath-relative-spec.js} +1 -3
- data/lib/less/js/test/browser/{runner-rootpath.js → runner-rootpath-spec.js} +1 -2
- data/lib/less/js/test/browser/test-runner-template.tmpl +47 -0
- data/lib/less/js/test/css/colors.css +7 -0
- data/lib/less/js/test/css/comments.css +9 -4
- data/lib/less/js/test/css/compression/compression.css +3 -2
- data/lib/less/js/test/css/css-3.css +17 -5
- data/lib/less/js/test/css/css-guards.css +37 -0
- data/lib/less/js/test/css/debug/linenumbers-all.css +6 -0
- data/lib/less/js/test/css/debug/linenumbers-comments.css +5 -0
- data/lib/less/js/test/css/debug/linenumbers-mediaquery.css +5 -0
- data/lib/less/js/test/css/empty.css +0 -0
- data/lib/less/js/test/css/extend-chaining.css +9 -0
- data/lib/less/js/test/css/extend-selector.css +10 -2
- data/lib/less/js/test/css/extract-and-length.css +133 -0
- data/lib/less/js/test/css/functions.css +23 -10
- data/lib/less/js/test/css/globalVars/extended.css +12 -0
- data/lib/less/js/test/css/globalVars/simple.css +6 -0
- data/lib/less/js/test/css/import-inline.css +5 -0
- data/lib/less/js/test/css/import-once.css +12 -0
- data/lib/less/js/test/css/import-reference.css +49 -0
- data/lib/less/js/test/css/import.css +0 -2
- data/lib/less/js/test/css/media.css +21 -5
- data/lib/less/js/test/css/merge.css +26 -0
- data/lib/less/js/test/css/mixins-guards-default-func.css +129 -0
- data/lib/less/js/test/css/mixins-guards.css +6 -0
- data/lib/less/js/test/css/mixins-important.css +7 -0
- data/lib/less/js/test/css/mixins-interpolated.css +39 -0
- data/lib/less/js/test/css/mixins.css +20 -0
- data/lib/less/js/test/css/modifyVars/extended.css +9 -0
- data/lib/less/js/test/css/no-output.css +0 -0
- data/lib/less/js/test/css/parens.css +3 -0
- data/lib/less/js/test/css/property-name-interp.css +20 -0
- data/lib/less/js/test/css/selectors.css +12 -0
- data/lib/less/js/test/css/static-urls/urls.css +7 -4
- data/lib/less/js/test/css/strings.css +3 -0
- data/lib/less/js/test/css/url-args/urls.css +56 -0
- data/lib/less/js/test/css/urls.css +21 -9
- data/lib/less/js/test/index.js +45 -0
- data/lib/less/js/test/less-test.js +234 -191
- data/lib/less/js/test/less/colors.less +6 -0
- data/lib/less/js/test/less/comments.less +7 -1
- data/lib/less/js/test/less/compression/compression.less +21 -1
- data/lib/less/js/test/less/css-3.less +12 -0
- data/lib/less/js/test/less/css-guards.less +99 -0
- data/lib/less/js/test/less/debug/linenumbers.less +11 -1
- data/lib/less/js/test/less/empty.less +0 -0
- data/lib/less/js/test/less/errors/add-mixed-units.txt +4 -2
- data/lib/less/js/test/less/errors/add-mixed-units2.txt +4 -2
- data/lib/less/js/test/less/errors/color-func-invalid-color.less +3 -0
- data/lib/less/js/test/less/errors/color-func-invalid-color.txt +4 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.less +4 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.txt +4 -0
- data/lib/less/js/test/less/errors/import-subfolder2.txt +4 -2
- data/lib/less/js/test/less/errors/javascript-undefined-var.less +3 -0
- data/lib/less/js/test/less/errors/javascript-undefined-var.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.txt +4 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.less +4 -1
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +4 -2
- data/lib/less/js/test/less/errors/parse-error-extra-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-extra-parens.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.txt +2 -2
- data/lib/less/js/test/less/errors/parse-error-missing-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-missing-parens.txt +3 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.less +3 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.txt +4 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.less +1 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.txt +2 -0
- data/lib/less/js/test/less/errors/svg-gradient1.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient1.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient2.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient2.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient3.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient3.txt +4 -0
- data/lib/less/js/test/less/errors/unit-function.less +3 -0
- data/lib/less/js/test/less/errors/unit-function.txt +4 -0
- data/lib/less/js/test/less/extend-chaining.less +12 -0
- data/lib/less/js/test/less/extend-selector.less +15 -0
- data/lib/less/js/test/less/extract-and-length.less +133 -0
- data/lib/less/js/test/less/functions.less +15 -2
- data/lib/less/js/test/less/globalVars/extended.json +5 -0
- data/lib/less/js/test/less/globalVars/extended.less +10 -0
- data/lib/less/js/test/less/globalVars/simple.json +3 -0
- data/lib/less/js/test/less/globalVars/simple.less +3 -0
- data/lib/less/js/test/less/import-inline.less +2 -0
- data/lib/less/js/test/less/import-once.less +2 -0
- data/lib/less/js/test/less/import-reference.less +18 -0
- data/lib/less/js/test/less/import/import-and-relative-paths-test.less +11 -0
- data/lib/less/js/test/less/import/import-reference.less +43 -0
- data/lib/less/js/test/less/import/import-test-f.less +5 -0
- data/lib/less/js/test/less/import/invalid-css.less +1 -0
- data/lib/less/js/test/less/media.less +25 -1
- data/lib/less/js/test/less/merge.less +59 -0
- data/lib/less/js/test/less/mixins-args.less +10 -0
- data/lib/less/js/test/less/mixins-guards-default-func.less +195 -0
- data/lib/less/js/test/less/mixins-guards.less +16 -0
- data/lib/less/js/test/less/mixins-important.less +4 -1
- data/lib/less/js/test/less/mixins-interpolated.less +69 -0
- data/lib/less/js/test/less/mixins.less +27 -0
- data/lib/less/js/test/less/modifyVars/extended.json +5 -0
- data/lib/less/js/test/less/modifyVars/extended.less +11 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.less +3 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.txt +4 -0
- data/lib/less/js/test/less/no-output.less +2 -0
- data/lib/less/js/test/less/parens.less +4 -0
- data/lib/less/js/test/less/property-name-interp.less +53 -0
- data/lib/less/js/test/less/selectors.less +13 -0
- data/lib/less/js/test/less/sourcemaps/basic.json +3 -0
- data/lib/less/js/test/less/sourcemaps/basic.less +27 -0
- data/lib/less/js/test/less/sourcemaps/imported.css +7 -0
- data/lib/less/js/test/less/strings.less +6 -0
- data/lib/less/js/test/less/url-args/urls.less +63 -0
- data/lib/less/js/test/less/urls.less +15 -0
- data/lib/less/js/test/rhino/test-header.js +15 -0
- data/lib/less/js/test/sourcemaps/basic.json +1 -0
- data/lib/less/js/test/sourcemaps/index.html +17 -0
- data/lib/less/loader.rb +48 -40
- data/lib/less/version.rb +1 -1
- data/spec/less/parser_spec.rb +15 -15
- metadata +146 -40
- data/lib/less/js/Makefile +0 -102
- data/lib/less/js/build/header.js +0 -9
- data/lib/less/js/test/browser-test-prepare.js +0 -46
- data/lib/less/js/test/browser/runner-errors.js +0 -5
- data/lib/less/js/test/browser/runner-main.js +0 -15
- data/lib/less/js/test/browser/template.htm +0 -10
- data/lib/less/js/test/less/errors/color-operation-error.txt +0 -2
@@ -0,0 +1,27 @@
|
|
1
|
+
/*
|
2
|
+
PhantomJS does not implement bind. this is from
|
3
|
+
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
|
4
|
+
*/
|
5
|
+
if (!Function.prototype.bind) {
|
6
|
+
Function.prototype.bind = function (oThis) {
|
7
|
+
if (typeof this !== "function") {
|
8
|
+
// closest thing possible to the ECMAScript 5 internal IsCallable function
|
9
|
+
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
10
|
+
}
|
11
|
+
|
12
|
+
var aArgs = Array.prototype.slice.call(arguments, 1),
|
13
|
+
fToBind = this,
|
14
|
+
fNOP = function () {},
|
15
|
+
fBound = function () {
|
16
|
+
return fToBind.apply(this instanceof fNOP && oThis
|
17
|
+
? this
|
18
|
+
: oThis,
|
19
|
+
aArgs.concat(Array.prototype.slice.call(arguments)));
|
20
|
+
};
|
21
|
+
|
22
|
+
fNOP.prototype = this.prototype;
|
23
|
+
fBound.prototype = new fNOP();
|
24
|
+
|
25
|
+
return fBound;
|
26
|
+
};
|
27
|
+
}
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
@import "imports/urls.less";
|
2
|
-
@import "http://localhost:8081/browser/less/imports/urls2.less";
|
2
|
+
@import "http://localhost:8081/test/browser/less/imports/urls2.less";
|
3
3
|
@font-face {
|
4
4
|
src: url("/fonts/garamond-pro.ttf");
|
5
5
|
src: local(Futura-Medium),
|
@@ -47,3 +47,11 @@
|
|
47
47
|
#data-uri-toobig {
|
48
48
|
uri: data-uri('../../data/data-uri-fail.png');
|
49
49
|
}
|
50
|
+
#svg-functions {
|
51
|
+
background-image: svg-gradient(to bottom, black, white);
|
52
|
+
background-image: svg-gradient(to bottom, black, orange 3%, white);
|
53
|
+
@green_5: green 5%;
|
54
|
+
@orange_percentage: 3%;
|
55
|
+
@orange_color: orange;
|
56
|
+
background-image: svg-gradient(to bottom, (mix(black, white) + #444) 1%, @orange_color @orange_percentage, ((@green_5)), white 95%);
|
57
|
+
}
|
@@ -2,31 +2,35 @@ var webpage = require('webpage');
|
|
2
2
|
var server = require('webserver').create();
|
3
3
|
var system = require('system');
|
4
4
|
var fs = require('fs');
|
5
|
-
var host
|
5
|
+
var host;
|
6
|
+
var port = 8081;
|
6
7
|
|
7
|
-
var listening = server.listen(port, function
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
if (!fs.exists(filename) || !fs.isFile(filename)) {
|
13
|
-
response.statusCode = 404;
|
14
|
-
response.write("<html><head></head><body><h1>File Not Found</h1><h2>File:"+filename+"</h2></body></html>");
|
15
|
-
response.close();
|
16
|
-
return;
|
17
|
-
}
|
8
|
+
var listening = server.listen(port, function(request, response) {
|
9
|
+
//console.log("Requested " + request.url);
|
10
|
+
|
11
|
+
var filename = ("test/" + request.url.slice(1)).replace(/[\\\/]/g, fs.separator);
|
18
12
|
|
19
|
-
|
20
|
-
response.statusCode =
|
21
|
-
response.
|
22
|
-
|
23
|
-
response.write(fs.read(filename));
|
24
|
-
|
13
|
+
if (!fs.exists(filename) || !fs.isFile(filename)) {
|
14
|
+
response.statusCode = 404;
|
15
|
+
response.write("<html><head></head><body><h1>File Not Found</h1><h2>File:" + filename + "</h2></body></html>");
|
25
16
|
response.close();
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
|
20
|
+
// we set the headers here
|
21
|
+
response.statusCode = 200;
|
22
|
+
response.headers = {
|
23
|
+
"Cache": "no-cache",
|
24
|
+
"Content-Type": "text/html"
|
25
|
+
};
|
26
|
+
|
27
|
+
response.write(fs.read(filename));
|
28
|
+
|
29
|
+
response.close();
|
26
30
|
});
|
27
31
|
if (!listening) {
|
28
|
-
|
29
|
-
|
32
|
+
console.log("could not create web server listening on port " + port);
|
33
|
+
phantom.exit();
|
30
34
|
}
|
31
35
|
|
32
36
|
/**
|
@@ -42,100 +46,105 @@ if (!listening) {
|
|
42
46
|
* @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
|
43
47
|
* @param timeOutErrorMessage the error message if time out occurs
|
44
48
|
*/
|
45
|
-
function waitFor(testFx, onReady, timeOutMillis, timeOutErrorMessage) {
|
46
|
-
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 10001, //< Default Max Timeout is 10s
|
47
|
-
start = new Date().getTime(),
|
48
|
-
condition = false,
|
49
|
-
interval = setInterval(function() {
|
50
|
-
if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) {
|
51
|
-
// If not time-out yet and condition not yet fulfilled
|
52
|
-
condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code
|
53
|
-
} else {
|
54
|
-
if(!condition) {
|
55
|
-
// If condition still not fulfilled (timeout but condition is 'false')
|
56
|
-
console.log(timeOutErrorMessage || "'waitFor()' timeout");
|
57
|
-
phantom.exit(1);
|
58
|
-
} else {
|
59
|
-
// Condition fulfilled (timeout and/or condition is 'true')
|
60
|
-
typeof(onReady) === "string" ? eval(onReady) : onReady(); //< Do what it's supposed to do once the condition is fulfilled
|
61
|
-
clearInterval(interval); //< Stop this interval
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}, 100); //< repeat check every 100ms
|
65
|
-
};
|
66
49
|
|
67
|
-
function
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
50
|
+
function waitFor(testFx, onReady, timeOutMillis, timeOutErrorMessage) {
|
51
|
+
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 10001, //< Default Max Timeout is 10s
|
52
|
+
start = new Date().getTime(),
|
53
|
+
condition = false,
|
54
|
+
interval = setInterval(function() {
|
55
|
+
if ((new Date().getTime() - start < maxtimeOutMillis) && !condition) {
|
56
|
+
// If not time-out yet and condition not yet fulfilled
|
57
|
+
condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code
|
58
|
+
} else {
|
59
|
+
if (!condition) {
|
60
|
+
// If condition still not fulfilled (timeout but condition is 'false')
|
61
|
+
console.log(timeOutErrorMessage || "'waitFor()' timeout");
|
62
|
+
phantom.exit(1);
|
73
63
|
} else {
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
document.body.querySelector('.symbolSummary .pending') === null &&
|
78
|
-
document.body.querySelector('.results') !== null;
|
79
|
-
});
|
80
|
-
}, function(){
|
81
|
-
page.onConsoleMessage = function (msg) {
|
82
|
-
console.log(msg);
|
83
|
-
};
|
84
|
-
var exitCode = page.evaluate(function(){
|
85
|
-
console.log('');
|
86
|
-
console.log(document.body.querySelector('.description').innerText);
|
87
|
-
var list = document.body.querySelectorAll('.results > #details > .specDetail.failed');
|
88
|
-
if (list && list.length > 0) {
|
89
|
-
console.log('');
|
90
|
-
console.log(list.length + ' test(s) FAILED:');
|
91
|
-
for (var i = 0; i < list.length; ++i) {
|
92
|
-
var el = list[i],
|
93
|
-
desc = el.querySelector('.description'),
|
94
|
-
msg = el.querySelector('.resultMessage.fail');
|
95
|
-
console.log('');
|
96
|
-
console.log(desc.innerText);
|
97
|
-
console.log(msg.innerText);
|
98
|
-
console.log('');
|
99
|
-
}
|
100
|
-
return 1;
|
101
|
-
} else {
|
102
|
-
console.log(document.body.querySelector('.alert > .passingAlert.bar').innerText);
|
103
|
-
return 0;
|
104
|
-
}
|
105
|
-
});
|
106
|
-
testFinished(exitCode);
|
107
|
-
},
|
108
|
-
10000, // 10 second timeout
|
109
|
-
"Test failed waiting for jasmine results on page: " + url);
|
64
|
+
// Condition fulfilled (timeout and/or condition is 'true')
|
65
|
+
typeof(onReady) === "string" ? eval(onReady) : onReady(); //< Do what it's supposed to do once the condition is fulfilled
|
66
|
+
clearInterval(interval); //< Stop this interval
|
110
67
|
}
|
111
|
-
|
68
|
+
}
|
69
|
+
}, 100); //< repeat check every 100ms
|
70
|
+
}
|
71
|
+
|
72
|
+
function testPage(url) {
|
73
|
+
var page = webpage.create();
|
74
|
+
page.open(url, function(status) {
|
75
|
+
if (status !== "success") {
|
76
|
+
console.log("Unable to access network - " + status);
|
77
|
+
phantom.exit();
|
78
|
+
} else {
|
79
|
+
waitFor(function() {
|
80
|
+
return page.evaluate(function() {
|
81
|
+
return document.body && document.body.querySelector &&
|
82
|
+
document.body.querySelector('.symbolSummary .pending') === null &&
|
83
|
+
document.body.querySelector('.results') !== null;
|
84
|
+
});
|
85
|
+
}, function() {
|
86
|
+
page.onConsoleMessage = function(msg) {
|
87
|
+
console.log(msg);
|
88
|
+
};
|
89
|
+
var exitCode = page.evaluate(function() {
|
90
|
+
console.log('');
|
91
|
+
console.log(document.body.querySelector('.description').innerText);
|
92
|
+
var list = document.body.querySelectorAll('.results > #details > .specDetail.failed');
|
93
|
+
if (list && list.length > 0) {
|
94
|
+
console.log('');
|
95
|
+
console.log(list.length + ' test(s) FAILED:');
|
96
|
+
for (var i = 0; i < list.length; ++i) {
|
97
|
+
var el = list[i],
|
98
|
+
desc = el.querySelector('.description'),
|
99
|
+
msg = el.querySelector('.resultMessage.fail');
|
100
|
+
console.log('');
|
101
|
+
console.log(desc.innerText);
|
102
|
+
console.log(msg.innerText);
|
103
|
+
console.log('');
|
104
|
+
}
|
105
|
+
return 1;
|
106
|
+
} else {
|
107
|
+
console.log(document.body.querySelector('.alert > .passingAlert.bar').innerText);
|
108
|
+
return 0;
|
109
|
+
}
|
110
|
+
});
|
111
|
+
testFinished(exitCode);
|
112
|
+
},
|
113
|
+
10000, // 10 second timeout
|
114
|
+
"Test failed waiting for jasmine results on page: " + url);
|
115
|
+
}
|
116
|
+
});
|
112
117
|
}
|
113
118
|
|
114
119
|
function scanDirectory(path, regex) {
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
}
|
120
|
+
var files = [];
|
121
|
+
fs.list(path).forEach(function(file) {
|
122
|
+
if (file.match(regex)) {
|
123
|
+
files.push(file);
|
124
|
+
}
|
125
|
+
});
|
126
|
+
return files;
|
127
|
+
}
|
123
128
|
|
124
129
|
var totalTests = 0,
|
125
|
-
|
126
|
-
|
130
|
+
totalFailed = 0,
|
131
|
+
totalDone = 0;
|
127
132
|
|
128
133
|
function testFinished(failed) {
|
129
|
-
|
130
|
-
|
131
|
-
|
134
|
+
if (failed) {
|
135
|
+
totalFailed++;
|
136
|
+
}
|
137
|
+
totalDone++;
|
138
|
+
if (totalDone === totalTests) {
|
139
|
+
phantom.exit(totalFailed > 0 ? 1 : 0);
|
140
|
+
}
|
132
141
|
}
|
133
142
|
|
134
143
|
if (system.args.length != 2 && system.args[1] != "--no-tests") {
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
144
|
+
var files = scanDirectory("test/browser/", /^test-runner-.+\.htm$/);
|
145
|
+
totalTests = files.length;
|
146
|
+
console.log("found " + files.length + " tests");
|
147
|
+
files.forEach(function(file) {
|
148
|
+
testPage("http://localhost:8081/browser/" + file);
|
149
|
+
});
|
141
150
|
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
var less = {};
|
2
|
+
|
3
|
+
// There originally run inside describe method. However, since they have not
|
4
|
+
// been inside it, they run at jasmine compile time (not runtime). It all
|
5
|
+
// worked cause less.js was in async mode and custom phantom runner had
|
6
|
+
// different setup then grunt-contrib-jasmine. They have been created before
|
7
|
+
// less.js run, even as they have been defined in spec.
|
8
|
+
|
9
|
+
// test inline less in style tags by grabbing an assortment of less files and doing `@import`s
|
10
|
+
var testFiles = ['charsets', 'colors', 'comments', 'css-3', 'strings', 'media', 'mixins'],
|
11
|
+
testSheets = [];
|
12
|
+
|
13
|
+
// setup style tags with less and link tags pointing to expected css output
|
14
|
+
for (var i = 0; i < testFiles.length; i++) {
|
15
|
+
var file = testFiles[i],
|
16
|
+
lessPath = '/test/less/' + file + '.less',
|
17
|
+
cssPath = '/test/css/' + file + '.css',
|
18
|
+
lessStyle = document.createElement('style'),
|
19
|
+
cssLink = document.createElement('link'),
|
20
|
+
lessText = '@import "' + lessPath + '";';
|
21
|
+
|
22
|
+
lessStyle.type = 'text/less';
|
23
|
+
lessStyle.id = file;
|
24
|
+
lessStyle.href = file;
|
25
|
+
|
26
|
+
if (lessStyle.styleSheet) {
|
27
|
+
lessStyle.styleSheet.cssText = lessText;
|
28
|
+
} else {
|
29
|
+
lessStyle.innerHTML = lessText;
|
30
|
+
}
|
31
|
+
|
32
|
+
cssLink.rel = 'stylesheet';
|
33
|
+
cssLink.type = 'text/css';
|
34
|
+
cssLink.href = cssPath;
|
35
|
+
cssLink.id = 'expected-' + file;
|
36
|
+
|
37
|
+
var head = document.getElementsByTagName('head')[0];
|
38
|
+
|
39
|
+
head.appendChild(lessStyle);
|
40
|
+
head.appendChild(cssLink);
|
41
|
+
testSheets[i] = lessStyle;
|
42
|
+
}
|
@@ -1,7 +1,12 @@
|
|
1
1
|
describe("less.js browser behaviour", function() {
|
2
2
|
testLessEqualsInDocument();
|
3
|
-
|
3
|
+
|
4
4
|
it("has some log messages", function() {
|
5
5
|
expect(logMessages.length).toBeGreaterThan(0);
|
6
6
|
});
|
7
|
-
|
7
|
+
|
8
|
+
for (var i = 0; i < testFiles.length; i++) {
|
9
|
+
var sheet = testSheets[i];
|
10
|
+
testSheet(sheet);
|
11
|
+
}
|
12
|
+
});
|
@@ -0,0 +1,15 @@
|
|
1
|
+
var less = {};
|
2
|
+
less.strictMath = true;
|
3
|
+
less.functions = {
|
4
|
+
add: function(a, b) {
|
5
|
+
return new(less.tree.Dimension)(a.value + b.value);
|
6
|
+
},
|
7
|
+
increment: function(a) {
|
8
|
+
return new(less.tree.Dimension)(a.value + 1);
|
9
|
+
},
|
10
|
+
_color: function(str) {
|
11
|
+
if (str.value === "evil red") {
|
12
|
+
return new(less.tree.Color)("600");
|
13
|
+
}
|
14
|
+
}
|
15
|
+
};
|