Bug 1381141 - Implement PaymentRequest UI stubs. r=MattN

MozReview-Commit-ID: o8gtrkOE2p

--HG--
rename : toolkit/components/satchel/.eslintrc.js => toolkit/components/payments/.eslintrc.js
extra : rebase_source : a36228edc1c0305c9386bc9fdb316dabf0c49afe
This commit is contained in:
Jonathan Guillotte-Blouin 2017-07-14 14:28:50 -07:00
parent 456985f68e
commit 7f053fd8ed
14 changed files with 204 additions and 0 deletions

View File

@ -43,6 +43,10 @@ var whitelist = [
// 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"},

View File

@ -397,6 +397,7 @@
@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

View File

@ -113,3 +113,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
'nsDefaultCLH.js',
'nsDefaultCLH.manifest',
]
if CONFIG['NIGHTLY_BUILD'] and CONFIG['MOZ_BUILD_APP'] == 'browser':
DIRS += ['payments']

View File

@ -0,0 +1,76 @@
"use strict";
module.exports = {
rules: {
"mozilla/balanced-listeners": "error",
"mozilla/no-cpows-in-tests": "error",
"mozilla/var-only-at-top-level": "error",
"array-bracket-spacing": ["error", "never"],
"block-scoped-var": "error",
"comma-dangle": ["error", "always-multiline"],
complexity: ["error", {
max: 20,
}],
curly: ["error", "all"],
"dot-location": ["error", "property"],
"dot-notation": "error",
"generator-star-spacing": ["error", "after"],
indent: ["error", 2, {
SwitchCase: 1,
CallExpression: {
arguments: "first",
},
FunctionExpression: {
parameters: "first",
},
FunctionDeclaration: {
parameters: "first",
},
// XXX: following line is used in eslint v4 to not throw an error when chaining methods
//MemberExpression: "off",
outerIIFEBody: 0,
}],
"max-len": ["error", 100],
"max-nested-callbacks": ["error", 4],
"new-parens": "error",
"no-caller": "error",
"no-console": "error",
"no-fallthrough": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": ["error", {
max: 2,
}],
"no-new-wrappers": "error",
"no-proto": "error",
"no-throw-literal": "error",
"no-unused-expressions": "error",
"no-unused-vars": ["error", {
args: "none",
varsIgnorePattern: "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$",
}],
"no-use-before-define": ["error", {
functions: false,
}],
"padded-blocks": ["error", "never"],
radix: "error",
semi: ["error", "always"],
"semi-spacing": ["error", {"before": false, "after": true}],
"space-in-parens": ["error", "never"],
"valid-jsdoc": ["error", {
prefer: {
return: "returns",
},
preferType: {
Boolean: "boolean",
Number: "number",
String: "string",
bool: "boolean",
},
requireParamDescription: false,
requireReturn: false,
requireReturnDescription: false,
}],
yoda: "error",
},
};

View File

@ -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/. */

View File

@ -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;

View File

@ -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>

View File

@ -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)

View File

@ -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']

View File

@ -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]);

View File

@ -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}

View File

@ -0,0 +1,8 @@
"use strict";
module.exports = {
"extends": [
"plugin:mozilla/browser-test",
],
};

View File

@ -0,0 +1,4 @@
[DEFAULT]
support-files =
[browser_request_summary.js]

View File

@ -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");
});
});