Changeset 223962 in webkit


Ignore:
Timestamp:
Oct 25, 2017 11:00:28 AM (7 years ago)
Author:
aestes@apple.com
Message:

[Payment Request] Implement the "user aborts the payment request" algorithm
https://bugs.webkit.org/show_bug.cgi?id=178810

Reviewed by Tim Horton.

Source/WebCore:

  • Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:

(WebCore::ApplePayPaymentHandler::didCancelPaymentSession):

  • Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
  • Modules/paymentrequest/PaymentRequest.cpp:

(WebCore::PaymentRequest::cancel):

  • Modules/paymentrequest/PaymentRequest.h:
  • testing/MockPaymentCoordinator.cpp:

(WebCore::MockPaymentCoordinator::cancelPayment):

  • testing/MockPaymentCoordinator.h:
  • testing/MockPaymentCoordinator.idl:

LayoutTests:

  • http/tests/paymentrequest/payment-request-show-method.https-expected.txt:
  • http/tests/paymentrequest/payment-request-show-method.https.html:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r223959 r223962  
     12017-10-25  Andy Estes  <aestes@apple.com>
     2
     3        [Payment Request] Implement the "user aborts the payment request" algorithm
     4        https://bugs.webkit.org/show_bug.cgi?id=178810
     5
     6        Reviewed by Tim Horton.
     7
     8        * http/tests/paymentrequest/payment-request-show-method.https-expected.txt:
     9        * http/tests/paymentrequest/payment-request-show-method.https.html:
     10
    1112017-10-25  Daniel Bates  <dabates@apple.com>
    212
  • trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https-expected.txt

    r223076 r223962  
    44PASS If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException.
    55PASS If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.
     6PASS If the user aborts the payment request algorithm, then return a promise rejected with an "AbortError" DOMException.
    67
  • trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https.html

    r223163 r223962  
    6666  await promise_rejects(t, "NotSupportedError", acceptPromise);
    6767}, `If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.`);
     68
     69promise_test(async t => {
     70  const request = new PaymentRequest(defaultMethods, defaultDetails);
     71  const acceptPromise = request.show(); // Sets state to "interactive"
     72  internals.mockPaymentCoordinator.cancelPayment();
     73  await promise_rejects(t, "AbortError", acceptPromise);
     74}, `If the user aborts the payment request algorithm, then return a promise rejected with an "AbortError" DOMException.`);
    6875</script>
  • trunk/Source/WebCore/ChangeLog

    r223960 r223962  
     12017-10-25  Andy Estes  <aestes@apple.com>
     2
     3        [Payment Request] Implement the "user aborts the payment request" algorithm
     4        https://bugs.webkit.org/show_bug.cgi?id=178810
     5
     6        Reviewed by Tim Horton.
     7
     8        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
     9        (WebCore::ApplePayPaymentHandler::didCancelPaymentSession):
     10        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
     11        * Modules/paymentrequest/PaymentRequest.cpp:
     12        (WebCore::PaymentRequest::cancel):
     13        * Modules/paymentrequest/PaymentRequest.h:
     14        * testing/MockPaymentCoordinator.cpp:
     15        (WebCore::MockPaymentCoordinator::cancelPayment):
     16        * testing/MockPaymentCoordinator.h:
     17        * testing/MockPaymentCoordinator.idl:
     18
    1192017-10-25  Jer Noble  <jer.noble@apple.com>
    220
  • trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp

    r223945 r223962  
    390390}
    391391
     392void ApplePayPaymentHandler::didCancelPaymentSession()
     393{
     394    m_paymentRequest->cancel();
     395}
     396
    392397} // namespace WebCore
    393398
  • trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h

    r223945 r223962  
    7070    void didSelectShippingContact(const PaymentContact&) final;
    7171    void didSelectPaymentMethod(const PaymentMethod&) final;
    72     void didCancelPaymentSession() final { }
     72    void didCancelPaymentSession() final;
    7373
    7474    PaymentRequest::MethodIdentifier m_identifier;
  • trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp

    r223945 r223962  
    657657}
    658658
     659void PaymentRequest::cancel()
     660{
     661    if (m_state != State::Interactive)
     662        return;
     663
     664    if (m_isUpdating)
     665        return;
     666
     667    m_activePaymentHandler = nullptr;
     668    stop();
     669}
     670
    659671} // namespace WebCore
    660672
  • trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h

    r223945 r223962  
    7474    void accept(const String& methodName, JSC::Strong<JSC::JSObject>&& details, Ref<PaymentAddress>&& shippingAddress, const String& payerName, const String& payerEmail, const String& payerPhone);
    7575    void complete(std::optional<PaymentComplete>&&);
     76    void cancel();
    7677
    7778    // EventTarget
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp

    r223945 r223962  
    131131}
    132132
     133void MockPaymentCoordinator::cancelPayment()
     134{
     135    dispatchIfShowing([mainFrame = makeRef(m_mainFrame)] {
     136        mainFrame->paymentCoordinator().didCancelPaymentSession();
     137        ++hideCount;
     138        ASSERT(showCount == hideCount);
     139    });
     140}
     141
    133142void MockPaymentCoordinator::completePaymentSession(std::optional<PaymentAuthorizationResult>&&)
    134143{
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.h

    r223945 r223962  
    4444    void changePaymentMethod(ApplePayPaymentMethod&&);
    4545    void acceptPayment();
     46    void cancelPayment();
    4647
    4748    void ref() const { }
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.idl

    r223945 r223962  
    3232    void changePaymentMethod(ApplePayPaymentMethod paymentMethod);
    3333    void acceptPayment();
     34    void cancelPayment();
    3435};
Note: See TracChangeset for help on using the changeset viewer.