Skip to content

Commit

Permalink
[PaymentRequest] Implement activationless show
Browse files Browse the repository at this point in the history
Implement the PaymentRequestAllowOneActivationlessShow feature which
allows one call to PaymentRequest.show() without a user activation.

This mostly reuses the activationless show behaviour implemented for
SPC[1], by adding a separate feature flag that expands the behaviour
to PaymentRequest calls in general.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/4479975

Bug: 1454204
Change-Id: Ia144c4a1b3663e1a7f8a826d789fa05a055a7477
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4672598
Reviewed-by: Stephen McGruer <[email protected]>
Commit-Queue: Nick Burris <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1171890}
  • Loading branch information
Nick Burris authored and chromium-wpt-export-bot committed Jul 18, 2023
1 parent 4ac7a0a commit 4a58a74
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
11 changes: 1 addition & 10 deletions payment-request/payment-request-show-method.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@
},
});

promise_test(async (t) => {
const request = new PaymentRequest(defaultMethods, defaultDetails);
const acceptPromise = request.show();
await promise_rejects_dom(t, "SecurityError", acceptPromise);
}, `Calling show() without being triggered by user interaction throws`);

promise_test(async (t) => {
const request = new PaymentRequest(defaultMethods, defaultDetails);
await promise_rejects_dom(t, "SecurityError", request.show());
Expand All @@ -63,11 +57,8 @@
await test_driver.bless();
const acceptPromise1 = request1.show();

// User activation consumed, so...
const request2 = new PaymentRequest(defaultMethods, defaultDetails);
await promise_rejects_dom(t, "SecurityError", request2.show());

// Payment request already showing, so...
const request2 = new PaymentRequest(defaultMethods, defaultDetails);
await test_driver.bless();
await promise_rejects_dom(t, "AbortError", request2.show());

Expand Down
12 changes: 3 additions & 9 deletions payment-request/show-consume-activation.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,16 @@
promise_test(async t => {
const pr = new PaymentRequest(defaultMethods, defaultDetails);

// Not activated by user gesture, so not allowed!
await promise_rejects_dom(t, "SecurityError", pr.show());

await test_driver.bless("Calls show() method");

// Activated by user gesture, so all good.
const showPromise = pr.show();

// The activation has been consumed, so calling show() again would require
// a new gesture.
await promise_rejects_dom(t, "InvalidStateError", pr.show());
// The activation has been consumed.
assert_false(navigator.userActivation.isActive);

// Abort the payment request
pr.abort()
await promise_rejects_dom(t, "AbortError", showPromise);
}, "Calling share consumes user activation");
}, "Calling show consumes user activation, if present");
</script>
</body>
</html>

0 comments on commit 4a58a74

Please sign in to comment.