diff --git a/manifest.json b/manifest.json
index f7c67941b..b27fcd235 100644
--- a/manifest.json
+++ b/manifest.json
@@ -4,8 +4,8 @@
"name": "GNU Taler Wallet (git)",
"description": "Privacy preserving and transparent payments",
"author": "GNU Taler Developers",
- "version": "0.6.55",
- "version_name": "0.5.0-pre8",
+ "version": "0.6.56",
+ "version_name": "0.5.0-pre9",
"minimum_chrome_version": "51",
"minimum_opera_version": "36",
diff --git a/src/webex/compat.ts b/src/webex/compat.ts
index f532c43bc..30ffd4a81 100644
--- a/src/webex/compat.ts
+++ b/src/webex/compat.ts
@@ -14,15 +14,15 @@
TALER; see the file COPYING. If not, see
*/
- /**
- * Compatibility helpers needed for browsers that don't implement
- * WebExtension APIs consistently.
- */
+/**
+* Compatibility helpers needed for browsers that don't implement
+* WebExtension APIs consistently.
+*/
- export function isFirefox(): boolean {
- const rt = chrome.runtime as any;
- if (typeof rt.getBrowserInfo === "function") {
- return true;
- }
- return false;
- }
+export function isFirefox(): boolean {
+ const rt = chrome.runtime as any;
+ if (typeof rt.getBrowserInfo === "function") {
+ return true;
+ }
+ return false;
+}
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index f1116637d..d7c43225d 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -44,6 +44,8 @@ import {
Wallet,
} from "../wallet";
+import { isFirefox } from "./compat";
+
import {
PurchaseRecord,
Stores,
@@ -449,7 +451,21 @@ async function talerPay(fields: any, url: string, tabId: number): Promise {
+ return new Promise((resolve, reject) => {
+ chrome.tabs.get(tabId, (tab: chrome.tabs.Tab) => resolve(tab));
+ });
+}
+
+
+function waitMs(timeoutMs: number): Promise {
+ return new Promise((resolve, reject) => {
+ chrome.extension.getBackgroundPage().setTimeout(() => resolve(), timeoutMs);
+ });
+}
+
+
+function makeSyncWalletRedirect(url: string, tabId: number, oldUrl: string, params?: {[name: string]: string | undefined}): object {
const innerUrl = new URI(chrome.extension.getURL("/src/webex/pages/" + url));
if (params) {
for (const key in params) {
@@ -460,6 +476,18 @@ function makeSyncWalletRedirect(url: string, params?: {[name: string]: string |
}
const outerUrl = new URI(chrome.extension.getURL("/src/webex/pages/redirect.html"));
outerUrl.addSearch("url", innerUrl);
+ if (isFirefox()) {
+ // Some platforms don't support the sync redirect (yet), so fall back to
+ // async redirect after a timeout.
+ const doit = async() => {
+ await waitMs(150);
+ const tab = await getTab(tabId);
+ if (tab.url === oldUrl) {
+ chrome.tabs.update(tabId, { url: outerUrl.href() });
+ }
+ };
+ doit();
+ }
return { redirectUrl: outerUrl.href() };
}
@@ -512,7 +540,7 @@ function handleHttpPayment(headerList: chrome.webRequest.HttpHeader[], url: stri
}
// Synchronous fast path for new contract
if (fields.contract_url) {
- return makeSyncWalletRedirect("confirm-contract.html", {
+ return makeSyncWalletRedirect("confirm-contract.html", tabId, url, {
contractUrl: fields.contract_url,
sessionId: fields.session_id,
resourceUrl: fields.resource_url,
@@ -521,13 +549,13 @@ function handleHttpPayment(headerList: chrome.webRequest.HttpHeader[], url: stri
// Synchronous fast path for tip
if (fields.tip) {
- return makeSyncWalletRedirect("tip.html", { tip_token: fields.tip });
+ return makeSyncWalletRedirect("tip.html", tabId, url, { tip_token: fields.tip });
}
// Synchronous fast path for refund
if (fields.refund_url) {
console.log("processing refund");
- return makeSyncWalletRedirect("refund.html", { refundUrl: fields.refund_url });
+ return makeSyncWalletRedirect("refund.html", tabId, url, { refundUrl: fields.refund_url });
}
// We need to do some asynchronous operation, we can't directly redirect