|
4 | 4 | rel="help"
|
5 | 5 | href="https://w3c.github.io/browser-payment-api/#dfn-payment-request-is-showing"
|
6 | 6 | />
|
| 7 | +<meta name="timeout" content="long"> |
7 | 8 | <script src="/resources/testharness.js"></script>
|
8 | 9 | <script src="/resources/testharnessreport.js"></script>
|
9 | 10 | <script src="/resources/testdriver-vendor.js"></script>
|
|
399 | 400 | }, "Navigating an iframe as a nested browsing context sets 'payment request is showing boolean' to false.");
|
400 | 401 |
|
401 | 402 | promise_test(async t => {
|
402 |
| - const [popupWindow, popupRequest, showPromise] = await test_driver.bless( |
403 |
| - 'test navigating popup after show()', |
404 |
| - async () => { |
405 |
| - const popupWindow = await loadPopupInsideUserGesture(); |
406 |
| - const popupRequest = new popupWindow.PaymentRequest(methods, details); |
407 |
| - return [popupWindow, popupRequest, popupRequest.show()]; |
408 |
| - }, |
409 |
| - ); |
| 403 | + const [popupWindow, popupRequest, popupShowPromise] = |
| 404 | + await test_driver.bless( |
| 405 | + 'trigger payment in a popup window', |
| 406 | + async () => { |
| 407 | + const popupWindow = await loadPopupInsideUserGesture(); |
| 408 | + const popupRequest = new popupWindow.PaymentRequest(methods, details); |
| 409 | + return [popupWindow, popupRequest, popupRequest.show()]; |
| 410 | + }); |
410 | 411 |
|
411 | 412 | // We navigate away, causing the payment sheet to close
|
412 | 413 | // and the request is showing boolean to become false.
|
413 | 414 | popupWindow.location = 'blank.html?abc=123';
|
414 | 415 | await new Promise(resolve => (popupWindow.onload = resolve));
|
415 |
| - await promise_rejects( |
416 |
| - t, |
417 |
| - 'AbortError', |
418 |
| - showPromise, |
419 |
| - 'Navigating away must cause the showPromise to reject with an AbortError', |
420 |
| - ); |
421 |
| - popupWindow.close(); |
422 | 416 |
|
423 |
| - // Now we should be ok to spin up a new payment request. |
| 417 | + // Don't wait for |popupShowPromise| to reject because it may never do |
| 418 | + // (see https://github.com/w3c/payment-request/issues/872). Instead, try |
| 419 | + // to spin up a new payment request and make sure it succeeds. |
424 | 420 | const request = new window.PaymentRequest(methods, details);
|
425 |
| - request.show(); |
426 |
| - await request.abort(); |
| 421 | + const [showPromise] = await test_driver.bless( |
| 422 | + 'trigger payment in main window', |
| 423 | + () => { |
| 424 | + return [request.show()]; |
| 425 | + }); |
| 426 | + |
| 427 | + // If a payment sheet fails to show, it should reject immediately. If it |
| 428 | + // hasn't rejected in 1 second, then the test has passed. |
| 429 | + t.step_timeout(async () => { |
| 430 | + // We're done. Clean up. |
| 431 | + popupWindow.close(); |
| 432 | + await request.abort(); |
| 433 | + t.done(); |
| 434 | + }, 1000); |
| 435 | + |
| 436 | + // If the navigation in popup window failed to close the original payment |
| 437 | + // sheet there, |showPromise| should reject immediately and this indicates |
| 438 | + // a failure of this test. |
| 439 | + await showPromise.then(() => { |
| 440 | + assert_true(false, |
| 441 | + "Second payment sheet should be pending but is resolved."); |
| 442 | + }) |
| 443 | + .catch(e => { |
| 444 | + assert_true(false, |
| 445 | + "Second payment sheet should be pending but is rejected."); |
| 446 | + }); |
427 | 447 | }, "Navigating a popup as a nested browsing context sets 'payment request is showing boolean' to false.");
|
428 | 448 | </script>
|
429 | 449 | </body>
|
0 commit comments