forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
manual test for PaymentResponse.shippingAddress attr (web-platform-te…
- Loading branch information
1 parent
0cb47cb
commit 8197622
Showing
2 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
payment-request/payment-response/shippingAddress-attribute-manual.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<!doctype html> | ||
<meta charset="utf8"> | ||
<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentresponse-shippingaddress"> | ||
<title> | ||
PaymentResponse.prototype.shippingAddress | ||
</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="helpers.js"></script> | ||
<script> | ||
async function checkNullShippingAddress(button, options) { | ||
button.disabled = true; | ||
const { request, response } = await getPaymentRequestResponse(options); | ||
await response.complete(); | ||
test(() => { | ||
assert_equals( | ||
response.shippingAddress, | ||
null, | ||
"Expected response.shippingAddress to be null" | ||
); | ||
assert_equals( | ||
request.shippingAddress, | ||
null, | ||
"Expected request.shippingAddress to be null" | ||
); | ||
}, button.textContent.trim()); | ||
} | ||
|
||
async function runManualTest(button, options = {}, expected = {}, id) { | ||
button.disabled = true; | ||
const { request, response } = await getPaymentRequestResponse(options, id); | ||
await response.complete(); | ||
test(() => { | ||
assert_equals(response.requestId, request.id, `Expected ids to match`); | ||
const { shippingAddress: addr } = request; | ||
assert_true( | ||
addr instanceof PaymentAddress, | ||
"Expect instance of PaymentAddress" | ||
); | ||
try { | ||
addr.toJSON(); | ||
} catch (err) { | ||
assert_unreached( | ||
`Unexpected exception calling PaymentAddress.toJSON(): ${err}` | ||
); | ||
} | ||
if (expected.shippingAddress === null) { | ||
return; | ||
} | ||
assert_equals(addr.country, "AF", "Expected AF for country"); | ||
assert_true( | ||
addr.addressLine instanceof Array, | ||
"Expected addressLine to be an array" | ||
); | ||
assert_equals( | ||
addr.addressLine.toString(), | ||
"1 wpt street", | ||
"Expected '1 wpt street' for addressLine" | ||
); | ||
assert_equals(addr.city, "Kabul", "Expected city to be Kabul"); | ||
assert_equals(addr.postalCode, "1001", "Expect postalCode to be 1001"); | ||
assert_equals(addr.recipient, "web platform test"); | ||
}, button.textContent.trim()); | ||
} | ||
</script> | ||
<h2>shippingAddress attribute</h2> | ||
<p> | ||
When prompted, please enter "web platform test" as recipient, at address "1 wpt street" in "Kabul, Afghanistan", zip/postal code 1001. | ||
</p> | ||
<ol> | ||
<li> | ||
<button onclick="checkNullShippingAddress(this, undefined)"> | ||
If options is undefined, then shippingAddress must be null. | ||
</button> | ||
</li> | ||
<li> | ||
<button onclick="checkNullShippingAddress(this, {})"> | ||
If the requestShipping member is missing, then shippingAddress must be null. | ||
</button> | ||
</li> | ||
<li> | ||
<button onclick="checkNullShippingAddress(this, {requestShipping: false})"> | ||
If the requestShipping member is false, then shippingAddress must be null. | ||
</button> | ||
</li> | ||
<li> | ||
<button onclick="runManualTest(this, {requestShipping: true}).then(done)"> | ||
If the requestShipping member is true, then shippingAddress must be "1 wpt street" in "Kabul, Afghanistan", zip code 1001. | ||
</button> | ||
</li> | ||
</ol> |