Diff
Modified: trunk/LayoutTests/ChangeLog (223961 => 223962)
--- trunk/LayoutTests/ChangeLog 2017-10-25 17:42:20 UTC (rev 223961)
+++ trunk/LayoutTests/ChangeLog 2017-10-25 18:00:28 UTC (rev 223962)
@@ -1,3 +1,13 @@
+2017-10-25 Andy Estes <[email protected]>
+
+ [Payment Request] Implement the "user aborts the payment request" algorithm
+ https://bugs.webkit.org/show_bug.cgi?id=178810
+
+ Reviewed by Tim Horton.
+
+ * http/tests/paymentrequest/payment-request-show-method.https-expected.txt:
+ * http/tests/paymentrequest/payment-request-show-method.https.html:
+
2017-10-25 Daniel Bates <[email protected]>
Attempt to fix flaky test fast/writing-mode/english-bt-text-with-spelling-marker.html following r223938
Modified: trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https-expected.txt (223961 => 223962)
--- trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https-expected.txt 2017-10-25 17:42:20 UTC (rev 223961)
+++ trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https-expected.txt 2017-10-25 18:00:28 UTC (rev 223962)
@@ -3,4 +3,5 @@
PASS Throws if the promise [[state]] is not "created"
PASS If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException.
PASS If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.
+PASS If the user aborts the payment request algorithm, then return a promise rejected with an "AbortError" DOMException.
Modified: trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https.html (223961 => 223962)
--- trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https.html 2017-10-25 17:42:20 UTC (rev 223961)
+++ trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https.html 2017-10-25 18:00:28 UTC (rev 223962)
@@ -65,4 +65,11 @@
const acceptPromise = request.show();
await promise_rejects(t, "NotSupportedError", acceptPromise);
}, `If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.`);
+
+promise_test(async t => {
+ const request = new PaymentRequest(defaultMethods, defaultDetails);
+ const acceptPromise = request.show(); // Sets state to "interactive"
+ internals.mockPaymentCoordinator.cancelPayment();
+ await promise_rejects(t, "AbortError", acceptPromise);
+}, `If the user aborts the payment request algorithm, then return a promise rejected with an "AbortError" DOMException.`);
</script>
Modified: trunk/Source/WebCore/ChangeLog (223961 => 223962)
--- trunk/Source/WebCore/ChangeLog 2017-10-25 17:42:20 UTC (rev 223961)
+++ trunk/Source/WebCore/ChangeLog 2017-10-25 18:00:28 UTC (rev 223962)
@@ -1,3 +1,21 @@
+2017-10-25 Andy Estes <[email protected]>
+
+ [Payment Request] Implement the "user aborts the payment request" algorithm
+ https://bugs.webkit.org/show_bug.cgi?id=178810
+
+ Reviewed by Tim Horton.
+
+ * 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:
+
2017-10-25 Jer Noble <[email protected]>
Autoplay muted videos still stop playback of other streaming apps in the background
Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (223961 => 223962)
--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2017-10-25 17:42:20 UTC (rev 223961)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2017-10-25 18:00:28 UTC (rev 223962)
@@ -389,6 +389,11 @@
m_paymentRequest->dispatchEvent(event.get());
}
+void ApplePayPaymentHandler::didCancelPaymentSession()
+{
+ m_paymentRequest->cancel();
+}
+
} // namespace WebCore
#endif // ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h (223961 => 223962)
--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h 2017-10-25 17:42:20 UTC (rev 223961)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h 2017-10-25 18:00:28 UTC (rev 223962)
@@ -69,7 +69,7 @@
void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) final;
void didSelectShippingContact(const PaymentContact&) final;
void didSelectPaymentMethod(const PaymentMethod&) final;
- void didCancelPaymentSession() final { }
+ void didCancelPaymentSession() final;
PaymentRequest::MethodIdentifier m_identifier;
Ref<PaymentRequest> m_paymentRequest;
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (223961 => 223962)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp 2017-10-25 17:42:20 UTC (rev 223961)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp 2017-10-25 18:00:28 UTC (rev 223962)
@@ -656,6 +656,18 @@
std::exchange(m_activePaymentHandler, nullptr)->complete(WTFMove(result));
}
+void PaymentRequest::cancel()
+{
+ if (m_state != State::Interactive)
+ return;
+
+ if (m_isUpdating)
+ return;
+
+ m_activePaymentHandler = nullptr;
+ stop();
+}
+
} // namespace WebCore
#endif // ENABLE(PAYMENT_REQUEST)
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h (223961 => 223962)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h 2017-10-25 17:42:20 UTC (rev 223961)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h 2017-10-25 18:00:28 UTC (rev 223962)
@@ -73,6 +73,7 @@
ExceptionOr<void> updateWith(Event&, Ref<DOMPromise>&&);
void accept(const String& methodName, JSC::Strong<JSC::JSObject>&& details, Ref<PaymentAddress>&& shippingAddress, const String& payerName, const String& payerEmail, const String& payerPhone);
void complete(std::optional<PaymentComplete>&&);
+ void cancel();
// EventTarget
bool dispatchEvent(Event&) final;
Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp (223961 => 223962)
--- trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp 2017-10-25 17:42:20 UTC (rev 223961)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp 2017-10-25 18:00:28 UTC (rev 223962)
@@ -130,6 +130,15 @@
});
}
+void MockPaymentCoordinator::cancelPayment()
+{
+ dispatchIfShowing([mainFrame = makeRef(m_mainFrame)] {
+ mainFrame->paymentCoordinator().didCancelPaymentSession();
+ ++hideCount;
+ ASSERT(showCount == hideCount);
+ });
+}
+
void MockPaymentCoordinator::completePaymentSession(std::optional<PaymentAuthorizationResult>&&)
{
++hideCount;
Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.h (223961 => 223962)
--- trunk/Source/WebCore/testing/MockPaymentCoordinator.h 2017-10-25 17:42:20 UTC (rev 223961)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.h 2017-10-25 18:00:28 UTC (rev 223962)
@@ -43,6 +43,7 @@
void changeShippingOption(String&& shippingOption);
void changePaymentMethod(ApplePayPaymentMethod&&);
void acceptPayment();
+ void cancelPayment();
void ref() const { }
void deref() const { }
Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.idl (223961 => 223962)
--- trunk/Source/WebCore/testing/MockPaymentCoordinator.idl 2017-10-25 17:42:20 UTC (rev 223961)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.idl 2017-10-25 18:00:28 UTC (rev 223962)
@@ -31,4 +31,5 @@
void changeShippingOption(DOMString shippingOption);
void changePaymentMethod(ApplePayPaymentMethod paymentMethod);
void acceptPayment();
+ void cancelPayment();
};