aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore8
-rw-r--r--lib/emscripten/taler-emscripten-lib.d.ts4
-rw-r--r--lib/wallet/cryptoApi-test.ts6
-rw-r--r--lib/wallet/cryptoWorker.ts4
-rw-r--r--lib/wallet/emscriptif-test.ts11
-rw-r--r--lib/wallet/emscriptif.ts6
-rw-r--r--package.json1
-rwxr-xr-xscripts/prove-node2
-rwxr-xr-xscripts/prove-selenium3
-rw-r--r--testlib/node/runtime.js (renamed from testlib/testruntime.js)8
-rw-r--r--testlib/selenium/runtime.js100
-rw-r--r--testlib/selenium/testhost.html19
-rw-r--r--testlib/talertest.ts1
13 files changed, 160 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index 95fb987d3..8563e66cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,8 @@ pages/**/*.js.map
pogen/**/*.js.map
test/**/*.js.map
content_scripts/**/*.js.map
+testlib/**/*.js.map
+testlib/talertest.js
background/*.js
pogen/*.js
test/*.js
@@ -20,4 +22,8 @@ build/
taler-wallet-*.tar.gz
taler-wallet-*.directive
taler-wallet-*.directive.asc
-taler-wallet-*.sig \ No newline at end of file
+taler-wallet-*.sig
+
+# Even though node_modules are tracked in git,
+# per default we don't want them to show up in git status
+node_modules
diff --git a/lib/emscripten/taler-emscripten-lib.d.ts b/lib/emscripten/taler-emscripten-lib.d.ts
index 0b180781a..97821d9ef 100644
--- a/lib/emscripten/taler-emscripten-lib.d.ts
+++ b/lib/emscripten/taler-emscripten-lib.d.ts
@@ -51,4 +51,6 @@ export declare namespace Module {
function writeStringToMemory(s: string,
buffer: number,
dontAddNull?: boolean): void;
-} \ No newline at end of file
+}
+
+export default Module;
diff --git a/lib/wallet/cryptoApi-test.ts b/lib/wallet/cryptoApi-test.ts
new file mode 100644
index 000000000..6399367b1
--- /dev/null
+++ b/lib/wallet/cryptoApi-test.ts
@@ -0,0 +1,6 @@
+import {CryptoApi} from "./cryptoApi";
+import {test, TestLib} from "testlib/talertest";
+
+test("string hashing", (t: TestLib) => {
+
+});
diff --git a/lib/wallet/cryptoWorker.ts b/lib/wallet/cryptoWorker.ts
index 22feb8eb7..0689c910e 100644
--- a/lib/wallet/cryptoWorker.ts
+++ b/lib/wallet/cryptoWorker.ts
@@ -45,7 +45,7 @@ if ("object" !== typeof Module) {
// we can use it from TypeScript by importing it.
{
- let mod = System.newModule({Module: Module});
+ let mod = System.newModule({Module: Module, default: Module});
let modName = System.normalizeSync("../emscripten/taler-emscripten-lib");
console.log("registering", modName);
System.set(modName, mod);
@@ -58,4 +58,4 @@ System.import("./cryptoLib")
.catch((e) => {
console.log("crypto worker failed");
console.error(e.stack);
- }); \ No newline at end of file
+ });
diff --git a/lib/wallet/emscriptif-test.ts b/lib/wallet/emscriptif-test.ts
new file mode 100644
index 000000000..a3a9229bb
--- /dev/null
+++ b/lib/wallet/emscriptif-test.ts
@@ -0,0 +1,11 @@
+import {test, TestLib} from "testlib/talertest";
+import * as native from "./emscriptif";
+
+test("string hashing", (t: TestLib) => {
+ let x = native.ByteArray.fromStringWithNull("hello taler");
+ let h = "8RDMADB3YNF3QZBS3V467YZVJAMC2QAQX0TZGVZ6Q5PFRRAJFT70HHN0QF661QR9QWKYMMC7YEMPD679D2RADXCYK8Y669A2A5MKQFR"
+ let hc = x.hash().toCrock();
+ console.log(`# hc ${hc}`);
+ t.assert(h === hc, "must equal");
+ t.pass();
+});
diff --git a/lib/wallet/emscriptif.ts b/lib/wallet/emscriptif.ts
index aad5a12a2..3ae2db72a 100644
--- a/lib/wallet/emscriptif.ts
+++ b/lib/wallet/emscriptif.ts
@@ -15,7 +15,7 @@
*/
import {AmountJson} from "./types";
-import * as EmscWrapper from "../emscripten/taler-emscripten-lib";
+import Module, {EmscFunGen} from "../emscripten/taler-emscripten-lib";
/**
* High-level interface to emscripten-compiled modules used
@@ -34,14 +34,12 @@ const GNUNET_YES = 1;
const GNUNET_NO = 0;
const GNUNET_SYSERR = -1;
-let Module = EmscWrapper.Module;
-
function myCcall(name: string, ret: any, argTypes: any[], args: any[]) {
return Module.ccall(name, ret, argTypes, args);
}
-let getEmsc: EmscWrapper.EmscFunGen = (name: string, ret: any,
+let getEmsc: EmscFunGen = (name: string, ret: any,
argTypes: any[]) => {
return (...args: any[]) => {
return myCcall(name, ret, argTypes, args);
diff --git a/package.json b/package.json
index 406a15858..cd08e3196 100644
--- a/package.json
+++ b/package.json
@@ -32,6 +32,7 @@
"map-stream": "0.0.6",
"mocha": "^2.4.5",
"po2json": "git+https://github.com/mikeedwards/po2json",
+ "selenium-webdriver": "^3.0.0-beta-3",
"systemjs": "^0.19.14",
"through2": "^2.0.1",
"typescript": "^2.0.3",
diff --git a/scripts/prove-node b/scripts/prove-node
index de9c8931a..ca8405324 100755
--- a/scripts/prove-node
+++ b/scripts/prove-node
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
-exec prove -e "node ./testlib/testruntime.js" "$@"
+exec prove -e "node ./testlib/node/runtime.js" "$@"
diff --git a/scripts/prove-selenium b/scripts/prove-selenium
new file mode 100755
index 000000000..d2bd957a5
--- /dev/null
+++ b/scripts/prove-selenium
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+exec prove -e "node ./testlib/selenium/runtime.js" "$@"
diff --git a/testlib/testruntime.js b/testlib/node/runtime.js
index 236807265..29ee508cc 100644
--- a/testlib/testruntime.js
+++ b/testlib/node/runtime.js
@@ -26,7 +26,7 @@ let vm = require("vm");
let fs = require("fs");
let process = require("process");
-let emsc = require("../lib/emscripten/taler-emscripten-lib.js");
+let emsc = require("../../lib/emscripten/taler-emscripten-lib.js");
// Do it here, since it breaks 'require'' for libwrapper
let System = require("systemjs");
@@ -49,13 +49,13 @@ System.config({
console.log("TAP version 13");
-let mod = System.newModule({Module: emsc});
-let modName = System.normalizeSync(__dirname + "/../lib/emscripten/taler-emscripten-lib.js");
+let mod = System.newModule({Module: emsc, default: emsc});
+let modName = System.normalizeSync(__dirname + "/../../lib/emscripten/taler-emscripten-lib.js");
System.set(modName, mod);
let testName = process.argv[2];
-System.import("./testlib/talertest")
+System.import("testlib/talertest")
.then(tt => {
SystemJS.import(testName)
.then(() => {
diff --git a/testlib/selenium/runtime.js b/testlib/selenium/runtime.js
new file mode 100644
index 000000000..0cf6c6d18
--- /dev/null
+++ b/testlib/selenium/runtime.js
@@ -0,0 +1,100 @@
+/*
+ This file is part of TALER
+ (C) 2016 Inria
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+/**
+ *
+ * @author Florian Dold
+ */
+
+"use strict";
+
+var webdriver = require('selenium-webdriver');
+var chrome = require('selenium-webdriver/chrome');
+var path = require("path");
+var process = require("process");
+
+var p = "file://" + __dirname + "/testhost.html";
+
+if (!process.argv[2]) {
+ console.log("no test script given");
+ process.exit(1);
+}
+
+var testScript = path.resolve(process.argv[2]);
+
+var script = `
+ function f() {
+ System.import("testlib/talertest")
+ .then(tt => {
+ SystemJS.import("file://${testScript}")
+ .then(() => {
+ return tt.run();
+ })
+ .then(() => {
+ window.__test_over = true;
+ })
+ .catch((e) => {
+ window.__test_over = true;
+ console.error(e)
+ });
+ })
+ .catch((e) => {
+ console.error("can't locate talertest");
+ console.error(e);
+ });
+ }
+ if (document.readyState == "complete") {
+ f();
+ } else {
+ document.addEventListener("DOMContentLoaded", f);
+ }
+`;
+
+function untilTestOver() {
+ return driver.executeScript("return window.__test_over");
+}
+
+console.log("TAP version 13");
+
+var driver = new webdriver.Builder()
+ .setLoggingPrefs({browser: 'ALL'})
+ .forBrowser('chrome')
+ .build();
+
+driver.get(p);
+driver.executeScript(script);
+driver.wait(untilTestOver);
+
+driver.manage().logs().get("browser").then((logs) => {
+ for (let l of logs) {
+ if (l.level.name != "INFO") {
+ continue;
+ }
+ if (l.message.startsWith("{")) {
+ // format not understood, sometimes messages are logged
+ // with more structure, just pass it on
+ console.log(l.message);
+ continue;
+ }
+ let s1 = l.message.indexOf(" ") + 1;
+ let s2 = l.message.indexOf(" ", s1) + 1;
+ // Skip file url and LINE:COL
+ console.log(l.message.substring(s2));
+ }
+});
+
+driver.quit();
+
diff --git a/testlib/selenium/testhost.html b/testlib/selenium/testhost.html
new file mode 100644
index 000000000..263fe6316
--- /dev/null
+++ b/testlib/selenium/testhost.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Browser Test Host</title>
+ <script src="../../lib/vendor/system-csp-production.src.js"></script>
+ <script>
+ System.config({
+ baseURL: "../../",
+ defaultJSExtensions: true,
+ meta: {
+ "lib/emscripten/taler-emscripten-lib": {
+ format: "global",
+ exports: "Module",
+ }
+ },
+ });
+ </script>
+ </head>
+</html>
diff --git a/testlib/talertest.ts b/testlib/talertest.ts
index 5dcaff457..14074620b 100644
--- a/testlib/talertest.ts
+++ b/testlib/talertest.ts
@@ -82,6 +82,7 @@ export async function run() {
await p;
console.log(`ok ${Number(i) + 1} ${lastMsg}`);
} catch (e) {
+ console.error(e);
console.log(`not ok ${Number(i) + 1} ${lastMsg}`);
}
}