Bug 1434839 - Rename PaymentDialog to paymentDialogWrapper to reduce confusion. r=jaws

MozReview-Commit-ID: 6o8B7bHy9fo

--HG--
rename : toolkit/components/payments/content/paymentDialog.css => toolkit/components/payments/content/paymentDialogWrapper.css
rename : toolkit/components/payments/content/paymentDialog.js => toolkit/components/payments/content/paymentDialogWrapper.js
rename : toolkit/components/payments/content/paymentDialog.xhtml => toolkit/components/payments/content/paymentDialogWrapper.xhtml
extra : rebase_source : 0267da92eca5b3b46fab87e26bfbeb089b1518ad
This commit is contained in:
Matthew Noorenberghe 2018-02-01 14:40:29 -08:00
parent 53c9c480b7
commit 7bebf01b39
8 changed files with 21 additions and 20 deletions

View File

@ -30,7 +30,7 @@ XPCOMUtils.defineLazyGetter(this, "profileStorage", () => {
return profileStorage;
});
var PaymentDialog = {
var paymentDialogWrapper = {
componentsLoaded: new Map(),
frame: null,
mm: null,
@ -275,5 +275,5 @@ if ("document" in this) {
// Running in a browser, not a unit test
let frame = document.getElementById("paymentRequestFrame");
let requestId = (new URLSearchParams(window.location.search)).get("requestId");
PaymentDialog.init(requestId, frame);
paymentDialogWrapper.init(requestId, frame);
}

View File

@ -6,7 +6,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" href="chrome://payments/content/paymentDialog.css"/>
<link rel="stylesheet" href="chrome://payments/content/paymentDialogWrapper.css"/>
</head>
<body>
@ -16,6 +16,6 @@
remote="true"
height="400"
width="700"></iframe>
<script src="chrome://payments/content/paymentDialog.js"></script>
<script src="chrome://payments/content/paymentDialogWrapper.js"></script>
</body>
</html>

View File

@ -33,7 +33,7 @@ The UI talks to the DOM code via the ``nsIPaymentRequestService`` interface.
Dialog Architecture
===================
Privileged wrapper XHTML document (paymentDialog.xhtml) containing a remote ``<iframe mozbrowser="true" remote="true">`` containing unprivileged XHTML (paymentRequest.xhtml).
Privileged wrapper XHTML document (paymentDialogWrapper.xhtml) containing a remote ``<iframe mozbrowser="true" remote="true">`` containing unprivileged XHTML (paymentRequest.xhtml).
Keeping the dialog contents unprivileged is useful since the dialog will render payment line items and shipping options that are provided by web developers and should therefore be considered untrusted.
In order to communicate across the process boundary a privileged frame script (`paymentDialogFrameScript.js`) is loaded into the iframe to relay messages.
This is because the unprivileged document cannot access message managers.

View File

@ -4,10 +4,11 @@
toolkit.jar:
% content payments %content/payments/
content/payments/paymentDialog.css (content/paymentDialog.css)
content/payments/paymentDialog.js (content/paymentDialog.js)
content/payments/paymentDialogFrameScript.js (content/paymentDialogFrameScript.js)
content/payments/paymentDialog.xhtml (content/paymentDialog.xhtml)
content/payments/paymentDialogWrapper.css (content/paymentDialogWrapper.css)
content/payments/paymentDialogWrapper.js (content/paymentDialogWrapper.js)
content/payments/paymentDialogWrapper.xhtml (content/paymentDialogWrapper.xhtml)
% resource payments %res/payments/
res/payments (res/paymentRequest.*)
res/payments/components/ (res/components/*.css)

View File

@ -40,7 +40,7 @@ function PaymentUIService() {
PaymentUIService.prototype = {
classID: Components.ID("{01f8bd55-9017-438b-85ec-7c15d2b35cdc}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPaymentUIService]),
DIALOG_URL: "chrome://payments/content/paymentDialog.xhtml",
DIALOG_URL: "chrome://payments/content/paymentDialogWrapper.xhtml",
REQUEST_ID_PREFIX: "paymentRequest-",
// nsIPaymentUIService implementation:

View File

@ -113,7 +113,7 @@ function withNewDialogFrame(requestId, taskFn) {
let args = {
gBrowser,
url: `chrome://payments/content/paymentDialog.xhtml?requestId=${requestId}`,
url: `chrome://payments/content/paymentDialogWrapper.xhtml?requestId=${requestId}`,
};
return BrowserTestUtils.withNewTab(args, dialogTabTask);
}

View File

@ -6,9 +6,9 @@
* methods is left to the DOM code.
*/
/* import-globals-from ../../content/paymentDialog.js */
const DIALOG_WRAPPER_URI = "chrome://payments/content/paymentDialogWrapper.js";
let dialogGlobal = {};
Services.scriptloader.loadSubScript("chrome://payments/content/paymentDialog.js", dialogGlobal);
Services.scriptloader.loadSubScript(DIALOG_WRAPPER_URI, dialogGlobal);
/**
* @param {Object} responseData with properties in the order matching `nsIBasicCardResponseData`
@ -28,7 +28,7 @@ add_task(async function test_createBasicCardResponseData_basic() {
expiryYear: "2017",
cardSecurityCode: "0123",
};
let actual = dialogGlobal.PaymentDialog.createBasicCardResponseData(expected);
let actual = dialogGlobal.paymentDialogWrapper.createBasicCardResponseData(expected);
let expectedSerialized = serializeBasicCardResponseData(expected);
Assert.equal(actual.data, expectedSerialized, "Check data");
});
@ -37,7 +37,7 @@ add_task(async function test_createBasicCardResponseData_minimal() {
let expected = {
cardNumber: "1234567890",
};
let actual = dialogGlobal.PaymentDialog.createBasicCardResponseData(expected);
let actual = dialogGlobal.paymentDialogWrapper.createBasicCardResponseData(expected);
let expectedSerialized = serializeBasicCardResponseData(expected);
info(actual.data);
Assert.equal(actual.data, expectedSerialized, "Check data");
@ -50,7 +50,7 @@ add_task(async function test_createBasicCardResponseData_withoutNumber() {
expiryYear: "2017",
cardSecurityCode: "0123",
};
Assert.throws(() => dialogGlobal.PaymentDialog.createBasicCardResponseData(data),
Assert.throws(() => dialogGlobal.paymentDialogWrapper.createBasicCardResponseData(data),
/NS_ERROR_FAILURE/,
"Check cardNumber is required");
});
@ -74,7 +74,7 @@ add_task(async function test_createPaymentAddress_minimal() {
let data = {
country: "CA",
};
let actual = dialogGlobal.PaymentDialog.createPaymentAddress(data);
let actual = dialogGlobal.paymentDialogWrapper.createPaymentAddress(data);
checkAddress(actual, data);
});
@ -95,13 +95,13 @@ add_task(async function test_createPaymentAddress_basic() {
recipient: "John Smith",
phone: "+15195555555",
};
let actual = dialogGlobal.PaymentDialog.createPaymentAddress(data);
let actual = dialogGlobal.paymentDialogWrapper.createPaymentAddress(data);
checkAddress(actual, data);
});
add_task(async function test_createShowResponse_basic() {
let requestId = "876hmbvfd45hb";
dialogGlobal.PaymentDialog.request = {
dialogGlobal.paymentDialogWrapper.request = {
requestId,
};
@ -112,7 +112,7 @@ add_task(async function test_createShowResponse_basic() {
expiryYear: "2099",
cardSecurityCode: "0123",
};
let methodData = dialogGlobal.PaymentDialog.createBasicCardResponseData(cardData);
let methodData = dialogGlobal.paymentDialogWrapper.createBasicCardResponseData(cardData);
let responseData = {
acceptStatus: Ci.nsIPaymentActionResponse.PAYMENT_ACCEPTED,
@ -122,7 +122,7 @@ add_task(async function test_createShowResponse_basic() {
payerEmail: "my.email@example.com",
payerPhone: "+15195555555",
};
let actual = dialogGlobal.PaymentDialog.createShowResponse(responseData);
let actual = dialogGlobal.paymentDialogWrapper.createShowResponse(responseData);
for (let [propName, propVal] of Object.entries(actual)) {
if (typeof(propVal) != "string") {
continue;