summaryrefslogtreecommitdiff
path: root/src/test/Test.js
diff options
context:
space:
mode:
authorhackademix2018-07-01 01:01:23 +0200
committerhackademix2018-07-01 01:01:23 +0200
commiteceae7187a6f0e9510bc1165f6977256b87f490f (patch)
treed943f1ec73c09efa70954dcedb55eac82a726148 /src/test/Test.js
downloadnoscript-eceae7187a6f0e9510bc1165f6977256b87f490f.tar.gz
noscript-eceae7187a6f0e9510bc1165f6977256b87f490f.tar.xz
noscript-eceae7187a6f0e9510bc1165f6977256b87f490f.zip
Initial commit starting at version 10.1.8.3rc4.
Diffstat (limited to 'src/test/Test.js')
-rw-r--r--src/test/Test.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/test/Test.js b/src/test/Test.js
new file mode 100644
index 0000000..8ca2ed7
--- /dev/null
+++ b/src/test/Test.js
@@ -0,0 +1,43 @@
+var Test = (() => {
+ 'use strict';
+ return {
+ passed: 0,
+ failed: 0,
+ async include(tests) {
+ for(let test of tests) {
+ let src = `/test/${test}_test.js`;
+ log(`Testing ${test}`);
+ this.passed = this.failed = 0;
+ try {
+ await include(src);
+ } catch (e) {
+ // we might omit some tests in publicly available code for Security
+ // reasons, e.g. XSS_test.js
+ log("Missing test ", test);
+ continue;
+ }
+ }
+ },
+ async run(test, msg = "", callback = null) {
+ let r = false;
+ try {
+ r = await test();
+ } catch(e) {
+ error(e);
+ }
+ this[r ? "passed" : "failed"]++;
+ log(`${r ? "PASSED" : "FAILED"} ${msg || uneval(test)}`);
+ if (typeof callback === "function") try {
+ callback(r, test, msg);
+ } catch(e) {
+ error(e);
+ }
+ },
+
+ report() {
+ let {passed, failed} = this;
+ log(`FAILED: ${failed}, PASSED: ${passed}, TOTAL ${passed + failed}.`);
+ }
+ };
+
+})();