|
153 | 153 | // We first show a payment request via the the top level browsing context,
|
154 | 154 | // windowRequest.show() sets "is showing boolean" to true. Then we try to
|
155 | 155 | // show a payment request in the iframe, which should reject.
|
156 |
| - const [iframeShowPromise] = await test_driver.bless( |
| 156 | + const [windowShowPromise, iframeShowPromise] = await test_driver.bless( |
157 | 157 | "testing iframe show() blocked by payment sheet in top window",
|
158 | 158 | () => {
|
159 |
| - windowRequest.show(); |
160 |
| - return [iframeRequest.show()]; |
| 159 | + return [windowRequest.show(), iframeRequest.show()]; |
161 | 160 | },
|
162 | 161 | );
|
163 | 162 |
|
|
170 | 169 |
|
171 | 170 | // Cleanup
|
172 | 171 | await windowRequest.abort();
|
| 172 | + await promise_rejects( |
| 173 | + t, |
| 174 | + "AbortError", |
| 175 | + windowShowPromise, |
| 176 | + "The window payment request should be aborted by test.", |
| 177 | + ); |
173 | 178 | iframe.remove();
|
174 | 179 | }, "An iframe cannot show a payment request if the top-level window is already showing one.");
|
175 | 180 |
|
|
200 | 205 | ];
|
201 | 206 | },
|
202 | 207 | );
|
203 |
| - await popupRequest.abort(); |
204 |
| - popupWindow.close(); |
205 | 208 |
|
206 | 209 | await promise_rejects(
|
207 | 210 | t,
|
208 | 211 | "AbortError",
|
209 | 212 | windowShowPromise,
|
210 | 213 | "Expected window's showPromise to reject, request is already showing",
|
211 | 214 | );
|
| 215 | + |
| 216 | + await popupRequest.abort(); |
| 217 | + await promise_rejects( |
| 218 | + t, |
| 219 | + "AbortError", |
| 220 | + popupShowPromise, |
| 221 | + "Expected popupShowPromise to be aborted by test.", |
| 222 | + ); |
| 223 | + popupWindow.close(); |
212 | 224 | }, "Using a popup window prevents the top-browsing context from showing a payment request");
|
213 | 225 |
|
214 | 226 | promise_test(async t => {
|
|
263 | 275 | );
|
264 | 276 |
|
265 | 277 | await windowRequest.abort();
|
| 278 | + await promise_rejects( |
| 279 | + t, |
| 280 | + "AbortError", |
| 281 | + windowShowPromise, |
| 282 | + "Expect window promise to be aborted by test." |
| 283 | + ); |
266 | 284 | popupWindow.close();
|
267 | 285 | iframe.remove();
|
268 | 286 | }, "Given multiple nested browsing contexts, and window calls show() first, other nested browsing contexts can't show a request.");
|
|
313 | 331 | );
|
314 | 332 |
|
315 | 333 | await popupRequest.abort();
|
| 334 | + await promise_rejects( |
| 335 | + t, |
| 336 | + "AbortError", |
| 337 | + popupShowPromise, |
| 338 | + "Expected popupShowPromise to be aborted by test.", |
| 339 | + ); |
316 | 340 | popupWindow.close();
|
317 | 341 | iframe.remove();
|
318 | 342 | }, "Given multiple nested browsing contexts, and popup calls show() first, other nested browsing contexts can't show a request.");
|
|
368 | 392 | );
|
369 | 393 |
|
370 | 394 | await iframeRequest.abort();
|
| 395 | + await promise_rejects( |
| 396 | + t, |
| 397 | + "AbortError", |
| 398 | + iframeShowPromise, |
| 399 | + "Expected iframeShowPromise to be aborted by test." |
| 400 | + ); |
371 | 401 | popupWindow.close();
|
372 | 402 | iframe.remove();
|
373 | 403 | }, "Given multiple nested browsing contexts, and an iframe calls show() first, other nested browsing contexts can't show a request.");
|
|
395 | 425 |
|
396 | 426 | // Now we should be ok to spin up a new payment request
|
397 | 427 | const request = new window.PaymentRequest(methods, details);
|
398 |
| - const showPromise = request.show(); |
399 |
| - await request.abort(); |
| 428 | + const [showPromise] = await test_driver.bless( |
| 429 | + "start a new payment request", |
| 430 | + () => { |
| 431 | + return [request.show()]; |
| 432 | + }); |
| 433 | + |
| 434 | + // If a payment sheet fails to show, it should reject immediately. If it |
| 435 | + // hasn't rejected in 1 second, then the test has passed. |
| 436 | + t.step_timeout(async () => { |
| 437 | + // We're done. Clean up. |
| 438 | + await request.abort(); |
| 439 | + t.done(); |
| 440 | + }); |
| 441 | + |
| 442 | + // If the navigation in iframe failed to close the original payment sheet |
| 443 | + // there, |showPromise| should reject immediately and this indicates a |
| 444 | + // failure of this test. |
| 445 | + await showPromise.then(() => { |
| 446 | + assert_true(false, |
| 447 | + "Second payment sheet should be pending but is resolved."); |
| 448 | + }) |
| 449 | + .catch(e => { |
| 450 | + assert_true(false, |
| 451 | + "Second payment sheet should be pending but is rejected." + e.message); |
| 452 | + }); |
400 | 453 | }, "Navigating an iframe as a nested browsing context sets 'payment request is showing boolean' to false.");
|
401 | 454 |
|
402 | 455 | promise_test(async t => {
|
|
0 commit comments