[Payment Request] PaymentResponse should have an onpayerdetailchange event handler
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Sep 2018 19:14:23 +0000 (19:14 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Sep 2018 19:14:23 +0000 (19:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189249

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

* web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https-expected.txt:

Source/WebCore:

Implemented the onpayerdetailchange event handler as defined in the Payment Request API W3C Editor's Draft of 30 August 2018.

The "payer detail changed" algorithm will be implemented in a follow-up patch.

Covered by existing web platform tests.

* Modules/paymentrequest/PaymentResponse.cpp:
(WebCore::PaymentResponse::scriptExecutionContext const):
* Modules/paymentrequest/PaymentResponse.h:
* Modules/paymentrequest/PaymentResponse.idl:
* dom/EventNames.h:
* dom/EventTargetFactory.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235625 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/paymentrequest/PaymentResponse.cpp
Source/WebCore/Modules/paymentrequest/PaymentResponse.h
Source/WebCore/Modules/paymentrequest/PaymentResponse.idl
Source/WebCore/dom/EventNames.h
Source/WebCore/dom/EventTargetFactory.in

index e33449a..a243159 100644 (file)
@@ -1,3 +1,12 @@
+2018-09-04  Andy Estes  <aestes@apple.com>
+
+        [Payment Request] PaymentResponse should have an onpayerdetailchange event handler
+        https://bugs.webkit.org/show_bug.cgi?id=189249
+
+        Reviewed by Alex Christensen.
+
+        * web-platform-tests/payment-request/payment-response/onpayerdetailchange-attribute.https-expected.txt:
+
 2018-09-03  Andy Estes  <aestes@apple.com>
 
         [Payment Request] Implement the MerchantValidationEvent constructor
index aa66532..b9ad87c 100644 (file)
@@ -1,8 +1,4 @@
 
-FAIL PaymentResponse inherits from EventTarget assert_equals: expected function "function EventTarget() {
-    [native code]
-}" but got function "function () {
-    [native code]
-}"
-FAIL PaymentResponse has an onpayerdetailchange in the prototype chain assert_true: expected true got false
+PASS PaymentResponse inherits from EventTarget 
+PASS PaymentResponse has an onpayerdetailchange in the prototype chain 
 
index bc413ec..fc93ef8 100644 (file)
@@ -1,3 +1,23 @@
+2018-09-04  Andy Estes  <aestes@apple.com>
+
+        [Payment Request] PaymentResponse should have an onpayerdetailchange event handler
+        https://bugs.webkit.org/show_bug.cgi?id=189249
+
+        Reviewed by Alex Christensen.
+
+        Implemented the onpayerdetailchange event handler as defined in the Payment Request API W3C Editor's Draft of 30 August 2018.
+
+        The "payer detail changed" algorithm will be implemented in a follow-up patch.
+
+        Covered by existing web platform tests.
+
+        * Modules/paymentrequest/PaymentResponse.cpp:
+        (WebCore::PaymentResponse::scriptExecutionContext const):
+        * Modules/paymentrequest/PaymentResponse.h:
+        * Modules/paymentrequest/PaymentResponse.idl:
+        * dom/EventNames.h:
+        * dom/EventTargetFactory.in:
+
 2018-09-04  Youenn Fablet  <youenn@apple.com>
 
         Introduce LibWebRTC backends for sender and receiver
index 63cf29d..0f16d6f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -59,6 +59,11 @@ void PaymentResponse::retry(PaymentValidationErrors&&, DOMPromiseDeferred<void>&
     promise.reject(Exception { NotSupportedError });
 }
 
+ScriptExecutionContext* PaymentResponse::scriptExecutionContext() const
+{
+    return static_cast<ActiveDOMObject&>(m_request.get()).scriptExecutionContext();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(PAYMENT_REQUEST)
index e265ebc..9609b8d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,6 +27,7 @@
 
 #if ENABLE(PAYMENT_REQUEST)
 
+#include "EventTarget.h"
 #include "JSDOMPromiseDeferred.h"
 #include "PaymentAddress.h"
 #include "PaymentComplete.h"
@@ -37,7 +38,7 @@ class Document;
 class PaymentRequest;
 struct PaymentValidationErrors;
 
-class PaymentResponse final : public RefCounted<PaymentResponse> {
+class PaymentResponse final : public RefCounted<PaymentResponse>, public EventTargetWithInlineData {
 public:
     static Ref<PaymentResponse> create(PaymentRequest& request)
     {
@@ -73,9 +74,18 @@ public:
     void complete(std::optional<PaymentComplete>&&, DOMPromiseDeferred<void>&&);
     void retry(PaymentValidationErrors&&, DOMPromiseDeferred<void>&&);
 
+    using RefCounted<PaymentResponse>::ref;
+    using RefCounted<PaymentResponse>::deref;
+
 private:
     explicit PaymentResponse(PaymentRequest&);
 
+    // EventTarget
+    EventTargetInterface eventTargetInterface() const final { return PaymentResponseEventTargetInterfaceType; }
+    ScriptExecutionContext* scriptExecutionContext() const final;
+    void refEventTarget() final { ref(); }
+    void derefEventTarget() final { deref(); }
+
     Ref<PaymentRequest> m_request;
     String m_requestId;
     String m_methodName;
index ae24519..7210dd8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,9 +26,9 @@
 [
     Conditional=PAYMENT_REQUEST,
     EnabledBySetting=PaymentRequest,
-    ImplementationLacksVTable,
-    SecureContext
-] interface PaymentResponse {
+    Exposed=Window,
+    SecureContext,
+] interface PaymentResponse : EventTarget {
     serializer = { attribute };
 
     readonly attribute DOMString requestId;
@@ -42,4 +42,6 @@
 
     [NewObject] Promise<void> complete(optional PaymentComplete result = "unknown");
     [NewObject] Promise<void> retry(PaymentValidationErrors errorFields);
+
+    attribute EventHandler onpayerdetailchange;
 };
index f70dc74..8226ea8 100644 (file)
@@ -189,6 +189,7 @@ namespace WebCore {
     macro(pageshow) \
     macro(paste) \
     macro(pause) \
+    macro(payerdetailchange) \
     macro(paymentauthorized) \
     macro(paymentmethodchange) \
     macro(paymentmethodselected) \
index 3ad9c32..80626a8 100644 (file)
@@ -29,6 +29,7 @@ Node
 Notification conditional=NOTIFICATIONS
 OffscreenCanvas
 PaymentRequest conditional=PAYMENT_REQUEST
+PaymentResponse conditional=PAYMENT_REQUEST
 Performance
 RTCDataChannel conditional=WEB_RTC
 RTCDTMFSender conditional=WEB_RTC_DTMF