From 2f79fdd170945fb988568274655c348551e5723f Mon Sep 17 00:00:00 2001 From: Rouslan Solomakhin Date: Mon, 17 Aug 2020 12:41:31 -0700 Subject: [PATCH] [Web Payment] No shipping with secure payment confirmation. Before this patch, invoking PaymentRequest API with secure payment confirmation method identifier and options to request shipping or contact information was considered valid. This patch throws RangeError in PaymentRequest constructor if secure payment confirmation method identifier is requested together with shipping or contact information. After this patch, it's not possible to request secure payment confirmation method together with shipping or contact information. Bug: 2348410 Change-Id: I3e01f9b758645a1653533f41da9688c453199b03 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359554 Reviewed-by: Liquan (Max) Gu Commit-Queue: Rouslan Solomakhin Cr-Commit-Position: refs/heads/master@{#798755} --- .../secure-payment-confirmation.https.html | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/payment-request/secure-payment-confirmation.https.html b/payment-request/secure-payment-confirmation.https.html index 860876e2e9bb75..b8d8372d3cf70c 100644 --- a/payment-request/secure-payment-confirmation.https.html +++ b/payment-request/secure-payment-confirmation.https.html @@ -50,6 +50,96 @@ }], details); }, 'The timeout field is optional.'); +test(() => { + assert_throws_js(RangeError, () => { + new PaymentRequest([{ + supportedMethods: 'secure-payment-confirmation', + data: { + action: 'authenticate', + instrumentId: 'x', + networkData: Uint8Array.from('x', c => c.charCodeAt(0)), + timeout: 60000, + fallbackUrl: 'https://fallback.example/url' + }, + }, {supportedMethods: 'basic-card'}], details); + }); +}, 'Extra payment method not allowed afterward.'); + +test(() => { + assert_throws_js(RangeError, () => { + new PaymentRequest([{supportedMethods: 'basic-card'}, { + supportedMethods: 'secure-payment-confirmation', + data: { + action: 'authenticate', + instrumentId: 'x', + networkData: Uint8Array.from('x', c => c.charCodeAt(0)), + timeout: 60000, + fallbackUrl: 'https://fallback.example/url' + }, + }], details); + }); +}, 'Extra payment method not allowed beforehand.'); + +test(() => { + assert_throws_js(RangeError, () => { + new PaymentRequest([{ + supportedMethods: 'secure-payment-confirmation', + data: { + action: 'authenticate', + instrumentId: 'x', + networkData: Uint8Array.from('x', c => c.charCodeAt(0)), + timeout: 60000, + fallbackUrl: 'https://fallback.example/url' + }, + }], details, {requestShipping: true}); + }); +}, 'Cannot request shipping information.'); + +test(() => { + assert_throws_js(RangeError, () => { + new PaymentRequest([{ + supportedMethods: 'secure-payment-confirmation', + data: { + action: 'authenticate', + instrumentId: 'x', + networkData: Uint8Array.from('x', c => c.charCodeAt(0)), + timeout: 60000, + fallbackUrl: 'https://fallback.example/url' + }, + }], details, {requestPayerName: true}); + }); +}, 'Cannot request payer name.'); + +test(() => { + assert_throws_js(RangeError, () => { + new PaymentRequest([{ + supportedMethods: 'secure-payment-confirmation', + data: { + action: 'authenticate', + instrumentId: 'x', + networkData: Uint8Array.from('x', c => c.charCodeAt(0)), + timeout: 60000, + fallbackUrl: 'https://fallback.example/url' + }, + }], details, {requestPayerEmail: true}); + }); +}, 'Cannot request payer email.'); + +test(() => { + assert_throws_js(RangeError, () => { + new PaymentRequest([{ + supportedMethods: 'secure-payment-confirmation', + data: { + action: 'authenticate', + instrumentId: 'x', + networkData: Uint8Array.from('x', c => c.charCodeAt(0)), + timeout: 60000, + fallbackUrl: 'https://fallback.example/url' + }, + }], details, {requestPayerPhone: true}); + }); +}, 'Cannot request payer phone.'); + test(() => { assert_throws_js(TypeError, () => { new PaymentRequest([{