Skip to content

Commit

Permalink
Reland "[Web Payment] Secure payment confirmation Blink parameters."
Browse files Browse the repository at this point in the history
This is a reland of b772a8f14e0aa806713f9042b2a8e186bcfc103d
Original patch: https://crrev.com/c/2341163
Revert: https://crrev.com/c/2348532

Reason for revert: New WPT test revealed a memory issue in
//third_party/blink/renderer/modules/payments/payments_validators.cc
when serializing data larger than than 1MB into JSON.

Reason for reland: Split out the large data serialization tests into a
separate patches for fixing the JSON serialization issue separately:
 1) https://crrev.com/c/2348411
 2) https://crrev.com/c/2348540
 3) https://crrev.com/c/2346973

Original change's description:
> [Web Payment] Secure payment confirmation Blink parameters.
>
> Before this patch, requesting "secure-payment-confirmation" method in
> PaymentRequest API would not validate the parameters.
>
> This patch adds the "secure-payment-confirmation" parameters to
> PaymentRequest API and validates them, if the
> "SecurePaymentConfirmation" feature is enabled.
>
> After this patch, PaymentRequest API validates the secure payment
> confirmation parameters.
>
> Explainer: https://github.com/rsolomakhin/secure-payment-confirmation
> Feature status: https://chromestatus.com/feature/5702310124584960
> Intent to prototype:
> https://groups.google.com/a/chromium.org/g/blink-dev/c/myUR5gyd5Js/m/iELL67NQAgAJ
>
> Bug: 1110324
> Change-Id: I7a4b6f9da1b3e1d7604bcd9e4733dc789f77ec4b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2341163
> Reviewed-by: Nick Burris <[email protected]>
> Reviewed-by: Kouhei Ueno <[email protected]>
> Auto-Submit: Rouslan Solomakhin <[email protected]>
> Commit-Queue: Rouslan Solomakhin <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#796792}

TBR=ellyjones, nburris, kouhei

Bug: 1110324, 1115091
Change-Id: I05ebdbfe234d3bee8ceb2016dafc5679a9a28ef9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348410
Commit-Queue: Rouslan Solomakhin <[email protected]>
Reviewed-by: Rouslan Solomakhin <[email protected]>
Reviewed-by: Nick Burris <[email protected]>
Cr-Commit-Position: refs/heads/master@{#796954}
  • Loading branch information
rsolomakhin authored and chromium-wpt-export-bot committed Aug 11, 2020
1 parent fa18831 commit b5bae34
Showing 1 changed file with 177 additions and 0 deletions.
177 changes: 177 additions & 0 deletions payment-request/secure-payment-confirmation.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Test for 'secure-payment-confirmation' payment method</title>
<link rel="help" href="https://github.com/rsolomakhin/secure-payment-confirmation">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict';

const details = {total:
{label: 'Total', amount: {value: '0.01', currency: 'USD'}}};

test(() => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
// All valid parameters.
action: 'authenticate',
instrumentId: 'x',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details);
}, 'Valid payment method data does not throw exceptions.');

test(() => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
// Omitted action field.
instrumentId: 'x',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details);
}, 'The action field is optional.');

test(() => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
instrumentId: 'x',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
// Omitted timeout field.
fallbackUrl: 'https://fallback.example/url'
},
}], details);
}, 'The timeout field is optional.');

test(() => {
assert_throws_js(TypeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
// Invalid action parameter.
action: 'authorize',
instrumentId: 'x',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details);
});
}, 'Invalid action parameter throws an exception.');

test(() => {
assert_throws_js(TypeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
// Omitted instrumentId field.
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details);
});
}, 'The instrumentId field is required.');

test(() => {
assert_throws_js(TypeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
instrumentId: 'x',
// Omitted instrumentId field.
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details);
});
}, 'The networkData field is required.');

test(() => {
assert_throws_js(TypeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
instrumentId: 'x',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
// Omitted fallbackUrl field.
},
}], details);
});
}, 'The fallbackUrl field is required.');

test(() => {
assert_throws_js(RangeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
// Empty instrumentId field.
instrumentId: '',
networkData: Uint8Array.from('x', c => c.charCodeAt(0)),
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details);
});
}, 'Empty instrumentId field throws exception.');

test(() => {
assert_throws_js(TypeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
instrumentId: 'x',
// Null networkData field.
networkData: null,
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details);
});
}, 'Null networkData field throws exception.');

test(() => {
assert_throws_js(TypeError, () => {
new PaymentRequest([{
supportedMethods: 'secure-payment-confirmation',
data: {
action: 'authenticate',
instrumentId: 'x',
// Empty networkData field.
networkData: [],
timeout: 60000,
fallbackUrl: 'https://fallback.example/url'
},
}], details);
});
}, 'Empty networkData field throws exception.');

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 longer than 1 hour.
timeout: 1000 * 60 * 60 + 1,
fallbackUrl: 'https://fallback.example/url'
},
}], details);
});
}, 'Timeout longer than 1 hour throws exception.');
</script>

0 comments on commit b5bae34

Please sign in to comment.