aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx24
-rw-r--r--packages/taler-wallet-webextension/src/wxApi.ts8
-rw-r--r--packages/taler-wallet-webextension/src/wxBackend.ts12
3 files changed, 44 insertions, 0 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx
index cbf6b1c0a..0916f4f43 100644
--- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx
@@ -200,6 +200,30 @@ export function View({
<Grid item>
<Button
variant="contained"
+ onClick={() => {
+ return api.background.call("sum", [1, 2, 3]).then((r) => {
+ console.log("SUM", r);
+ });
+ }}
+ >
+ <i18n.Translate>sum 123</i18n.Translate>
+ </Button>
+ </Grid>
+ <Grid item>
+ <Button
+ variant="contained"
+ onClick={() => {
+ return api.background.call("freeze", 5000).then(() => {
+ console.log("WAIT");
+ });
+ }}
+ >
+ <i18n.Translate>freeze 5000</i18n.Translate>
+ </Button>
+ </Grid>
+ <Grid item>
+ <Button
+ variant="contained"
onClick={async () => fileRef?.current?.click()}
>
<i18n.Translate>import database</i18n.Translate>
diff --git a/packages/taler-wallet-webextension/src/wxApi.ts b/packages/taler-wallet-webextension/src/wxApi.ts
index ea087fc5d..4ec51fc78 100644
--- a/packages/taler-wallet-webextension/src/wxApi.ts
+++ b/packages/taler-wallet-webextension/src/wxApi.ts
@@ -53,6 +53,14 @@ export interface ExtendedPermissionsResponse {
}
export interface BackgroundOperations {
+ freeze: {
+ request: number;
+ response: void;
+ };
+ sum: {
+ request: number[],
+ response: number,
+ }
resetDb: {
request: void;
response: void;
diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts b/packages/taler-wallet-webextension/src/wxBackend.ts
index c94b390ff..d54dc818f 100644
--- a/packages/taler-wallet-webextension/src/wxBackend.ts
+++ b/packages/taler-wallet-webextension/src/wxBackend.ts
@@ -162,7 +162,19 @@ async function toggleHeaderListener(
return { newValue: false };
}
+function freeze(time: number): Promise<void> {
+ return new Promise((res, rej) => {
+ setTimeout(res, time)
+ })
+}
+
+async function sum(ns: Array<number>): Promise<number> {
+ return ns.reduce((prev, cur) => prev + cur, 0)
+}
+
const backendHandlers: BackendHandlerType = {
+ freeze,
+ sum,
containsHeaderListener,
getDiagnostics,
resetDb,