Title: [244092] trunk/Source
Revision
244092
Author
aes...@apple.com
Date
2019-04-09 12:53:35 -0700 (Tue, 09 Apr 2019)

Log Message

[Apple Pay] Add release logging to PaymentCoordinator
https://bugs.webkit.org/show_bug.cgi?id=196738

Reviewed by Alex Christensen.

Source/WebCore:

When allowed, log interactions with PaymentCoordinator to os_log to help diagnose Apple Pay bugs.

The following information might be logged: names of functions called, merchant API versions,
boolean results of canMakePayments(), boolean results of beginPaymentSession(), whether
completePaymentSession() was called with a final state result, boolean results of
shouldAllowApplePay(), whether a document has evaluated user agent scripts or is running
user scripts, and whether a client supports unrestricted Apple Pay.

* Modules/applepay/PaymentCoordinator.cpp:
(WebCore::PaymentCoordinator::supportsVersion const):
(WebCore::PaymentCoordinator::canMakePayments):
(WebCore::PaymentCoordinator::canMakePaymentsWithActiveCard):
(WebCore::PaymentCoordinator::openPaymentSetup):
(WebCore::PaymentCoordinator::beginPaymentSession):
(WebCore::PaymentCoordinator::completeMerchantValidation):
(WebCore::PaymentCoordinator::completeShippingMethodSelection):
(WebCore::PaymentCoordinator::completeShippingContactSelection):
(WebCore::PaymentCoordinator::completePaymentMethodSelection):
(WebCore::PaymentCoordinator::completePaymentSession):
(WebCore::PaymentCoordinator::abortPaymentSession):
(WebCore::PaymentCoordinator::cancelPaymentSession):
(WebCore::PaymentCoordinator::validateMerchant):
(WebCore::PaymentCoordinator::didAuthorizePayment):
(WebCore::PaymentCoordinator::didSelectPaymentMethod):
(WebCore::PaymentCoordinator::didSelectShippingMethod):
(WebCore::PaymentCoordinator::didSelectShippingContact):
(WebCore::PaymentCoordinator::didCancelPaymentSession):
(WebCore::PaymentCoordinator::shouldAllowApplePay const):
(WebCore::PaymentCoordinator::shouldAllowUserAgentScripts const):
* Modules/applepay/PaymentCoordinatorClient.h:
(WebCore::PaymentCoordinatorClient::isAlwaysOnLoggingAllowed const):
* platform/Logging.h:
* testing/MockPaymentCoordinator.h:

Source/WebKit:

* WebProcess/ApplePay/WebPaymentCoordinator.cpp:
(WebKit::WebPaymentCoordinator::isAlwaysOnLoggingAllowed const):
* WebProcess/ApplePay/WebPaymentCoordinator.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (244091 => 244092)


--- trunk/Source/WebCore/ChangeLog	2019-04-09 19:37:28 UTC (rev 244091)
+++ trunk/Source/WebCore/ChangeLog	2019-04-09 19:53:35 UTC (rev 244092)
@@ -1,3 +1,44 @@
+2019-04-09  Andy Estes  <aes...@apple.com>
+
+        [Apple Pay] Add release logging to PaymentCoordinator
+        https://bugs.webkit.org/show_bug.cgi?id=196738
+
+        Reviewed by Alex Christensen.
+
+        When allowed, log interactions with PaymentCoordinator to os_log to help diagnose Apple Pay bugs.
+
+        The following information might be logged: names of functions called, merchant API versions,
+        boolean results of canMakePayments(), boolean results of beginPaymentSession(), whether
+        completePaymentSession() was called with a final state result, boolean results of
+        shouldAllowApplePay(), whether a document has evaluated user agent scripts or is running
+        user scripts, and whether a client supports unrestricted Apple Pay.
+
+        * Modules/applepay/PaymentCoordinator.cpp:
+        (WebCore::PaymentCoordinator::supportsVersion const):
+        (WebCore::PaymentCoordinator::canMakePayments):
+        (WebCore::PaymentCoordinator::canMakePaymentsWithActiveCard):
+        (WebCore::PaymentCoordinator::openPaymentSetup):
+        (WebCore::PaymentCoordinator::beginPaymentSession):
+        (WebCore::PaymentCoordinator::completeMerchantValidation):
+        (WebCore::PaymentCoordinator::completeShippingMethodSelection):
+        (WebCore::PaymentCoordinator::completeShippingContactSelection):
+        (WebCore::PaymentCoordinator::completePaymentMethodSelection):
+        (WebCore::PaymentCoordinator::completePaymentSession):
+        (WebCore::PaymentCoordinator::abortPaymentSession):
+        (WebCore::PaymentCoordinator::cancelPaymentSession):
+        (WebCore::PaymentCoordinator::validateMerchant):
+        (WebCore::PaymentCoordinator::didAuthorizePayment):
+        (WebCore::PaymentCoordinator::didSelectPaymentMethod):
+        (WebCore::PaymentCoordinator::didSelectShippingMethod):
+        (WebCore::PaymentCoordinator::didSelectShippingContact):
+        (WebCore::PaymentCoordinator::didCancelPaymentSession):
+        (WebCore::PaymentCoordinator::shouldAllowApplePay const):
+        (WebCore::PaymentCoordinator::shouldAllowUserAgentScripts const):
+        * Modules/applepay/PaymentCoordinatorClient.h:
+        (WebCore::PaymentCoordinatorClient::isAlwaysOnLoggingAllowed const):
+        * platform/Logging.h:
+        * testing/MockPaymentCoordinator.h:
+
 2019-04-09  John Wilander  <wilan...@apple.com>
 
         Pick up Ad Click Attribution conversions in NetworkResourceLoader::willSendRedirectedRequest()

Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp (244091 => 244092)


--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp	2019-04-09 19:37:28 UTC (rev 244091)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp	2019-04-09 19:53:35 UTC (rev 244092)
@@ -30,6 +30,7 @@
 
 #include "Document.h"
 #include "LinkIconCollector.h"
+#include "Logging.h"
 #include "PaymentAuthorizationStatus.h"
 #include "PaymentCoordinatorClient.h"
 #include "PaymentSession.h"
@@ -36,6 +37,11 @@
 #include <wtf/CompletionHandler.h>
 #include <wtf/URL.h>
 
+#undef RELEASE_LOG_ERROR_IF_ALLOWED
+#undef RELEASE_LOG_IF_ALLOWED
+#define RELEASE_LOG_ERROR_IF_ALLOWED(fmt, ...) RELEASE_LOG_ERROR_IF(m_client.isAlwaysOnLoggingAllowed(), ApplePay, "%p - PaymentCoordinator::" fmt, this, ##__VA_ARGS__)
+#define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(m_client.isAlwaysOnLoggingAllowed(), ApplePay, "%p - PaymentCoordinator::" fmt, this, ##__VA_ARGS__)
+
 namespace WebCore {
 
 PaymentCoordinator::PaymentCoordinator(PaymentCoordinatorClient& client)
@@ -52,7 +58,10 @@
 {
     if (!shouldAllowApplePay(document))
         return false;
-    return m_client.supportsVersion(version);
+
+    auto supportsVersion = m_client.supportsVersion(version);
+    RELEASE_LOG_IF_ALLOWED("supportsVersion(%d) -> %d", version, supportsVersion);
+    return supportsVersion;
 }
 
 bool PaymentCoordinator::canMakePayments(Document& document)
@@ -59,7 +68,10 @@
 {
     if (!shouldAllowApplePay(document))
         return false;
-    return m_client.canMakePayments();
+
+    auto canMakePayments = m_client.canMakePayments();
+    RELEASE_LOG_IF_ALLOWED("canMakePayments() -> %d", canMakePayments);
+    return canMakePayments;
 }
 
 void PaymentCoordinator::canMakePaymentsWithActiveCard(Document& document, const String& merchantIdentifier, WTF::Function<void(bool)>&& completionHandler)
@@ -66,6 +78,8 @@
 {
     if (!shouldAllowApplePay(document))
         return completionHandler(false);
+
+    RELEASE_LOG_IF_ALLOWED("canMakePaymentsWithActiveCard()");
     m_client.canMakePaymentsWithActiveCard(merchantIdentifier, document.domain(), WTFMove(completionHandler));
 }
 
@@ -73,6 +87,8 @@
 {
     if (!shouldAllowApplePay(document))
         return completionHandler(false);
+
+    RELEASE_LOG_IF_ALLOWED("openPaymentSetup()");
     m_client.openPaymentSetup(merchantIdentifier, document.domain(), WTFMove(completionHandler));
 }
 
@@ -87,7 +103,9 @@
     for (auto& icon : LinkIconCollector { document }.iconsOfTypes({ LinkIconType::TouchIcon, LinkIconType::TouchPrecomposedIcon }))
         linkIconURLs.append(icon.url);
 
-    if (!m_client.showPaymentUI(document.url(), linkIconURLs, paymentRequest))
+    auto showPaymentUI = m_client.showPaymentUI(document.url(), linkIconURLs, paymentRequest);
+    RELEASE_LOG_IF_ALLOWED("beginPaymentSession() -> %d", showPaymentUI);
+    if (!showPaymentUI)
         return false;
 
     m_activeSession = &paymentSession;
@@ -98,7 +116,7 @@
 void PaymentCoordinator::completeMerchantValidation(const PaymentMerchantSession& paymentMerchantSession)
 {
     ASSERT(m_activeSession);
-
+    RELEASE_LOG_IF_ALLOWED("completeMerchantValidation()");
     m_client.completeMerchantValidation(paymentMerchantSession);
 }
 
@@ -105,7 +123,7 @@
 void PaymentCoordinator::completeShippingMethodSelection(Optional<ShippingMethodUpdate>&& update)
 {
     ASSERT(m_activeSession);
-
+    RELEASE_LOG_IF_ALLOWED("completeShippingMethodSelection()");
     m_client.completeShippingMethodSelection(WTFMove(update));
 }
 
@@ -112,7 +130,7 @@
 void PaymentCoordinator::completeShippingContactSelection(Optional<ShippingContactUpdate>&& update)
 {
     ASSERT(m_activeSession);
-
+    RELEASE_LOG_IF_ALLOWED("completeShippingContactSelection()");
     m_client.completeShippingContactSelection(WTFMove(update));
 }
 
@@ -119,7 +137,7 @@
 void PaymentCoordinator::completePaymentMethodSelection(Optional<PaymentMethodUpdate>&& update)
 {
     ASSERT(m_activeSession);
-
+    RELEASE_LOG_IF_ALLOWED("completePaymentMethodSelection()");
     m_client.completePaymentMethodSelection(WTFMove(update));
 }
 
@@ -128,7 +146,7 @@
     ASSERT(m_activeSession);
 
     bool isFinalState = isFinalStateResult(result);
-
+    RELEASE_LOG_IF_ALLOWED("completePaymentSession() (isFinalState: %d)", isFinalState);
     m_client.completePaymentSession(WTFMove(result));
 
     if (!isFinalState)
@@ -140,7 +158,7 @@
 void PaymentCoordinator::abortPaymentSession()
 {
     ASSERT(m_activeSession);
-
+    RELEASE_LOG_IF_ALLOWED("abortPaymentSession()");
     m_client.abortPaymentSession();
     m_activeSession = nullptr;
 }
@@ -148,7 +166,7 @@
 void PaymentCoordinator::cancelPaymentSession()
 {
     ASSERT(m_activeSession);
-
+    RELEASE_LOG_IF_ALLOWED("cancelPaymentSession()");
     m_client.cancelPaymentSession();
 }
 
@@ -159,6 +177,7 @@
         return;
     }
 
+    RELEASE_LOG_IF_ALLOWED("validateMerchant()");
     m_activeSession->validateMerchant(WTFMove(validationURL));
 }
 
@@ -169,6 +188,7 @@
         return;
     }
 
+    RELEASE_LOG_IF_ALLOWED("validateMerchant()");
     m_activeSession->didAuthorizePayment(payment);
 }
 
@@ -179,6 +199,7 @@
         return;
     }
 
+    RELEASE_LOG_IF_ALLOWED("didSelectPaymentMethod()");
     m_activeSession->didSelectPaymentMethod(paymentMethod);
 }
 
@@ -189,6 +210,7 @@
         return;
     }
 
+    RELEASE_LOG_IF_ALLOWED("didSelectShippingMethod()");
     m_activeSession->didSelectShippingMethod(shippingMethod);
 }
 
@@ -199,6 +221,7 @@
         return;
     }
 
+    RELEASE_LOG_IF_ALLOWED("didSelectShippingContact()");
     m_activeSession->didSelectShippingContact(shippingContact);
 }
 
@@ -209,6 +232,7 @@
         return;
     }
 
+    RELEASE_LOG_IF_ALLOWED("didCancelPaymentSession()");
     m_activeSession->didCancelPaymentSession();
     m_activeSession = nullptr;
 }
@@ -229,14 +253,20 @@
 
 bool PaymentCoordinator::shouldAllowApplePay(Document& document) const
 {
-    if (m_client.supportsUnrestrictedApplePay())
+    if (m_client.supportsUnrestrictedApplePay()) {
+        RELEASE_LOG_IF_ALLOWED("shouldAllowApplePay() -> true (unrestricted client)");
         return true;
+    }
 
-    if (document.hasEvaluatedUserAgentScripts() || document.isRunningUserScripts()) {
+    auto hasEvaluatedUserAgentScripts = document.hasEvaluatedUserAgentScripts();
+    auto isRunningUserScripts = document.isRunningUserScripts();
+    if (hasEvaluatedUserAgentScripts || isRunningUserScripts) {
         ASSERT(shouldAllowUserAgentScripts(document));
+        RELEASE_LOG_IF_ALLOWED("shouldAllowApplePay() -> false (hasEvaluatedUserAgentScripts: %d, isRunningUserScripts: %d)", hasEvaluatedUserAgentScripts, isRunningUserScripts);
         return false;
     }
 
+    RELEASE_LOG_IF_ALLOWED("shouldAllowApplePay() -> true");
     return true;
 }
 
@@ -247,6 +277,7 @@
 
     if (document.hasStartedApplePaySession()) {
         ASSERT(shouldAllowApplePay(document));
+        RELEASE_LOG_ERROR_IF_ALLOWED("shouldAllowUserAgentScripts() -> false (active session)");
         return false;
     }
 
@@ -255,4 +286,7 @@
 
 } // namespace WebCore
 
+#undef RELEASE_LOG_ERROR_IF_ALLOWED
+#undef RELEASE_LOG_IF_ALLOWED
+
 #endif // ENABLE(APPLE_PAY)

Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h (244091 => 244092)


--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h	2019-04-09 19:37:28 UTC (rev 244091)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h	2019-04-09 19:53:35 UTC (rev 244092)
@@ -66,6 +66,7 @@
     virtual bool isMockPaymentCoordinator() const { return false; }
     virtual bool isWebPaymentCoordinator() const { return false; }
 
+    virtual bool isAlwaysOnLoggingAllowed() const { return false; }
     virtual bool supportsUnrestrictedApplePay() const { return true; }
 
 protected:

Modified: trunk/Source/WebCore/platform/Logging.h (244091 => 244092)


--- trunk/Source/WebCore/platform/Logging.h	2019-04-09 19:37:28 UTC (rev 244091)
+++ trunk/Source/WebCore/platform/Logging.h	2019-04-09 19:53:35 UTC (rev 244092)
@@ -39,6 +39,7 @@
 
 #define WEBCORE_LOG_CHANNELS(M) \
     M(Animations) \
+    M(ApplePay) \
     M(Archives) \
     M(Compositing) \
     M(ContentFiltering) \

Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.h (244091 => 244092)


--- trunk/Source/WebCore/testing/MockPaymentCoordinator.h	2019-04-09 19:37:28 UTC (rev 244091)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.h	2019-04-09 19:53:35 UTC (rev 244092)
@@ -83,6 +83,8 @@
 
     bool isMockPaymentCoordinator() const final { return true; }
 
+    bool isAlwaysOnLoggingAllowed() const final { return true; }
+
     void updateTotalAndLineItems(const ApplePaySessionPaymentRequest::TotalAndLineItems&);
 
     Page& m_page;

Modified: trunk/Source/WebKit/ChangeLog (244091 => 244092)


--- trunk/Source/WebKit/ChangeLog	2019-04-09 19:37:28 UTC (rev 244091)
+++ trunk/Source/WebKit/ChangeLog	2019-04-09 19:53:35 UTC (rev 244092)
@@ -1,3 +1,14 @@
+2019-04-09  Andy Estes  <aes...@apple.com>
+
+        [Apple Pay] Add release logging to PaymentCoordinator
+        https://bugs.webkit.org/show_bug.cgi?id=196738
+
+        Reviewed by Alex Christensen.
+
+        * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
+        (WebKit::WebPaymentCoordinator::isAlwaysOnLoggingAllowed const):
+        * WebProcess/ApplePay/WebPaymentCoordinator.h:
+
 2019-04-09  Jer Noble  <jer.no...@apple.com>
 
         [Cocoa] Awaken UIProcess if WebContent process is awakened from suspensions unexpectedly.

Modified: trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp (244091 => 244092)


--- trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp	2019-04-09 19:37:28 UTC (rev 244091)
+++ trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp	2019-04-09 19:53:35 UTC (rev 244092)
@@ -142,6 +142,11 @@
     delete this;
 }
 
+bool WebPaymentCoordinator::isAlwaysOnLoggingAllowed() const
+{
+    return m_webPage.isAlwaysOnLoggingAllowed();
+}
+
 bool WebPaymentCoordinator::supportsUnrestrictedApplePay() const
 {
 #if ENABLE(APPLE_PAY_REMOTE_UI)

Modified: trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h (244091 => 244092)


--- trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h	2019-04-09 19:37:28 UTC (rev 244091)
+++ trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h	2019-04-09 19:53:35 UTC (rev 244092)
@@ -78,6 +78,7 @@
 
     bool isWebPaymentCoordinator() const override { return true; }
 
+    bool isAlwaysOnLoggingAllowed() const override;
     bool supportsUnrestrictedApplePay() const override;
 
     // IPC::MessageReceiver.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to