1 <!DOCTYPE html
> <meta charset=
"utf-8" />
2 <title>Warn when errorFields don't match request[[options]]
</title>
3 <link rel=
"help" href=
"https://github.com/w3c/payment-request/pull/807" />
4 <script src=
"/resources/testharness.js"></script>
5 <script src=
"/resources/testharnessreport.js"></script>
6 <script src=
"helpers.js"></script>
10 "retry" in PaymentResponse
.prototype,
11 "retry must be in prototype"
14 PaymentResponse
.prototype.retry
instanceof Function
,
15 "retry must be a function"
17 }, "PaymentResponse.prototype must have a retry() function (smoke test).");
19 const defaultOptions
= {
20 requestPayerName
: false,
21 requestPayerEmail
: false,
22 requestPayerPhone
: false,
23 requestShipping
: false,
25 function testShowWarning(button
, errorFields
) {
26 button
.disabled
= true;
27 promise_test(async () => {
28 const { response
} = await
getPaymentRequestResponse(defaultOptions
);
29 await response
.retry(errorFields
);
30 await response
.complete();
34 <h2>Manual Tests - Please run in order!
</h2>
36 Please open the developer console. Each of the tests below should generate a
37 warning in the developer console.
39 <p>When presented with the payment sheet, hit pay twice.
</p>
42 <button onclick=
"testShowWarning(this, {payer: {name: 'Dont show this'}});">
43 Show warning if `requestPayerName` if false, and `errorFields.payer.name` is
49 onclick=
"testShowWarning(this, {payer: {email: 'Dont show this'}});"
51 Show warning if `requestPayerEmail` if false, and `errorFields.payer.email`
57 onclick=
"testShowWarning(this, {payer: {phone: 'Dont show this'}});"
59 Show warning if `requestPayerPhone` if false, and `errorFields.payer.phone`
64 <button onclick=
"testShowWarning(this, {shippingAddress: {}});">
65 Show warning if `requestShipping` if false, and
66 `errorFields.shippingAddress` member present.
71 onclick=
"testShowWarning(this, {shippingAddress: {addressLine: 'Dont show this'}});"
73 Show warning if `requestShipping` if false, and
74 `errorFields.shippingAddress.addressLine` member present.
79 onclick=
"testShowWarning(this, {shippingAddress: {city: 'Dont show this'}});"
81 Show warning if `requestShipping` if false, and
82 `errorFields.shippingAddress.city` member present.
87 onclick=
"testShowWarning(this, {shippingAddress: {country: 'Dont show this'}});"
89 Show warning if `requestShipping` if false, and
90 `errorFields.shippingAddress.country` member present.
95 onclick=
"testShowWarning(this, {shippingAddress: {dependentLocality: 'Dont show this'}});"
97 Show warning if `requestShipping` if false, and
98 `errorFields.shippingAddress.dependentLocality` member present.
103 onclick=
"testShowWarning(this, {shippingAddress: {organization: 'Dont show this'}});"
105 Show warning if `requestShipping` if false, and
106 `errorFields.shippingAddress.organization` member present.
111 onclick=
"testShowWarning(this, {shippingAddress: {phone: 'Dont show this'}});"
113 Show warning if `requestShipping` if false, and
114 `errorFields.shippingAddress.phone` member present.
119 onclick=
"testShowWarning(this, {shippingAddress: {postalCode: 'Dont show this'}});"
121 Show warning if `requestShipping` if false, and
122 `errorFields.shippingAddress.postalCode` member present.
127 onclick=
"testShowWarning(this, {shippingAddress: {recipient: 'Dont show this'}});"
129 Show warning if `requestShipping` if false, and
130 `errorFields.shippingAddress.recipient` member present.
135 onclick=
"testShowWarning(this, {shippingAddress: {region: 'Dont show this'}});"
137 Show warning if `requestShipping` if false, and
138 `errorFields.shippingAddress.region` member present.
143 onclick=
"testShowWarning(this, {shippingAddress: {regionCode: 'Dont show this'}});"
145 Show warning if `requestShipping` if false, and
146 `errorFields.shippingAddress.regionCode` member present.
151 onclick=
"testShowWarning(this, {shippingAddress: {sortingCode: 'Dont show this'}});"
153 Show warning if `requestShipping` if false, and
154 `errorFields.shippingAddress.sortingCode` member present.
157 <li><button onclick=
"done()">Done!
</button></li>