3 <title>PaymentRequest show() rejects if doc is not fully active
</title>
4 <link rel=
"help" href=
"https://w3c.github.io/payment-request/#show-method">
5 <script src=
"/resources/testharness.js"></script>
6 <script src=
"/resources/testharnessreport.js"></script>
7 <script src=
"/resources/testdriver.js"></script>
8 <script src=
"/resources/testdriver-vendor.js"></script>
11 const applePay
= Object
.freeze({
12 supportedMethods
: "https://apple.com/apple-pay",
15 merchantIdentifier
: "merchant.com.example",
17 merchantCapabilities
: ["supports3DS"],
18 supportedNetworks
: ["visa"],
21 const validMethod
= Object
.freeze({
22 supportedMethods
: "basic-card",
24 const validMethods
= Object
.freeze([validMethod
, applePay
]);
25 const validAmount
= Object
.freeze({
29 const validTotal
= Object
.freeze({
33 const validDetails
= Object
.freeze({
37 function getLoadedPaymentRequest(iframe
, url
) {
38 return new Promise(resolve
=> {
39 iframe
.addEventListener(
42 const { PaymentRequest
} = iframe
.contentWindow
;
43 const request
= new PaymentRequest(validMethods
, validDetails
);
52 promise_test(async t
=> {
53 const iframe
= document
.createElement("iframe");
54 iframe
.allowPaymentRequest
= true;
55 document
.body
.appendChild(iframe
);
56 // Make a request in the iframe.
57 const request
= await
getLoadedPaymentRequest(
59 "/payment-request/resources/page1.html"
61 const showPromise
= await test_driver
.bless("show payment request", () => {
62 return request
.show();
64 // Navigate the iframe to a new location. Wait for the load event to fire.
65 await
new Promise(resolve
=> {
66 iframe
.addEventListener("load", resolve
);
67 iframe
.src
= "/payment-request/resources/page2.html";
69 await
promise_rejects(
73 "The iframe was navigated away, so showPromise must reject with AbortError"
75 // We are done, so clean up.
77 }, "If a payment request is showing, but its document is navigated away (so no longer fully active), the payment request aborts.");