Commit d02cba30 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Payments] Reject canMakePayment() after show().

Spec:
https://w3c.github.io/payment-request/#canmakepayment()-method

"If request.[[state]] is not "created", then return a promise rejected
with an "InvalidStateError" DOMException."

(After show() was called, request.[[state]] is "interactive".)

Bug: 766176
Change-Id: I05a0804bc8324a2a65dd5e3128422507269cf117
Reviewed-on: https://chromium-review.googlesource.com/671610Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502896}
parent 6412d357
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Request failed
FAIL If request.[[state]] is "created", then return a promise that resolves to true for known method. assert_equals: if it throws, then it must be a NotAllowedError. expected "NotAllowedError" but got "UnknownError"
FAIL If request.[[state]] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException. promise_test: Unhandled rejection with value: object "InvalidStateError: Never called show(), so nothing to abort"
FAIL If request.[[state]] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException. promise_test: Unhandled rejection with value: object "UnknownError: Request failed"
FAIL If request.[[state]] is "closed", then return a promise rejected with an "InvalidStateError" DOMException. promise_test: Unhandled rejection with value: object "UnknownError: Request failed"
FAIL If payment method identifier and serialized parts are supported, resolve promise with true. promise_test: Unhandled rejection with value: object "UnknownError: Request failed"
FAIL If payment method identifier is unknown, resolve promise with false. assert_true: Unexpected exception testing method this-is-not-supported, expected false. See error console. expected true got false
......
......@@ -884,8 +884,8 @@ ScriptPromise PaymentRequest::abort(ScriptState* script_state) {
}
ScriptPromise PaymentRequest::canMakePayment(ScriptState* script_state) {
if (!payment_provider_.is_bound() || can_make_payment_resolver_ ||
!script_state->ContextIsValid()) {
if (!payment_provider_.is_bound() || show_resolver_ ||
can_make_payment_resolver_ || !script_state->ContextIsValid()) {
return ScriptPromise::RejectWithDOMException(
script_state, DOMException::Create(kInvalidStateError,
"Cannot query payment request"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment