Backed out changeset b532acf3b5ea (bug 1382092)

This commit is contained in:
Sebastian Hengst 2017-08-06 16:37:18 +02:00
parent 4c09ce6369
commit 20b517f5a7
7 changed files with 79 additions and 59 deletions

View File

@ -41,17 +41,20 @@ function abortPaymentResponse(requestId) {
let abortResponse = Cc["@mozilla.org/dom/payments/payment-abort-action-response;1"].
createInstance(Ci.nsIPaymentAbortActionResponse);
abortResponse.init(requestId, Ci.nsIPaymentActionResponse.ABORT_SUCCEEDED);
paymentSrv.respondPayment(abortResponse.QueryInterface(Ci.nsIPaymentActionResponse));
return abortResponse.QueryInterface(Ci.nsIPaymentActionResponse);
}
function completePaymentResponse(requestId) {
let completeResponse = Cc["@mozilla.org/dom/payments/payment-complete-action-response;1"].
createInstance(Ci.nsIPaymentCompleteActionResponse);
completeResponse.init(requestId, Ci.nsIPaymentActionResponse.COMPLETE_SUCCEEDED);
paymentSrv.respondPayment(completeResponse.QueryInterface(Ci.nsIPaymentActionResponse));
return completeResponse;
}
const detailedResponseUI = {
canMakePayment: function(requestId) {
return null;
},
showPayment: function(requestId) {
try {
basiccardResponseData.initData("Bill A. Pacheco", // cardholderName
@ -70,16 +73,20 @@ const detailedResponseUI = {
"Bill A. Pacheco", // payer name
"", // payer email
""); // payer phone
paymentSrv.respondPayment(showResponse.QueryInterface(Ci.nsIPaymentActionResponse));
return showResponse;
},
abortPayment: abortPaymentResponse,
completePayment: completePaymentResponse,
updatePayment: function(requestId) {
return null;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPaymentUIService]),
};
const simpleResponseUI = {
canMakePayment: function(requestId) {
return null;
},
showPayment: function(requestId) {
try {
basiccardResponseData.initData("", // cardholderName
@ -98,11 +105,12 @@ const simpleResponseUI = {
"Bill A. Pacheco", // payer name
"", // payer email
""); // payer phone
paymentSrv.respondPayment(showResponse.QueryInterface(Ci.nsIPaymentActionResponse));
return showResponse;
},
abortPayment: abortPaymentResponse,
completePayment: completePaymentResponse,
updatePayment: function(requestId) {
return null;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPaymentUIService]),
};

View File

@ -0,0 +1,39 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const DummyUIService = {
canMakePayment: function(requestId) {
let canMakeResponse = Cc["@mozilla.org/dom/payments/payment-canmake-action-response;1"].
createInstance(Ci.nsIPaymentCanMakeActionResponse);
canMakeResponse.init(requestId, true);
return canMakeResponse.QueryInterface(Ci.nsIPaymentActionResponse);
},
showPayment: function(requestId) {
return null;
},
abortPayment: function(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: function(requestId) {
return null;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPaymentUIService]),
};
const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"].getService(Ci.nsIPaymentRequestService);
paymentSrv.setTestingUIService(DummyUIService.QueryInterface(Ci.nsIPaymentUIService));
addMessageListener('teardown', function() {
paymentSrv.cleanup();
paymentSrv.setTestingUIService(null);
sendAsyncMessage('teardown-complete');
});

View File

@ -1,16 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"].getService(Ci.nsIPaymentRequestService);
addMessageListener("teardown", function() {
paymentSrv.cleanup();
paymentSrv.setTestingUIService(null);
sendAsyncMessage('teardown-complete');
});

View File

@ -33,16 +33,21 @@ shippingAddress.init("USA", // country
const NormalUIService = {
shippingOptionChanged: false,
canMakePayment: function(requestId) {
return null;
},
showPayment: function(requestId) {
paymentSrv.changeShippingAddress(requestId, shippingAddress);
return null;
},
abortPayment: function(requestId) {
return null;
},
completePayment: function(requestId) {
let completeResponse = Cc["@mozilla.org/dom/payments/payment-complete-action-response;1"].
createInstance(Ci.nsIPaymentCompleteActionResponse);
completeResponse.init(requestId, Ci.nsIPaymentActionResponse.COMPLETE_SUCCEEDED);
paymentSrv.respondPayment(completeResponse.QueryInterface(Ci.nsIPaymentActionResponse));
return completeResponse;
},
updatePayment: function(requestId) {
let showResponse = null;
@ -82,13 +87,16 @@ const NormalUIService = {
"Bill A. Pacheco", // payer name
"", // payer email
""); // payer phone
paymentSrv.respondPayment(showResponse.QueryInterface(Ci.nsIPaymentActionResponse));
}
return showResponse;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPaymentUIService]),
};
const RejectUIService = {
canMakePayment: function(requestId) {
return null;
},
showPayment: function(requestId) {
const responseData = Cc["@mozilla.org/dom/payments/general-response-data;1"].
createInstance(Ci.nsIGeneralResponseData);
@ -107,24 +115,34 @@ const RejectUIService = {
"", // payer name
"", // payer email
""); // payer phone
paymentSrv.respondPayment(showResponse.QueryInterface(Ci.nsIPaymentActionResponse));
return showResponse;
},
abortPayment: function(requestId) {
return null;
},
completePayment: function(requestId) {
return null;
},
updatePayment: function(requestId) {
return null;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPaymentUIService]),
};
const ErrorUIService = {
canMakePayment: function(requestId) {
return null;
},
showPayment: function(requestId) {
paymentSrv.changeShippingOption(requestId, "");
return null;
},
abortPayment: function(requestId) {
return null;
},
completePayment: function(requestId) {
return null;
},
updatePayment: function(requestId) {
let payRequest = paymentSrv.getPaymentRequestById(requestId);
@ -150,7 +168,8 @@ const ErrorUIService = {
"", // payer name
"", // payer email
""); // payer phone
paymentSrv.respondPayment(showResponse.QueryInterface(Ci.nsIPaymentActionResponse));
return showResponse;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPaymentUIService]),

View File

@ -5,8 +5,8 @@ scheme = https
support-files =
simple_payment_request.html
BasiccardChromeScript.js
CanMakePaymentChromeScript.js
ConstructorChromeScript.js
GeneralChromeScript.js
ShowPaymentChromeScript.js
[test_abortPayment.html]

View File

@ -13,9 +13,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345367
"use strict";
SimpleTest.waitForExplicitFinish();
var gUrl = SimpleTest.getTestFileURL('GeneralChromeScript.js');
var gScript = SpecialPowers.loadChromeScript(gUrl);
const defaultMethods = [{
supportedMethods: "basic-card",
}];
@ -57,19 +54,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345367
});
}
function teardown() {
gScript.addMessageListener("teardown-complete", function teardownCompleteHandler() {
gScript.removeMessageListener("teardown-complete", teardownCompleteHandler);
gScript.destroy();
SimpleTest.finish();
});
gScript.sendAsyncMessage("teardown");
}
function runTests() {
testBeforeShow()
.then(testAfterShow)
.then(teardown)
.then(SimpleTest.finish)
.catch( e => {
ok(false, "Unexpected error: " + e.name);
SimpleTest.finish();

View File

@ -13,7 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345365
"use strict";
SimpleTest.waitForExplicitFinish();
var gUrl = SimpleTest.getTestFileURL('GeneralChromeScript.js');
var gUrl = SimpleTest.getTestFileURL('CanMakePaymentChromeScript.js');
var gScript = SpecialPowers.loadChromeScript(gUrl);
const defaultMethods = [{
@ -29,28 +29,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345365
},
};
const nonsupportedMethods = [{
supportedMethods: "testing-payment-method",
}];
function testDefaultAction() {
return new Promise((resolve, reject) => {
const payRequest = new PaymentRequest(nonsupportedMethods, defaultDetails);
payRequest.canMakePayment().then((result) => {
ok(!result, "Should be resolved with false, but got " + result + ".");
resolve();
}).catch((err) => {
ok(false, "Expected no error, but got '" + err.name +"'.");
resolve();
});
});
}
function testSimple() {
return new Promise((resolve, reject) => {
const payRequest = new PaymentRequest(defaultMethods, defaultDetails);
payRequest.canMakePayment().then((result) => {
ok(result, "Should be resolved with true, but got " + result + ".");
ok(result, "Should be resolved with true, but got false.");
resolve();
}).catch((err) => {
ok(false, "Expected no error, but got '" + err.name +"'.");
@ -135,8 +118,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345365
}
function runTests() {
testDefaultAction()
.then(testSimple)
testSimple()
.then(testAfterShow)
.then(testAfterAbort)
.then(testNotAllowed)