From fb313d2fa9cc6667f0d5f999ca089c9a10c0f437 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 1 Jul 2015 08:41:54 -0700 Subject: [PATCH] Bug 1080088 - disable broken mozPay implementation in desktop runtime; r=marco --- webapprt/prefs.js | 2 +- webapprt/test/chrome/browser_mozpay.js | 60 +++++++++++++------------- webapprt/test/chrome/mozpay.html | 22 +++++++--- 3 files changed, 47 insertions(+), 37 deletions(-) diff --git a/webapprt/prefs.js b/webapprt/prefs.js index a3c4aa6effa..949120802d4 100644 --- a/webapprt/prefs.js +++ b/webapprt/prefs.js @@ -49,7 +49,7 @@ pref("dom.mozTCPSocket.enabled", true); pref("general.smoothScroll", true); // WebPayment -pref("dom.mozPay.enabled", true); +pref("dom.mozPay.enabled", false); // System messages pref("dom.sysmsg.enabled", true); diff --git a/webapprt/test/chrome/browser_mozpay.js b/webapprt/test/chrome/browser_mozpay.js index 9da82455888..47be8142c06 100644 --- a/webapprt/test/chrome/browser_mozpay.js +++ b/webapprt/test/chrome/browser_mozpay.js @@ -12,10 +12,10 @@ function test() { providerUri: "https://example.com:443/webapprtChrome/webapprt/test/chrome/mozpay-success.html?req=", message: "Success." }); - tests.push({ - providerUri: "https://example.com:443/webapprtChrome/webapprt/test/chrome/mozpay-failure.html?req=", - message: "Chocolate rejected." - }); + // tests.push({ + // providerUri: "https://example.com:443/webapprtChrome/webapprt/test/chrome/mozpay-failure.html?req=", + // message: "Chocolate rejected." + // }); let jwt = "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJhdWQiOiAibW9j" + "a3BheXByb3ZpZGVyLnBocGZvZ2FwcC5jb20iLCAiaXNzIjogIkVudGVyI" + @@ -36,23 +36,25 @@ function test() { requestMethod: "GET" }; - let providerWindow; - - let winObserver = function(win, topic) { - if (topic == "domwindowopened") { - win.addEventListener("load", function onLoadWindow() { - win.removeEventListener("load", onLoadWindow, false); - - if (win.document.getElementById("content").getAttribute("src") == - (tests[curTest].providerUri + jwt)) { - ok(true, "Payment provider window shown."); - providerWindow = win; - } - }, false); - } - } - - Services.ww.registerNotification(winObserver); + // Disabled because the mozPay API is disabled, so the provider window + // won't be shown. + // + // let providerWindow; + // let winObserver = function(win, topic) { + // if (topic == "domwindowopened") { + // win.addEventListener("load", function onLoadWindow() { + // win.removeEventListener("load", onLoadWindow, false); + // + // if (win.document.getElementById("content") && + // win.document.getElementById("content").getAttribute("src") == + // (tests[curTest].providerUri + jwt)) { + // ok(true, "Payment provider window shown."); + // providerWindow = win; + // } + // }, false); + // } + // } + // Services.ww.registerNotification(winObserver); let mutObserver = null; @@ -61,12 +63,12 @@ function test() { mutObserver = new MutationObserver(function(mutations) { is(msg.textContent, tests[curTest].message, "Got: " + tests[curTest].message); - if (!providerWindow) { - ok(false, "Payment provider window shown."); - } else { - providerWindow.close(); - providerWindow = null; - } + // if (!providerWindow) { + // ok(false, "Payment provider window shown."); + // } else { + // providerWindow.close(); + // providerWindow = null; + // } runNextTest(); }); @@ -76,7 +78,7 @@ function test() { loadWebapp("mozpay.webapp", undefined, onLoad); function runNextTest() { - providerWindow = null; + // providerWindow = null; if (mutObserver) { mutObserver.disconnect(); } @@ -97,7 +99,7 @@ function test() { } registerCleanupFunction(function() { - Services.ww.unregisterNotification(winObserver); + // Services.ww.unregisterNotification(winObserver); mutObserver.disconnect(); }); } diff --git a/webapprt/test/chrome/mozpay.html b/webapprt/test/chrome/mozpay.html index 8997bc6c7de..e5159c03088 100644 --- a/webapprt/test/chrome/mozpay.html +++ b/webapprt/test/chrome/mozpay.html @@ -32,13 +32,21 @@ "gInR5cCI6ICJtb2NrL3BheW1lbnRzL2luYXBwL3YxIn0.QZxc62USCy4U" + "IyKIC1TKelVhNklvk-Ou1l_daKntaFI"; - var request = navigator.mozPay(jwt); - request.onsuccess = function onsuccess() { - document.getElementById("msg").textContent = "Success."; - }; - request.onerror = function onerror() { - document.getElementById("msg").textContent = request.error.name; - }; + // mozPay is currently disabled in the desktop runtime, so we check + // that the property is set to null on the navigator object. + window.addEventListener("load", function() { + document.getElementById("msg").textContent = + (navigator.mozPay === null) ? "Success." : "navigator.mozPay defined"; + }, false); + + // This is the old code for checking the behavior of the API when enabled: + // var request = navigator.mozPay(jwt); + // request.onsuccess = function onsuccess() { + // document.getElementById("msg").textContent = "Success."; + // }; + // request.onerror = function onerror() { + // document.getElementById("msg").textContent = request.error.name; + // };

Webapp waiting to be paid...