Bug 1381141 - Implement PaymentRequest UI stubs. r=MattN
MozReview-Commit-ID: o8gtrkOE2p
--- a/browser/base/content/test/static/browser_all_files_referenced.js
+++ b/browser/base/content/test/static/browser_all_files_referenced.js
@@ -38,16 +38,20 @@ var whitelist = new Set([
{file: "chrome://pdf.js/locale/viewer.properties"},
// security/manager/pki/resources/content/device_manager.js
{file: "chrome://pippki/content/load_device.xul"},
// Used by setting this url as a pref in about:config
{file: "chrome://browser/content/newtab/alternativeDefaultSites.json"},
+ // Temporary whitelisted while WebPayments in construction
+ // See Bug 1381141
+ {file: "chrome://payments/content/paymentRequest.xhtml"},
+
// Add-on compat
{file: "chrome://browser/skin/devtools/common.css"},
{file: "chrome://global/content/XPCNativeWrapper.js"},
{file: "chrome://global/locale/brand.dtd"},
// The l10n build system can't package string files only for some platforms.
// See bug 1339424 for why this is hard to fix.
{file: "chrome://global/locale/fallbackMenubar.properties",
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -394,16 +394,17 @@
@RESPATH@/components/DownloadLegacy.js
@RESPATH@/components/BrowserPageThumbs.manifest
@RESPATH@/components/crashmonitor.manifest
@RESPATH@/components/nsCrashMonitor.js
@RESPATH@/components/toolkitsearch.manifest
@RESPATH@/components/nsSearchService.js
@RESPATH@/components/nsSearchSuggestions.js
@RESPATH@/components/nsSidebar.js
+@RESPATH@/components/payments.manifest
@RESPATH@/components/passwordmgr.manifest
@RESPATH@/components/nsLoginInfo.js
@RESPATH@/components/nsLoginManager.js
@RESPATH@/components/nsLoginManagerPrompter.js
@RESPATH@/components/storage-json.js
@RESPATH@/components/crypto-SDR.js
@RESPATH@/components/TooltipTextProvider.js
@RESPATH@/components/TooltipTextProvider.manifest
--- a/toolkit/components/moz.build
+++ b/toolkit/components/moz.build
@@ -108,8 +108,11 @@ DIRS += ['build']
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
DIRS += ['gfx']
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
EXTRA_COMPONENTS += [
'nsDefaultCLH.js',
'nsDefaultCLH.manifest',
]
+
+if CONFIG['NIGHTLY_BUILD'] and CONFIG['MOZ_BUILD_APP'] == 'browser':
+ DIRS += ['payments']
copy from toolkit/components/satchel/.eslintrc.js
copy to toolkit/components/payments/.eslintrc.js
new file mode 100644
--- /dev/null
+++ b/toolkit/components/payments/content/paymentRequest.css
@@ -0,0 +1,4 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
new file mode 100644
--- /dev/null
+++ b/toolkit/components/payments/content/paymentRequest.js
@@ -0,0 +1,7 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
new file mode 100644
--- /dev/null
+++ b/toolkit/components/payments/content/paymentRequest.xhtml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title></title>
+ <link rel="stylesheet" href="chrome://payments/content/paymentRequest.css" />
+ <script src="chrome://payments/content/paymentRequest.js"></script>
+</head>
+<body>
+ <div id="controls-container">
+ <button id="cancel"></button>
+ </div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/toolkit/components/payments/jar.mn
@@ -0,0 +1,9 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+toolkit.jar:
+% content payments %content/payments/
+ content/payments/paymentRequest.css (content/paymentRequest.css)
+ content/payments/paymentRequest.js (content/paymentRequest.js)
+ content/payments/paymentRequest.xhtml (content/paymentRequest.xhtml)
new file mode 100644
--- /dev/null
+++ b/toolkit/components/payments/moz.build
@@ -0,0 +1,16 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini']
+
+EXTRA_COMPONENTS += [
+ 'payments.manifest',
+ 'paymentUIService.js',
+]
+
+EXTRA_JS_MODULES += []
+
+JAR_MANIFESTS += ['jar.mn']
new file mode 100644
--- /dev/null
+++ b/toolkit/components/payments/paymentUIService.js
@@ -0,0 +1,42 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
+// eslint-disable-next-line no-unused-vars
+const DIALOG_URL = "chrome://payments/content/paymentRequest.xhtml";
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+function PaymentUIService() {}
+
+PaymentUIService.prototype = {
+ classID: Components.ID("{01f8bd55-9017-438b-85ec-7c15d2b35cdc}"),
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIPaymentUIService]),
+
+ canMakePayment(requestId) {
+ let canMakeResponse = Cc["@mozilla.org/dom/payments/payment-canmake-action-response;1"]
+ .createInstance(Ci.nsIPaymentCanMakeActionResponse);
+ canMakeResponse.init(requestId, false);
+ return canMakeResponse.QueryInterface(Ci.nsIPaymentActionResponse);
+ },
+
+ showPayment(requestId) {
+ return null;
+ },
+
+ abortPayment(requestId) {
+ let abortResponse = Cc["@mozilla.org/dom/payments/payment-abort-action-response;1"]
+ .createInstance(Ci.nsIPaymentAbortActionResponse);
+ abortResponse.init(requestId, Ci.nsIPaymentActionResponse.ABORT_SUCCEEDED);
+ return abortResponse.QueryInterface(Ci.nsIPaymentActionResponse);
+ },
+
+ completePayment(requestId) {
+ return null;
+ },
+};
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PaymentUIService]);
new file mode 100644
--- /dev/null
+++ b/toolkit/components/payments/payments.manifest
@@ -0,0 +1,2 @@
+component {01f8bd55-9017-438b-85ec-7c15d2b35cdc} paymentUIService.js
+contract @mozilla.org/dom/payments/payment-ui-service;1 {01f8bd55-9017-438b-85ec-7c15d2b35cdc}
new file mode 100644
--- /dev/null
+++ b/toolkit/components/payments/test/browser/.eslintrc.js
@@ -0,0 +1,8 @@
+"use strict";
+
+module.exports = {
+ "extends": [
+ "plugin:mozilla/browser-test",
+ ],
+};
+
new file mode 100644
--- /dev/null
+++ b/toolkit/components/payments/test/browser/browser.ini
@@ -0,0 +1,4 @@
+[DEFAULT]
+support-files =
+
+[browser_request_summary.js]
new file mode 100644
--- /dev/null
+++ b/toolkit/components/payments/test/browser/browser_request_summary.js
@@ -0,0 +1,11 @@
+"use strict";
+
+add_task(async function test_summary() {
+ await BrowserTestUtils.withNewTab({
+ gBrowser,
+ url: "chrome://payments/content/paymentRequest.xhtml",
+ }, async browser => {
+ // eslint-disable-next-line mozilla/no-cpows-in-tests
+ ok(browser.contentDocument.getElementById("cancel"), "Cancel button exists");
+ });
+});