Title: [237521] trunk
Revision
237521
Author
[email protected]
Date
2018-10-28 07:34:13 -0700 (Sun, 28 Oct 2018)

Log Message

[Payment Request] Implement MerchantValidationEvent.methodName
https://bugs.webkit.org/show_bug.cgi?id=190058

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/payment-request/MerchantValidationEvent/constructor.https-expected.txt:

Source/WebCore:

Implemented MerchantValidationEvent's methodName attribute and MerchantValidationEventInit's
methodName property as specified in the Payment Request API W3C Editor's Draft of
27 September 2018.

Covered by web-platform-tests/payment-request/MerchantValidationEvent/constructor.https.html.

* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::validateMerchant): Passed the payment method identifier
(as a string) to MerchantValidationEvent::create()
* Modules/paymentrequest/MerchantValidationEvent.cpp:
(WebCore::MerchantValidationEvent::create): Validated the methodName before constructing the
event, throwing a RangeError on failure.
(WebCore::MerchantValidationEvent::MerchantValidationEvent):
* Modules/paymentrequest/MerchantValidationEvent.h:
* Modules/paymentrequest/MerchantValidationEvent.idl:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (237520 => 237521)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-10-28 13:44:22 UTC (rev 237520)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-10-28 14:34:13 UTC (rev 237521)
@@ -1,3 +1,12 @@
+2018-10-28  Andy Estes  <[email protected]>
+
+        [Payment Request] Implement MerchantValidationEvent.methodName
+        https://bugs.webkit.org/show_bug.cgi?id=190058
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/payment-request/MerchantValidationEvent/constructor.https-expected.txt:
+
 2018-10-26  Antoine Quint  <[email protected]>
 
         [Web Animations] Rebase some flaky tests

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/MerchantValidationEvent/constructor.https-expected.txt (237520 => 237521)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/MerchantValidationEvent/constructor.https-expected.txt	2018-10-28 13:44:22 UTC (rev 237520)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/MerchantValidationEvent/constructor.https-expected.txt	2018-10-28 14:34:13 UTC (rev 237521)
@@ -5,10 +5,8 @@
 PASS Must have a validationURL IDL attribute, which is initialized with to the validationURL dictionary value. 
 PASS Must throw TypeError if initialized with an invalid URL. 
 PASS Relative validationURLs use the document as the base. 
-FAIL Must have a methodName IDL attribute, which is initialized with to the methodName dictionary value. assert_idl_attribute: property "methodName" not found in prototype chain
-FAIL When no methodName is passed, methodName attribute defaults to the empty string assert_equals: expected (string) "" but got (undefined) undefined
-FAIL MerchantValidationEvent can be constructed with valid PMIs assert_equals: expected (string) "https://example.com/pay" but got (undefined) undefined
-FAIL MerchantValidationEvent can't be constructed with invalid PMIs assert_throws: expected to throw when constructed with invalid PMI: 'basic-💳' function "() => {
-        const event = new MerchantValidationEvent("test", { methodName });
-      }" did not throw
+PASS Must have a methodName IDL attribute, which is initialized with to the methodName dictionary value. 
+PASS When no methodName is passed, methodName attribute defaults to the empty string 
+PASS MerchantValidationEvent can be constructed with valid PMIs 
+PASS MerchantValidationEvent can't be constructed with invalid PMIs 
 

Modified: trunk/Source/WebCore/ChangeLog (237520 => 237521)


--- trunk/Source/WebCore/ChangeLog	2018-10-28 13:44:22 UTC (rev 237520)
+++ trunk/Source/WebCore/ChangeLog	2018-10-28 14:34:13 UTC (rev 237521)
@@ -1,3 +1,26 @@
+2018-10-28  Andy Estes  <[email protected]>
+
+        [Payment Request] Implement MerchantValidationEvent.methodName
+        https://bugs.webkit.org/show_bug.cgi?id=190058
+
+        Reviewed by Darin Adler.
+
+        Implemented MerchantValidationEvent's methodName attribute and MerchantValidationEventInit's
+        methodName property as specified in the Payment Request API W3C Editor's Draft of
+        27 September 2018.
+
+        Covered by web-platform-tests/payment-request/MerchantValidationEvent/constructor.https.html.
+
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+        (WebCore::ApplePayPaymentHandler::validateMerchant): Passed the payment method identifier
+        (as a string) to MerchantValidationEvent::create()
+        * Modules/paymentrequest/MerchantValidationEvent.cpp:
+        (WebCore::MerchantValidationEvent::create): Validated the methodName before constructing the
+        event, throwing a RangeError on failure.
+        (WebCore::MerchantValidationEvent::MerchantValidationEvent):
+        * Modules/paymentrequest/MerchantValidationEvent.h:
+        * Modules/paymentrequest/MerchantValidationEvent.idl:
+
 2018-10-27  Antoine Quint  <[email protected]>
 
         [Web Animations] Remove WebAnimation::description()

Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (237520 => 237521)


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2018-10-28 13:44:22 UTC (rev 237520)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2018-10-28 14:34:13 UTC (rev 237521)
@@ -503,7 +503,7 @@
 void ApplePayPaymentHandler::validateMerchant(URL&& validationURL)
 {
     if (validationURL.isValid())
-        m_paymentRequest->dispatchEvent(MerchantValidationEvent::create(eventNames().merchantvalidationEvent, WTFMove(validationURL)).get());
+        m_paymentRequest->dispatchEvent(MerchantValidationEvent::create(eventNames().merchantvalidationEvent, WTF::get<URL>(m_identifier).string(), WTFMove(validationURL)).get());
 }
 
 static Ref<PaymentAddress> convert(const ApplePayPaymentContact& contact)

Modified: trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.cpp (237520 => 237521)


--- trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.cpp	2018-10-28 13:44:22 UTC (rev 237520)
+++ trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.cpp	2018-10-28 14:34:13 UTC (rev 237521)
@@ -33,9 +33,9 @@
 
 namespace WebCore {
 
-Ref<MerchantValidationEvent> MerchantValidationEvent::create(const AtomicString& type, URL&& validationURL)
+Ref<MerchantValidationEvent> MerchantValidationEvent::create(const AtomicString& type, const String& methodName, URL&& validationURL)
 {
-    return adoptRef(*new MerchantValidationEvent(type, WTFMove(validationURL)));
+    return adoptRef(*new MerchantValidationEvent(type, methodName, WTFMove(validationURL)));
 }
 
 ExceptionOr<Ref<MerchantValidationEvent>> MerchantValidationEvent::create(Document& document, const AtomicString& type, Init&& eventInit)
@@ -44,11 +44,19 @@
     if (!validationURL.isValid())
         return Exception { TypeError };
 
-    return adoptRef(*new MerchantValidationEvent(type, WTFMove(validationURL), WTFMove(eventInit)));
+    auto methodName = WTFMove(eventInit.methodName);
+    if (!methodName.isEmpty()) {
+        auto validatedMethodName = convertAndValidatePaymentMethodIdentifier(methodName);
+        if (!validatedMethodName)
+            return Exception { RangeError, makeString('"', methodName, "\" is an invalid payment method identifier.") };
+    }
+
+    return adoptRef(*new MerchantValidationEvent(type, WTFMove(methodName), WTFMove(validationURL), WTFMove(eventInit)));
 }
 
-MerchantValidationEvent::MerchantValidationEvent(const AtomicString& type, URL&& validationURL)
+MerchantValidationEvent::MerchantValidationEvent(const AtomicString& type, const String& methodName, URL&& validationURL)
     : Event { type, Event::CanBubble::No, Event::IsCancelable::No }
+    , m_methodName { methodName }
     , m_validationURL { WTFMove(validationURL) }
 {
     ASSERT(isTrusted());
@@ -55,8 +63,9 @@
     ASSERT(m_validationURL.isValid());
 }
 
-MerchantValidationEvent::MerchantValidationEvent(const AtomicString& type, URL&& validationURL, Init&& eventInit)
+MerchantValidationEvent::MerchantValidationEvent(const AtomicString& type, String&& methodName, URL&& validationURL, Init&& eventInit)
     : Event { type, WTFMove(eventInit), IsTrusted::No }
+    , m_methodName { WTFMove(methodName) }
     , m_validationURL { WTFMove(validationURL) }
 {
     ASSERT(!isTrusted());

Modified: trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.h (237520 => 237521)


--- trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.h	2018-10-28 13:44:22 UTC (rev 237520)
+++ trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.h	2018-10-28 14:34:13 UTC (rev 237521)
@@ -38,23 +38,26 @@
 class MerchantValidationEvent final : public Event {
 public:
     struct Init final : EventInit {
+        String methodName;
         String validationURL;
     };
 
-    static Ref<MerchantValidationEvent> create(const AtomicString&, URL&&);
-    static ExceptionOr<Ref<MerchantValidationEvent>> create(Document&, const AtomicString&, Init&&);
+    static Ref<MerchantValidationEvent> create(const AtomicString& type, const String& methodName, URL&& validationURL);
+    static ExceptionOr<Ref<MerchantValidationEvent>> create(Document&, const AtomicString& type, Init&&);
 
+    const String& methodName() const { return m_methodName; }
     const String& validationURL() const { return m_validationURL.string(); }
     ExceptionOr<void> complete(Ref<DOMPromise>&&);
 
 private:
-    MerchantValidationEvent(const AtomicString&, URL&&);
-    MerchantValidationEvent(const AtomicString&, URL&&, Init&&);
+    MerchantValidationEvent(const AtomicString& type, const String& methodName, URL&& validationURL);
+    MerchantValidationEvent(const AtomicString& type, String&& methodName, URL&& validationURL, Init&&);
 
     // Event
     EventInterface eventInterface() const final;
 
     bool m_isCompleted { false };
+    String m_methodName;
     URL m_validationURL;
 };
 

Modified: trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.idl (237520 => 237521)


--- trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.idl	2018-10-28 13:44:22 UTC (rev 237520)
+++ trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.idl	2018-10-28 14:34:13 UTC (rev 237521)
@@ -32,7 +32,8 @@
     Exposed=Window,
     SecureContext,
 ] interface MerchantValidationEvent : Event {
-    readonly attribute DOMString validationURL;
+    readonly attribute DOMString methodName;
+    readonly attribute USVString validationURL;
     [MayThrowException] void complete(Promise<any> merchantSessionPromise);
 };
 
@@ -39,5 +40,6 @@
 [
     Conditional=PAYMENT_REQUEST,
 ] dictionary MerchantValidationEventInit : EventInit {
+    DOMString methodName = "";
     USVString validationURL = "";
 };

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (237520 => 237521)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2018-10-28 13:44:22 UTC (rev 237520)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2018-10-28 14:34:13 UTC (rev 237521)
@@ -275,7 +275,7 @@
         if (shouldValidatePaymentMethodIdentifier == ShouldValidatePaymentMethodIdentifier::Yes) {
             auto paymentMethodIdentifier = convertAndValidatePaymentMethodIdentifier(modifier.supportedMethods);
             if (!paymentMethodIdentifier)
-                return Exception { RangeError, makeString("\"", modifier.supportedMethods, "\" is an invalid payment method identifier.") };
+                return Exception { RangeError, makeString('"', modifier.supportedMethods, "\" is an invalid payment method identifier.") };
         }
 
         if (modifier.total) {
@@ -323,7 +323,7 @@
     for (auto& paymentMethod : methodData) {
         auto identifier = convertAndValidatePaymentMethodIdentifier(paymentMethod.supportedMethods);
         if (!identifier)
-            return Exception { RangeError, makeString("\"", paymentMethod.supportedMethods, "\" is an invalid payment method identifier.") };
+            return Exception { RangeError, makeString('"', paymentMethod.supportedMethods, "\" is an invalid payment method identifier.") };
 
         String serializedData;
         if (paymentMethod.data) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to