<!DOCTYPE html> <meta charset="utf-8" />
<title>Warn when errorFields don't match request[[options]]</title>
<link rel="help" href="https://github.com/w3c/payment-request/pull/807" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="helpers.js"></script>
<script>
test(() => {
assert_true(
"retry" in PaymentResponse.prototype,
"retry must be in prototype"
);
assert_true(
PaymentResponse.prototype.retry instanceof Function,
"retry must be a function"
);
}, "PaymentResponse.prototype must have a retry() function (smoke test).");
const defaultOptions = {
requestPayerName: false,
requestPayerEmail: false,
requestPayerPhone: false,
requestShipping: false,
};
function testShowWarning(button, errorFields) {
button.disabled = true;
promise_test(async () => {
const { response } = await getPaymentRequestResponse(defaultOptions);
await response.retry(errorFields);
await response.complete();
});
}
</script>
<h2>Manual Tests - Please run in order!</h2>
<p>
Please open the developer console. Each of the tests below should generate a
warning in the developer console.
</p>
<p>When presented with the payment sheet, hit pay twice.</p>
<ol>
<li>
<button onclick="testShowWarning(this, {payer: {name: 'Dont show this'}});">
Show warning if `requestPayerName` if false, and `errorFields.payer.name` is
present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {payer: {email: 'Dont show this'}});"
>
Show warning if `requestPayerEmail` if false, and `errorFields.payer.email`
is present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {payer: {phone: 'Dont show this'}});"
>
Show warning if `requestPayerPhone` if false, and `errorFields.payer.phone`
is present.
</button>
</li>
<li>
<button onclick="testShowWarning(this, {shippingAddress: {}});">
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {addressLine: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.addressLine` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {city: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.city` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {country: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.country` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {dependentLocality: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.dependentLocality` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {organization: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.organization` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {phone: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.phone` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {postalCode: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.postalCode` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {recipient: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.recipient` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {region: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.region` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {regionCode: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.regionCode` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {sortingCode: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.sortingCode` member present.
</button>
</li>
<li><button onclick="done()">Done!</button></li>
</ol>