[Apple Pay] Add testing and logging for ApplePaySetup
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 May 2020 18:19:24 +0000 (18:19 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 May 2020 18:19:24 +0000 (18:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=211972
<rdar://problem/63291965>

Reviewed by Alex Christensen.

Source/WebCore:

Test: http/tests/ssl/applepay/ApplePaySetup.https.html

* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Modules/applepay/ApplePaySetup.cpp:
(WebCore::ApplePaySetup::getSetupFeatures):
(WebCore::ApplePaySetup::begin):
(WebCore::ApplePaySetup::ApplePaySetup):
(WebCore::ApplePaySetup::stop):
* Modules/applepay/ApplePaySetup.idl:
* Modules/applepay/ApplePaySetupConfiguration.h: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureType.idl.
* Modules/applepay/ApplePaySetupConfiguration.idl: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureType.idl.
* Modules/applepay/ApplePaySetupFeature.idl:
* Modules/applepay/ApplePaySetupFeature.mm:
(WebCore::ApplePaySetupFeature::state const):
* Modules/applepay/ApplePaySetupFeatureState.h: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureType.idl.
* Modules/applepay/ApplePaySetupFeatureState.idl: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureType.idl.
* Modules/applepay/ApplePaySetupFeatureType.idl:
* Modules/applepay/ApplePaySetupFeatureWebCore.h:
* Modules/applepay/ApplePaySetupWebCore.h:
(WebCore::ApplePaySetup::create):
* Modules/applepay/PaymentCoordinator.cpp:
(WebCore::PaymentCoordinator::setApplePayIsActiveIfAllowed const):
(WebCore::PaymentCoordinator::getSetupFeatures):
(WebCore::PaymentCoordinator::beginApplePaySetup):
(WebCore::PaymentCoordinator::endApplePaySetup):
* Modules/applepay/PaymentCoordinator.h:
* Modules/applepay/PaymentCoordinatorClient.h:
(WebCore::PaymentCoordinatorClient::getSetupFeatures):
(WebCore::PaymentCoordinatorClient::beginApplePaySetup):
* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* testing/MockApplePaySetupFeature.cpp: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureWebCore.h.
(WebCore::MockApplePaySetupFeature::create):
(WebCore::MockApplePaySetupFeature::MockApplePaySetupFeature):
* testing/MockApplePaySetupFeature.h: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureWebCore.h.
* testing/MockPaymentCoordinator.cpp:
(WebCore::MockPaymentCoordinator::addSetupFeature):
(WebCore::MockPaymentCoordinator::getSetupFeatures):
(WebCore::MockPaymentCoordinator::beginApplePaySetup):
* testing/MockPaymentCoordinator.h:
* testing/MockPaymentCoordinator.idl:

Source/WebKit:

* Shared/ApplePay/PaymentSetupConfiguration.mm:
(WebKit::toPlatformConfiguration):
(WebKit::PaymentSetupConfiguration::PaymentSetupConfiguration):
* Shared/ApplePay/PaymentSetupConfigurationWebKit.h:
* WebProcess/ApplePay/WebPaymentCoordinator.cpp:
(WebKit::WebPaymentCoordinator::getSetupFeatures):
(WebKit::WebPaymentCoordinator::beginApplePaySetup):
* WebProcess/ApplePay/WebPaymentCoordinator.h:

LayoutTests:

* http/tests/ssl/applepay/ApplePaySetup.https-expected.txt: Added.
* http/tests/ssl/applepay/ApplePaySetup.https.html: Added.
* platform/mac-wk2/TestExpectations:

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

34 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/ssl/applepay/ApplePaySetup.https-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/ssl/applepay/ApplePaySetup.https.html [new file with mode: 0644]
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources-input.xcfilelist
Source/WebCore/DerivedSources-output.xcfilelist
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/applepay/ApplePaySetup.cpp
Source/WebCore/Modules/applepay/ApplePaySetup.idl
Source/WebCore/Modules/applepay/ApplePaySetupConfiguration.h [new file with mode: 0644]
Source/WebCore/Modules/applepay/ApplePaySetupConfiguration.idl [new file with mode: 0644]
Source/WebCore/Modules/applepay/ApplePaySetupFeature.idl
Source/WebCore/Modules/applepay/ApplePaySetupFeature.mm
Source/WebCore/Modules/applepay/ApplePaySetupFeatureState.h [new file with mode: 0644]
Source/WebCore/Modules/applepay/ApplePaySetupFeatureState.idl [new file with mode: 0644]
Source/WebCore/Modules/applepay/ApplePaySetupFeatureType.idl
Source/WebCore/Modules/applepay/ApplePaySetupFeatureWebCore.h
Source/WebCore/Modules/applepay/ApplePaySetupWebCore.h
Source/WebCore/Modules/applepay/PaymentCoordinator.cpp
Source/WebCore/Modules/applepay/PaymentCoordinator.h
Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/testing/MockApplePaySetupFeature.cpp [new file with mode: 0644]
Source/WebCore/testing/MockApplePaySetupFeature.h [new file with mode: 0644]
Source/WebCore/testing/MockPaymentCoordinator.cpp
Source/WebCore/testing/MockPaymentCoordinator.h
Source/WebCore/testing/MockPaymentCoordinator.idl
Source/WebKit/ChangeLog
Source/WebKit/Shared/ApplePay/PaymentSetupConfiguration.mm
Source/WebKit/Shared/ApplePay/PaymentSetupConfigurationWebKit.h
Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp
Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h

index 89fbf3b..eddd6d9 100644 (file)
@@ -1,3 +1,15 @@
+2020-05-19  Andy Estes  <aestes@apple.com>
+
+        [Apple Pay] Add testing and logging for ApplePaySetup
+        https://bugs.webkit.org/show_bug.cgi?id=211972
+        <rdar://problem/63291965>
+
+        Reviewed by Alex Christensen.
+
+        * http/tests/ssl/applepay/ApplePaySetup.https-expected.txt: Added.
+        * http/tests/ssl/applepay/ApplePaySetup.https.html: Added.
+        * platform/mac-wk2/TestExpectations:
+
 2020-05-19  Simon Fraser  <simon.fraser@apple.com>
 
         [ macOS wk2 ] fast/scrolling/rtl-point-in-iframe.html sometimes fails
diff --git a/LayoutTests/http/tests/ssl/applepay/ApplePaySetup.https-expected.txt b/LayoutTests/http/tests/ssl/applepay/ApplePaySetup.https-expected.txt
new file mode 100644 (file)
index 0000000..3235845
--- /dev/null
@@ -0,0 +1,26 @@
+Test ApplePaySetup.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.mockPaymentCoordinator.setupConfiguration.merchantIdentifier is expectedMerchantIdentifier
+PASS internals.mockPaymentCoordinator.setupConfiguration.referrerIdentifier is expectedReferrerIdentifier
+PASS internals.mockPaymentCoordinator.setupConfiguration.signature is expectedSignature
+PASS typeof internals.mockPaymentCoordinator.setupConfiguration.signedFields is "object"
+PASS internals.mockPaymentCoordinator.setupConfiguration.signedFields.length is expectedSignedFields.length
+PASS internals.mockPaymentCoordinator.setupConfiguration.signedFields[0] is expectedSignedFields[0]
+PASS typeof features is "object"
+PASS features.length is 1
+PASS features[0].state is expectedSetupFeatureState
+PASS features[0].type is expectedSetupFeatureType
+PASS features[0].supportsInstallments is expectedSetupFeatureSupportsInstallments
+PASS internals.mockPaymentCoordinator.setupConfiguration.merchantIdentifier is expectedMerchantIdentifier
+PASS internals.mockPaymentCoordinator.setupConfiguration.referrerIdentifier is expectedReferrerIdentifier
+PASS internals.mockPaymentCoordinator.setupConfiguration.signature is expectedSignature
+PASS typeof internals.mockPaymentCoordinator.setupConfiguration.signedFields is "object"
+PASS internals.mockPaymentCoordinator.setupConfiguration.signedFields.length is expectedSignedFields.length
+PASS internals.mockPaymentCoordinator.setupConfiguration.signedFields[0] is expectedSignedFields[0]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/ssl/applepay/ApplePaySetup.https.html b/LayoutTests/http/tests/ssl/applepay/ApplePaySetup.https.html
new file mode 100644 (file)
index 0000000..97aaf3a
--- /dev/null
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="/js-test-resources/ui-helper.js"></script>
+<script src="/resources/js-test-pre.js"></script>
+<script src="/resources/payment-request.js"></script>
+</head>
+<body>
+<script>
+
+description("Test ApplePaySetup.");
+
+window.jsTestIsAsync = true;
+
+expectedMerchantIdentifier = 'merchant';
+expectedReferrerIdentifier = 'referrer';
+expectedSignature = 'signature';
+expectedSignedFields = ['field1'];
+expectedSetupFeatureState = 'supported';
+expectedSetupFeatureType = 'appleCard';
+expectedSetupFeatureSupportsInstallments = true;
+
+testSetupConfiguration = () => {
+    shouldBe('internals.mockPaymentCoordinator.setupConfiguration.merchantIdentifier', 'expectedMerchantIdentifier');
+    shouldBe('internals.mockPaymentCoordinator.setupConfiguration.referrerIdentifier', 'expectedReferrerIdentifier');
+    shouldBe('internals.mockPaymentCoordinator.setupConfiguration.signature', 'expectedSignature');
+    shouldBe('typeof internals.mockPaymentCoordinator.setupConfiguration.signedFields', '"object"');
+    shouldBe('internals.mockPaymentCoordinator.setupConfiguration.signedFields.length', 'expectedSignedFields.length');
+    shouldBe('internals.mockPaymentCoordinator.setupConfiguration.signedFields[0]', 'expectedSignedFields[0]');
+}
+
+(async () => {
+
+    let setup = new ApplePaySetup({
+        merchantIdentifier: expectedMerchantIdentifier,
+        referrerIdentifier: expectedReferrerIdentifier,
+        signature: expectedSignature,
+        signedFields: expectedSignedFields,
+    });
+
+    internals.mockPaymentCoordinator.addSetupFeature(expectedSetupFeatureState, expectedSetupFeatureType, expectedSetupFeatureSupportsInstallments);
+
+    features = await setup.getSetupFeatures();
+    testSetupConfiguration();
+    shouldBe('typeof features', '"object"');
+    shouldBe('features.length', '1');
+    shouldBe('features[0].state', 'expectedSetupFeatureState');
+    shouldBe('features[0].type', 'expectedSetupFeatureType');
+    shouldBe('features[0].supportsInstallments', 'expectedSetupFeatureSupportsInstallments');
+
+    activateThen(async () => {
+        let success = await setup.begin(features);
+        testSetupConfiguration();
+        finishJSTest();
+    });
+
+})();
+</script>
+<script src="/resources/js-test-post.js"></script>
+</body>
+</html>
index fab9e86..b531c44 100644 (file)
@@ -36,8 +36,9 @@ fast/media/mq-prefers-reduced-motion-live-update.html [ Pass ]
 
 http/tests/ssl/applepay/ [ Pass ]
 
-# ApplePayInstallmentConfiguration was first available in Catalina.
+# ApplePayInstallmentConfiguration and ApplePaySetup were first available in Catalina.
 [ Mojave ] http/tests/ssl/applepay/ApplePayInstallmentConfiguration.https.html [ Skip ]
+[ Mojave ] http/tests/ssl/applepay/ApplePaySetup.https.html [ Skip ]
 
 fast/visual-viewport/rubberbanding-viewport-rects.html [ Pass ]
 fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html  [ Pass ]
index 04d5fc5..3352e38 100644 (file)
@@ -1,3 +1,55 @@
+2020-05-19  Andy Estes  <aestes@apple.com>
+
+        [Apple Pay] Add testing and logging for ApplePaySetup
+        https://bugs.webkit.org/show_bug.cgi?id=211972
+        <rdar://problem/63291965>
+
+        Reviewed by Alex Christensen.
+
+        Test: http/tests/ssl/applepay/ApplePaySetup.https.html
+
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Modules/applepay/ApplePaySetup.cpp:
+        (WebCore::ApplePaySetup::getSetupFeatures):
+        (WebCore::ApplePaySetup::begin):
+        (WebCore::ApplePaySetup::ApplePaySetup):
+        (WebCore::ApplePaySetup::stop):
+        * Modules/applepay/ApplePaySetup.idl:
+        * Modules/applepay/ApplePaySetupConfiguration.h: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureType.idl.
+        * Modules/applepay/ApplePaySetupConfiguration.idl: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureType.idl.
+        * Modules/applepay/ApplePaySetupFeature.idl:
+        * Modules/applepay/ApplePaySetupFeature.mm:
+        (WebCore::ApplePaySetupFeature::state const):
+        * Modules/applepay/ApplePaySetupFeatureState.h: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureType.idl.
+        * Modules/applepay/ApplePaySetupFeatureState.idl: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureType.idl.
+        * Modules/applepay/ApplePaySetupFeatureType.idl:
+        * Modules/applepay/ApplePaySetupFeatureWebCore.h:
+        * Modules/applepay/ApplePaySetupWebCore.h:
+        (WebCore::ApplePaySetup::create):
+        * Modules/applepay/PaymentCoordinator.cpp:
+        (WebCore::PaymentCoordinator::setApplePayIsActiveIfAllowed const):
+        (WebCore::PaymentCoordinator::getSetupFeatures):
+        (WebCore::PaymentCoordinator::beginApplePaySetup):
+        (WebCore::PaymentCoordinator::endApplePaySetup):
+        * Modules/applepay/PaymentCoordinator.h:
+        * Modules/applepay/PaymentCoordinatorClient.h:
+        (WebCore::PaymentCoordinatorClient::getSetupFeatures):
+        (WebCore::PaymentCoordinatorClient::beginApplePaySetup):
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * testing/MockApplePaySetupFeature.cpp: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureWebCore.h.
+        (WebCore::MockApplePaySetupFeature::create):
+        (WebCore::MockApplePaySetupFeature::MockApplePaySetupFeature):
+        * testing/MockApplePaySetupFeature.h: Copied from Source/WebCore/Modules/applepay/ApplePaySetupFeatureWebCore.h.
+        * testing/MockPaymentCoordinator.cpp:
+        (WebCore::MockPaymentCoordinator::addSetupFeature):
+        (WebCore::MockPaymentCoordinator::getSetupFeatures):
+        (WebCore::MockPaymentCoordinator::beginApplePaySetup):
+        * testing/MockPaymentCoordinator.h:
+        * testing/MockPaymentCoordinator.idl:
+
 2020-05-19  Sergio Villar Senin  <svillar@igalia.com>
 
         [WebXR] Implement requestSession()
index 5a8da6a..7fa9478 100644 (file)
@@ -41,7 +41,9 @@ $(PROJECT_DIR)/Modules/applepay/ApplePayRequestBase.idl
 $(PROJECT_DIR)/Modules/applepay/ApplePaySession.idl
 $(PROJECT_DIR)/Modules/applepay/ApplePaySessionError.idl
 $(PROJECT_DIR)/Modules/applepay/ApplePaySetup.idl
+$(PROJECT_DIR)/Modules/applepay/ApplePaySetupConfiguration.idl
 $(PROJECT_DIR)/Modules/applepay/ApplePaySetupFeature.idl
+$(PROJECT_DIR)/Modules/applepay/ApplePaySetupFeatureState.idl
 $(PROJECT_DIR)/Modules/applepay/ApplePaySetupFeatureType.idl
 $(PROJECT_DIR)/Modules/applepay/ApplePayShippingContactSelectedEvent.idl
 $(PROJECT_DIR)/Modules/applepay/ApplePayShippingContactUpdate.idl
@@ -1133,6 +1135,7 @@ $(PROJECT_DIR)/testing/InternalsMapLike.idl
 $(PROJECT_DIR)/testing/InternalsSetLike.idl
 $(PROJECT_DIR)/testing/MallocStatistics.idl
 $(PROJECT_DIR)/testing/MemoryInfo.idl
+$(PROJECT_DIR)/testing/MockApplePaySetupFeature.idl
 $(PROJECT_DIR)/testing/MockCDMFactory.idl
 $(PROJECT_DIR)/testing/MockContentFilterSettings.idl
 $(PROJECT_DIR)/testing/MockPageOverlay.idl
index f3e9762..2545157 100644 (file)
@@ -115,8 +115,12 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySessionError.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySessionError.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySetup.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySetup.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySetupConfiguration.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySetupConfiguration.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySetupFeature.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySetupFeature.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySetupFeatureState.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySetupFeatureState.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySetupFeatureType.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePaySetupFeatureType.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePayShippingContactSelectedEvent.cpp
@@ -1086,6 +1090,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMessageEvent.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMessageEvent.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMessagePort.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMessagePort.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMockApplePaySetupFeature.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMockApplePaySetupFeature.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMockCDMFactory.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMockCDMFactory.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMockContentFilterSettings.cpp
index 2a3ef90..e3dc345 100644 (file)
@@ -120,7 +120,9 @@ JS_BINDING_IDLS = \
     $(WebCore)/Modules/applepay/ApplePaySession.idl \
     $(WebCore)/Modules/applepay/ApplePaySessionError.idl \
     $(WebCore)/Modules/applepay/ApplePaySetup.idl \
+       $(WebCore)/Modules/applepay/ApplePaySetupConfiguration.idl \
     $(WebCore)/Modules/applepay/ApplePaySetupFeature.idl \
+       $(WebCore)/Modules/applepay/ApplePaySetupFeatureState.idl \
     $(WebCore)/Modules/applepay/ApplePaySetupFeatureType.idl \
     $(WebCore)/Modules/applepay/ApplePayShippingContactSelectedEvent.idl \
     $(WebCore)/Modules/applepay/ApplePayShippingContactUpdate.idl \
index e8c2b1f..cfc0ddd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -76,7 +76,7 @@ void ApplePaySetup::getSetupFeatures(Document& document, SetupFeaturesPromise&&
 
     m_setupFeaturesPromise = WTFMove(promise);
 
-    page->paymentCoordinator().client().getSetupFeatures(m_configuration, document.url(), [this, pendingActivity = makePendingActivity(*this)](Vector<Ref<ApplePaySetupFeature>>&& setupFeatures) {
+    page->paymentCoordinator().getSetupFeatures(m_configuration, document.url(), [this, pendingActivity = makePendingActivity(*this)](Vector<Ref<ApplePaySetupFeature>>&& setupFeatures) {
         if (m_setupFeaturesPromise)
             std::exchange(m_setupFeaturesPromise, WTF::nullopt)->settle(WTFMove(setupFeatures));
     });
@@ -109,13 +109,13 @@ void ApplePaySetup::begin(Document& document, Vector<RefPtr<ApplePaySetupFeature
     m_beginPromise = WTFMove(promise);
     m_pendingActivity = makePendingActivity(*this);
 
-    page->paymentCoordinator().client().beginApplePaySetup(m_configuration, document.url(), WTFMove(features), [this](bool result) {
+    page->paymentCoordinator().beginApplePaySetup(m_configuration, document.url(), WTFMove(features), [this](bool result) {
         if (m_beginPromise)
             std::exchange(m_beginPromise, WTF::nullopt)->settle(result);
     });
 }
 
-ApplePaySetup::ApplePaySetup(ScriptExecutionContext& context, Configuration&& configuration)
+ApplePaySetup::ApplePaySetup(ScriptExecutionContext& context, ApplePaySetupConfiguration&& configuration)
     : ActiveDOMObject(&context)
     , m_configuration(WTFMove(configuration))
 {
@@ -131,7 +131,7 @@ void ApplePaySetup::stop()
         std::exchange(m_beginPromise, WTF::nullopt)->settle(Exception { AbortError });
 
     if (auto page = downcast<Document>(*scriptExecutionContext()).page())
-        page->paymentCoordinator().client().endApplePaySetup();
+        page->paymentCoordinator().endApplePaySetup();
 
     m_pendingActivity = nullptr;
 }
index 57a465b..a5d0bcf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 [
-    Conditional=APPLE_PAY_SETUP,
-] dictionary ApplePaySetupConfiguration {
-    DOMString merchantIdentifier;
-    DOMString referrerIdentifier;
-    DOMString signature;
-    sequence<DOMString> signedFields;
-};
-
-[
     ActiveDOMObject,
     Conditional=APPLE_PAY_SETUP,
     Constructor(ApplePaySetupConfiguration configuration),
@@ -43,3 +34,4 @@
     [CallWith=Document] Promise<sequence<ApplePaySetupFeature>> getSetupFeatures();
     [CallWith=Document] Promise<boolean> begin(sequence<ApplePaySetupFeature> setupFeatures);
 };
+
diff --git a/Source/WebCore/Modules/applepay/ApplePaySetupConfiguration.h b/Source/WebCore/Modules/applepay/ApplePaySetupConfiguration.h
new file mode 100644 (file)
index 0000000..4493580
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(APPLE_PAY_SETUP)
+
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+struct ApplePaySetupConfiguration {
+    String merchantIdentifier;
+    String referrerIdentifier;
+    String signature;
+    Vector<String> signedFields;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY_SETUP)
diff --git a/Source/WebCore/Modules/applepay/ApplePaySetupConfiguration.idl b/Source/WebCore/Modules/applepay/ApplePaySetupConfiguration.idl
new file mode 100644 (file)
index 0000000..7e040e4
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=APPLE_PAY_SETUP,
+    ExportMacro=WEBCORE_EXPORT,
+    JSGenerateToJSObject,
+] dictionary ApplePaySetupConfiguration {
+    DOMString merchantIdentifier;
+    DOMString referrerIdentifier;
+    DOMString signature;
+    sequence<DOMString> signedFields;
+};
+
index 516dbbc..edbdfae 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 [
     Conditional=APPLE_PAY_SETUP,
-] enum ApplePaySetupFeatureState {
-    "unsupported",
-    "supported",
-    "supplementarySupported",
-    "completed"
-};
-
-[
-    Conditional=APPLE_PAY_SETUP,
     EnabledBySetting=ApplePay,
-    ImplementationLacksVTable,
+    ExportMacro=WEBCORE_EXPORT,
     SecureContext,
+    SkipVTableValidation,
 ] interface ApplePaySetupFeature {
     [CachedAttribute] readonly attribute ApplePaySetupFeatureType type;
     [CachedAttribute] readonly attribute ApplePaySetupFeatureState state;
     [CachedAttribute, Conditional=APPLE_PAY_INSTALLMENTS] readonly attribute boolean supportsInstallments;
 };
+
index 586a0aa..d677b07 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #if ENABLE(APPLE_PAY_SETUP)
 
+#import "ApplePaySetupFeatureState.h"
 #import "ApplePaySetupFeatureTypeWebCore.h"
 #import <pal/spi/cocoa/PassKitSPI.h>
 
 namespace WebCore {
 
+ApplePaySetupFeature::ApplePaySetupFeature() = default;
+ApplePaySetupFeature::~ApplePaySetupFeature() = default;
+
 ApplePaySetupFeatureType ApplePaySetupFeature::type() const
 {
     switch ([m_feature type]) {
@@ -45,17 +49,17 @@ ApplePaySetupFeatureType ApplePaySetupFeature::type() const
     }
 }
 
-ApplePaySetupFeature::State ApplePaySetupFeature::state() const
+ApplePaySetupFeatureState ApplePaySetupFeature::state() const
 {
     switch ([m_feature state]) {
     case PKPaymentSetupFeatureStateUnsupported:
-        return State::Unsupported;
+        return ApplePaySetupFeatureState::Unsupported;
     case PKPaymentSetupFeatureStateSupported:
-        return State::Supported;
+        return ApplePaySetupFeatureState::Supported;
     case PKPaymentSetupFeatureStateSupplementarySupported:
-        return State::SupplementarySupported;
+        return ApplePaySetupFeatureState::SupplementarySupported;
     case PKPaymentSetupFeatureStateCompleted:
-        return State::Completed;
+        return ApplePaySetupFeatureState::Completed;
     }
 }
 
diff --git a/Source/WebCore/Modules/applepay/ApplePaySetupFeatureState.h b/Source/WebCore/Modules/applepay/ApplePaySetupFeatureState.h
new file mode 100644 (file)
index 0000000..c5fa164
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(APPLE_PAY_SETUP)
+
+namespace WebCore {
+
+enum class ApplePaySetupFeatureState : uint8_t {
+    Unsupported,
+    Supported,
+    SupplementarySupported,
+    Completed,
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY_SETUP)
diff --git a/Source/WebCore/Modules/applepay/ApplePaySetupFeatureState.idl b/Source/WebCore/Modules/applepay/ApplePaySetupFeatureState.idl
new file mode 100644 (file)
index 0000000..36f49b8
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=APPLE_PAY_SETUP,
+    ExportMacro=WEBCORE_EXPORT,
+] enum ApplePaySetupFeatureState {
+    "unsupported",
+    "supported",
+    "supplementarySupported",
+    "completed"
+};
+
index a4961ad..5d0a957 100644 (file)
@@ -25,7 +25,9 @@
 
 [
     Conditional=APPLE_PAY_SETUP,
+    ExportMacro=WEBCORE_EXPORT,
 ] enum ApplePaySetupFeatureType {
     "applePay",
     "appleCard"
 };
+
index 15c1152..d85ef06 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -34,6 +34,7 @@ OBJC_CLASS PKPaymentSetupFeature;
 
 namespace WebCore {
 
+enum class ApplePaySetupFeatureState : uint8_t;
 enum class ApplePaySetupFeatureType : uint8_t;
 
 class ApplePaySetupFeature : public RefCounted<ApplePaySetupFeature> {
@@ -42,23 +43,21 @@ public:
     {
         return adoptRef(*new ApplePaySetupFeature(feature));
     }
+    
+    WEBCORE_EXPORT virtual ~ApplePaySetupFeature();
 
-    ApplePaySetupFeatureType type() const;
-
-    enum class State : uint8_t {
-        Unsupported,
-        Supported,
-        SupplementarySupported,
-        Completed,
-    };
-    State state() const;
+    virtual ApplePaySetupFeatureState state() const;
+    virtual ApplePaySetupFeatureType type() const;
 
     PKPaymentSetupFeature *platformFeature() const { return m_feature.get(); }
 
 #if ENABLE(APPLE_PAY_INSTALLMENTS)
-    bool supportsInstallments() const;
+    virtual bool supportsInstallments() const;
 #endif
 
+protected:
+    WEBCORE_EXPORT ApplePaySetupFeature();
+
 private:
     WEBCORE_EXPORT explicit ApplePaySetupFeature(PKPaymentSetupFeature *);
 
index 6cc74c4..887d213 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2020 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(APPLE_PAY_SETUP)
 
+#include "ApplePaySetupConfiguration.h"
 #include <WebCore/ActiveDOMObject.h>
 #include <WebCore/JSDOMPromiseDeferred.h>
 #include <wtf/Forward.h>
@@ -42,14 +43,7 @@ class Document;
 
 class ApplePaySetup : public ActiveDOMObject, public RefCounted<ApplePaySetup> {
 public:
-    struct Configuration {
-        String merchantIdentifier;
-        String referrerIdentifier;
-        String signature;
-        Vector<String> signedFields;
-    };
-
-    static Ref<ApplePaySetup> create(ScriptExecutionContext& context, Configuration&& configuration)
+    static Ref<ApplePaySetup> create(ScriptExecutionContext& context, ApplePaySetupConfiguration&& configuration)
     {
         return adoptRef(*new ApplePaySetup(context, WTFMove(configuration)));
     }
@@ -61,14 +55,14 @@ public:
     void begin(Document&, Vector<RefPtr<ApplePaySetupFeature>>&&, BeginPromise&&);
 
 private:
-    ApplePaySetup(ScriptExecutionContext&, Configuration&&);
+    ApplePaySetup(ScriptExecutionContext&, ApplePaySetupConfiguration&&);
 
     // ActiveDOMObject
     const char* activeDOMObjectName() const final { return "ApplePaySetup"; }
     void stop() final;
     void suspend(ReasonForSuspension) final;
 
-    Configuration m_configuration;
+    ApplePaySetupConfiguration m_configuration;
     Optional<SetupFeaturesPromise> m_setupFeaturesPromise;
     Optional<BeginPromise> m_beginPromise;
     RefPtr<PendingActivity<ApplePaySetup>> m_pendingActivity;
index 92d873f..d94466a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -284,7 +284,6 @@ bool PaymentCoordinator::setApplePayIsActiveIfAllowed(Document& document) const
         return false;
     }
 
-    RELEASE_LOG_IF_ALLOWED("setApplePayIsActiveIfAllowed() -> true (supportsUnrestrictedApplePay: %d)", supportsUnrestrictedApplePay);
     document.setApplePayIsActive();
     return true;
 }
@@ -300,6 +299,38 @@ Expected<void, ExceptionDetails> PaymentCoordinator::shouldAllowUserAgentScripts
     return makeUnexpected(ExceptionDetails { m_client.userAgentScriptsBlockedErrorMessage() });
 }
 
+#if ENABLE(APPLE_PAY_SETUP)
+
+void PaymentCoordinator::getSetupFeatures(const ApplePaySetupConfiguration& configuration, const URL& url, CompletionHandler<void(Vector<Ref<ApplePaySetupFeature>>&&)>&& completionHandler)
+{
+    RELEASE_LOG_IF_ALLOWED("getSetupFeatures()");
+    m_client.getSetupFeatures(configuration, url, [this, weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)](Vector<Ref<ApplePaySetupFeature>>&& features) mutable {
+        if (!weakThis)
+            return;
+        RELEASE_LOG_IF_ALLOWED("getSetupFeatures() completed (features: %zu)", features.size());
+        completionHandler(WTFMove(features));
+    });
+}
+
+void PaymentCoordinator::beginApplePaySetup(const ApplePaySetupConfiguration& configuration, const URL& url, Vector<RefPtr<ApplePaySetupFeature>>&& features, CompletionHandler<void(bool)>&& completionHandler)
+{
+    RELEASE_LOG_IF_ALLOWED("beginApplePaySetup()");
+    m_client.beginApplePaySetup(configuration, url, WTFMove(features), [this, weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)](bool success) mutable {
+        if (!weakThis)
+            return;
+        RELEASE_LOG_IF_ALLOWED("beginApplePaySetup() completed (success: %d)", success);
+        completionHandler(success);
+    });
+}
+
+void PaymentCoordinator::endApplePaySetup()
+{
+    RELEASE_LOG_IF_ALLOWED("endApplePaySetup()");
+    m_client.endApplePaySetup();
+}
+
+#endif
+
 } // namespace WebCore
 
 #undef RELEASE_LOG_ERROR_IF_ALLOWED
index bfeca8f..97d86e7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -34,6 +34,7 @@
 
 namespace WebCore {
 
+class ApplePaySetupFeature;
 class Document;
 class Payment;
 class PaymentCoordinatorClient;
@@ -44,6 +45,7 @@ class PaymentMethodUpdate;
 class PaymentSession;
 class PaymentSessionError;
 enum class PaymentAuthorizationStatus;
+struct ApplePaySetupConfiguration;
 struct ExceptionDetails;
 struct PaymentAuthorizationResult;
 struct ShippingContactUpdate;
@@ -85,6 +87,12 @@ public:
     bool shouldEnableApplePayAPIs(Document&) const;
     WEBCORE_EXPORT Expected<void, ExceptionDetails> shouldAllowUserAgentScripts(Document&) const;
 
+#if ENABLE(APPLE_PAY_SETUP)
+    void getSetupFeatures(const ApplePaySetupConfiguration&, const URL&, CompletionHandler<void(Vector<Ref<ApplePaySetupFeature>>&&)>&&);
+    void beginApplePaySetup(const ApplePaySetupConfiguration&, const URL&, Vector<RefPtr<ApplePaySetupFeature>>&&, CompletionHandler<void(bool)>&&);
+    void endApplePaySetup();
+#endif
+
 private:
     bool setApplePayIsActiveIfAllowed(Document&) const;
 
index 1b84e7e..553d9cd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,7 +29,6 @@
 
 #include "ApplePaySessionPaymentRequest.h"
 #include "ApplePaySetupFeatureWebCore.h"
-#include "ApplePaySetupWebCore.h"
 #include <wtf/CompletionHandler.h>
 #include <wtf/Forward.h>
 #include <wtf/Function.h>
@@ -39,6 +38,7 @@ namespace WebCore {
 class Document;
 class PaymentMerchantSession;
 class PaymentMethodUpdate;
+struct ApplePaySetupConfiguration;
 struct PaymentAuthorizationResult;
 struct ShippingContactUpdate;
 struct ShippingMethodUpdate;
@@ -71,8 +71,8 @@ public:
     virtual bool isAlwaysOnLoggingAllowed() const { return false; }
 
 #if ENABLE(APPLE_PAY_SETUP)
-    virtual void getSetupFeatures(const ApplePaySetup::Configuration&, const URL&, CompletionHandler<void(Vector<Ref<ApplePaySetupFeature>>&&)>&& completionHandler) { completionHandler({ }); }
-    virtual void beginApplePaySetup(const ApplePaySetup::Configuration&, const URL&, Vector<RefPtr<ApplePaySetupFeature>>&&, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(false); }
+    virtual void getSetupFeatures(const ApplePaySetupConfiguration&, const URL&, CompletionHandler<void(Vector<Ref<ApplePaySetupFeature>>&&)>&& completionHandler) { completionHandler({ }); }
+    virtual void beginApplePaySetup(const ApplePaySetupConfiguration&, const URL&, Vector<RefPtr<ApplePaySetupFeature>>&&, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(false); }
     virtual void endApplePaySetup() { }
 #endif
 
index dbf7f63..31f3d26 100644 (file)
@@ -641,7 +641,9 @@ WHLSLStandardLibraryFunctionMap.cpp
     JSApplePaySession.cpp
     JSApplePaySessionError.cpp
     JSApplePaySetup.cpp
+    JSApplePaySetupConfiguration.cpp
     JSApplePaySetupFeature.cpp
+    JSApplePaySetupFeatureState.cpp
     JSApplePaySetupFeatureType.cpp
     JSApplePayShippingContactSelectedEvent.cpp
     JSApplePayShippingContactUpdate.cpp
index 3fb15be..d9cc79a 100644 (file)
                A110DB9B14F5DF7700A03B93 /* StyleGridItemData.h in Headers */ = {isa = PBXBuildFile; fileRef = A110DB9A14F5DF7700A03B93 /* StyleGridItemData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A113E02823318293009C33A0 /* PaymentSessionError.h in Headers */ = {isa = PBXBuildFile; fileRef = A113E02723318293009C33A0 /* PaymentSessionError.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A113E02E2331A134009C33A0 /* ApplePayCancelEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A113E02B2331A0E4009C33A0 /* ApplePayCancelEvent.h */; };
+               A11750872474403100D4D26C /* JSApplePayInstallmentConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = A11750832474400200D4D26C /* JSApplePayInstallmentConfiguration.h */; };
+               A11750882474405500D4D26C /* JSApplePaySetup.h in Headers */ = {isa = PBXBuildFile; fileRef = A11750842474400300D4D26C /* JSApplePaySetup.h */; };
+               A11750892474407C00D4D26C /* JSApplePaySetupFeature.h in Headers */ = {isa = PBXBuildFile; fileRef = A11750822474400100D4D26C /* JSApplePaySetupFeature.h */; };
+               A117508A247440A400D4D26C /* JSApplePaySetupFeatureType.h in Headers */ = {isa = PBXBuildFile; fileRef = A11750802474400000D4D26C /* JSApplePaySetupFeatureType.h */; };
+               A117508B247440B600D4D26C /* JSApplePayValidateMerchantEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A11750852474400400D4D26C /* JSApplePayValidateMerchantEvent.h */; };
                A11AE0CC1FFD60530047348B /* MerchantValidationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A11AE0C91FFD60530047348B /* MerchantValidationEvent.h */; };
                A11AE0D31FFD61DF0047348B /* JSMerchantValidationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A11AE0D11FFD61DF0047348B /* JSMerchantValidationEvent.h */; };
                A11E8C051B1E28F40003A7C7 /* copyCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = A11E8C001B1E28BE0003A7C7 /* copyCursor.png */; };
                A180AD5B219F81B000DC039A /* WebCoreAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = A17E4F26219BC01600E1C7EE /* WebCoreAdditions.mm */; };
                A185B42A1E8211A100DC9118 /* LegacyPreviewLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A185B4281E8211A100DC9118 /* LegacyPreviewLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A18890AF1AA13F250026C301 /* ParentalControlsContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = A18890AD1AA13F250026C301 /* ParentalControlsContentFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A1891045246DF6C6006BA9FC /* ApplePaySetupFeatureState.h in Headers */ = {isa = PBXBuildFile; fileRef = A1891042246DF6C6006BA9FC /* ApplePaySetupFeatureState.h */; };
+               A1891053246E1A34006BA9FC /* MockApplePaySetupFeature.h in Headers */ = {isa = PBXBuildFile; fileRef = A1891051246E1A34006BA9FC /* MockApplePaySetupFeature.h */; };
+               A1891054246E1A34006BA9FC /* MockApplePaySetupFeature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1891052246E1A34006BA9FC /* MockApplePaySetupFeature.cpp */; };
+               A1891059246F2C1B006BA9FC /* ApplePaySetupConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = A1891056246F2BC8006BA9FC /* ApplePaySetupConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A1956F1C2331A6770057E9D2 /* JSApplePayCancelEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A1956F1B2331A6460057E9D2 /* JSApplePayCancelEvent.h */; };
                A1956F202331A8C70057E9D2 /* ApplePaySessionError.h in Headers */ = {isa = PBXBuildFile; fileRef = A1956F1D2331A8C70057E9D2 /* ApplePaySessionError.h */; };
                A1956F232331ACF20057E9D2 /* WHLSLReplaceWith.h in Headers */ = {isa = PBXBuildFile; fileRef = 3351F70B22CAD8DA0015B40D /* WHLSLReplaceWith.h */; };
                A113E02A23318EBC009C33A0 /* PaymentSessionErrorCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PaymentSessionErrorCocoa.mm; sourceTree = "<group>"; };
                A113E02B2331A0E4009C33A0 /* ApplePayCancelEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePayCancelEvent.h; sourceTree = "<group>"; };
                A113E02C2331A0E4009C33A0 /* ApplePayCancelEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ApplePayCancelEvent.cpp; sourceTree = "<group>"; };
+               A117507D24743FFE00D4D26C /* JSApplePayInstallmentConfiguration.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePayInstallmentConfiguration.cpp; sourceTree = "<group>"; };
+               A117507F24743FFF00D4D26C /* JSApplePaySetup.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePaySetup.cpp; sourceTree = "<group>"; };
+               A11750802474400000D4D26C /* JSApplePaySetupFeatureType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSApplePaySetupFeatureType.h; sourceTree = "<group>"; };
+               A11750812474400100D4D26C /* JSApplePaySetupFeatureType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePaySetupFeatureType.cpp; sourceTree = "<group>"; };
+               A11750822474400100D4D26C /* JSApplePaySetupFeature.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSApplePaySetupFeature.h; sourceTree = "<group>"; };
+               A11750832474400200D4D26C /* JSApplePayInstallmentConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSApplePayInstallmentConfiguration.h; sourceTree = "<group>"; };
+               A11750842474400300D4D26C /* JSApplePaySetup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSApplePaySetup.h; sourceTree = "<group>"; };
+               A11750852474400400D4D26C /* JSApplePayValidateMerchantEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSApplePayValidateMerchantEvent.h; sourceTree = "<group>"; };
+               A11750862474400500D4D26C /* JSApplePaySetupFeature.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePaySetupFeature.cpp; sourceTree = "<group>"; };
                A11AE0C91FFD60530047348B /* MerchantValidationEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MerchantValidationEvent.h; sourceTree = "<group>"; };
                A11AE0CA1FFD60530047348B /* MerchantValidationEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MerchantValidationEvent.cpp; sourceTree = "<group>"; };
                A11AE0CB1FFD60530047348B /* MerchantValidationEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MerchantValidationEvent.idl; sourceTree = "<group>"; };
                A185B4281E8211A100DC9118 /* LegacyPreviewLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyPreviewLoader.h; sourceTree = "<group>"; };
                A18890AC1AA13F250026C301 /* ParentalControlsContentFilter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ParentalControlsContentFilter.mm; sourceTree = "<group>"; };
                A18890AD1AA13F250026C301 /* ParentalControlsContentFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParentalControlsContentFilter.h; sourceTree = "<group>"; };
+               A1891042246DF6C6006BA9FC /* ApplePaySetupFeatureState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePaySetupFeatureState.h; sourceTree = "<group>"; };
+               A1891044246DF6C6006BA9FC /* ApplePaySetupFeatureState.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ApplePaySetupFeatureState.idl; sourceTree = "<group>"; };
+               A1891051246E1A34006BA9FC /* MockApplePaySetupFeature.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockApplePaySetupFeature.h; sourceTree = "<group>"; };
+               A1891052246E1A34006BA9FC /* MockApplePaySetupFeature.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MockApplePaySetupFeature.cpp; sourceTree = "<group>"; };
+               A1891056246F2BC8006BA9FC /* ApplePaySetupConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePaySetupConfiguration.h; sourceTree = "<group>"; };
+               A1891058246F2BC8006BA9FC /* ApplePaySetupConfiguration.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ApplePaySetupConfiguration.idl; sourceTree = "<group>"; };
                A18F7A351ECA73640059E1E1 /* RuntimeApplicationChecks.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RuntimeApplicationChecks.cpp; sourceTree = "<group>"; };
                A1956F182331A4680057E9D2 /* ApplePayCancelEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ApplePayCancelEvent.idl; sourceTree = "<group>"; };
                A1956F1A2331A6460057E9D2 /* JSApplePayCancelEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePayCancelEvent.cpp; sourceTree = "<group>"; };
                                1A58E8641D19D4DF00C0EA73 /* ApplePaySessionPaymentRequest.h */,
                                5C53DCD22446449A00A93124 /* ApplePaySetup.cpp */,
                                5C53DCC62446449700A93124 /* ApplePaySetup.idl */,
+                               A1891056246F2BC8006BA9FC /* ApplePaySetupConfiguration.h */,
+                               A1891058246F2BC8006BA9FC /* ApplePaySetupConfiguration.idl */,
                                5C53DCCA2446449800A93124 /* ApplePaySetupFeature.idl */,
                                5C53DCC92446449800A93124 /* ApplePaySetupFeature.mm */,
+                               A1891042246DF6C6006BA9FC /* ApplePaySetupFeatureState.h */,
+                               A1891044246DF6C6006BA9FC /* ApplePaySetupFeatureState.idl */,
                                5C53DCD62446449C00A93124 /* ApplePaySetupFeatureType.idl */,
                                5C53DCD42446449B00A93124 /* ApplePaySetupFeatureTypeWebCore.h */,
                                5C53DCCF2446449900A93124 /* ApplePaySetupFeatureWebCore.h */,
                                A1BB85AE2159B1A00067E07D /* JSApplePayErrorCode.h */,
                                A1BB85AC2159B19F0067E07D /* JSApplePayErrorContactField.cpp */,
                                A1BB85AF2159B1A00067E07D /* JSApplePayErrorContactField.h */,
+                               A117507D24743FFE00D4D26C /* JSApplePayInstallmentConfiguration.cpp */,
+                               A11750832474400200D4D26C /* JSApplePayInstallmentConfiguration.h */,
                                7C6579E91E00856600E3A27A /* JSApplePayLineItem.cpp */,
                                7C6579EA1E00856600E3A27A /* JSApplePayLineItem.h */,
                                A1DF5A891F7EC0000058A477 /* JSApplePayMerchantCapability.cpp */,
                                1AE96A7F1D1A0A8000B86768 /* JSApplePaySession.h */,
                                A1D506132331ED970014EE4E /* JSApplePaySessionError.cpp */,
                                A1D506112331ED960014EE4E /* JSApplePaySessionError.h */,
+                               A117507F24743FFF00D4D26C /* JSApplePaySetup.cpp */,
+                               A11750842474400300D4D26C /* JSApplePaySetup.h */,
+                               A11750862474400500D4D26C /* JSApplePaySetupFeature.cpp */,
+                               A11750822474400100D4D26C /* JSApplePaySetupFeature.h */,
+                               A11750812474400100D4D26C /* JSApplePaySetupFeatureType.cpp */,
+                               A11750802474400000D4D26C /* JSApplePaySetupFeatureType.h */,
                                1AE96A801D1A0A8000B86768 /* JSApplePayShippingContactSelectedEvent.cpp */,
                                1AE96A811D1A0A8000B86768 /* JSApplePayShippingContactSelectedEvent.h */,
                                1ADFDFE71E71DCA0008F5D34 /* JSApplePayShippingContactUpdate.cpp */,
                                1ADFDFE91E71DCA0008F5D34 /* JSApplePayShippingMethodUpdate.cpp */,
                                1ADFDFEA1E71DCA0008F5D34 /* JSApplePayShippingMethodUpdate.h */,
                                1AE96A841D1A0A8000B86768 /* JSApplePayValidateMerchantEvent.cpp */,
+                               A11750852474400400D4D26C /* JSApplePayValidateMerchantEvent.h */,
                        );
                        name = ApplePay;
                        sourceTree = "<group>";
                                A7BE7EDE14C9175A0014489D /* MallocStatistics.idl */,
                                CD5393CB175DCCE600C07123 /* MemoryInfo.h */,
                                CD5393CC175DCCE600C07123 /* MemoryInfo.idl */,
+                               A1891052246E1A34006BA9FC /* MockApplePaySetupFeature.cpp */,
+                               A1891051246E1A34006BA9FC /* MockApplePaySetupFeature.h */,
                                CDF4B7211E03BF8100E235A2 /* MockCDMFactory.cpp */,
                                CDF4B7221E03BF8100E235A2 /* MockCDMFactory.h */,
                                CDF4B71F1E03BF6F00E235A2 /* MockCDMFactory.idl */,
                                427DA71E13735DFA007C57FB /* JSServiceWorkerInternals.h in Headers */,
                                EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */,
                                CDC26B41160A8CCE0026757B /* LegacyMockCDM.h in Headers */,
+                               A1891053246E1A34006BA9FC /* MockApplePaySetupFeature.h in Headers */,
                                A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */,
                                A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */,
                                51058ADC1D6792C1009A538C /* MockGamepad.h in Headers */,
                                1A8A64591D19FCFC00D0E00F /* ApplePaySession.h in Headers */,
                                A1956F202331A8C70057E9D2 /* ApplePaySessionError.h in Headers */,
                                1A58E8651D19D4EB00C0EA73 /* ApplePaySessionPaymentRequest.h in Headers */,
+                               A1891059246F2C1B006BA9FC /* ApplePaySetupConfiguration.h in Headers */,
+                               A1891045246DF6C6006BA9FC /* ApplePaySetupFeatureState.h in Headers */,
                                5C53DCE124465DFC00A93124 /* ApplePaySetupFeatureWebCore.h in Headers */,
                                5C53DCEA24468FB400A93124 /* ApplePaySetupWebCore.h in Headers */,
                                1A8A645C1D19FCFC00D0E00F /* ApplePayShippingContactSelectedEvent.h in Headers */,
                                A12C59F920360ACB0012236B /* JSApplePayError.h in Headers */,
                                A1BB85B22159B1A10067E07D /* JSApplePayErrorCode.h in Headers */,
                                A1BB85B32159B1A10067E07D /* JSApplePayErrorContactField.h in Headers */,
+                               A11750872474403100D4D26C /* JSApplePayInstallmentConfiguration.h in Headers */,
                                7C6579F01E00856600E3A27A /* JSApplePayLineItem.h in Headers */,
                                A1DF5A8E1F7EC0020058A477 /* JSApplePayMerchantCapability.h in Headers */,
                                A1F6D0121FE099B40018078C /* JSApplePayModifier.h in Headers */,
                                A1DF5AB31F8077530058A477 /* JSApplePayRequestBase.h in Headers */,
                                1AE96A8F1D1A0DDD00B86768 /* JSApplePaySession.h in Headers */,
                                A1D506142331EDD40014EE4E /* JSApplePaySessionError.h in Headers */,
+                               A11750882474405500D4D26C /* JSApplePaySetup.h in Headers */,
+                               A11750892474407C00D4D26C /* JSApplePaySetupFeature.h in Headers */,
+                               A117508A247440A400D4D26C /* JSApplePaySetupFeatureType.h in Headers */,
                                1AE96A911D1A0DDD00B86768 /* JSApplePayShippingContactSelectedEvent.h in Headers */,
                                A12C59FD20360B3E0012236B /* JSApplePayShippingContactUpdate.h in Headers */,
                                7C6579F41E00856600E3A27A /* JSApplePayShippingMethod.h in Headers */,
                                1AE96A931D1A0DDD00B86768 /* JSApplePayShippingMethodSelectedEvent.h in Headers */,
                                A12C59FE20360B4A0012236B /* JSApplePayShippingMethodUpdate.h in Headers */,
+                               A117508B247440B600D4D26C /* JSApplePayValidateMerchantEvent.h in Headers */,
                                57D1352C2294AA3D00827401 /* JSAttestationConveyancePreference.h in Headers */,
                                65DF31DB09D1C123000BE325 /* JSAttr.h in Headers */,
                                FDA15E9E12B03EE1003A583A /* JSAudioBuffer.h in Headers */,
                                427DA71D13735DFA007C57FB /* JSServiceWorkerInternals.cpp in Sources */,
                                EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */,
                                CDC26B40160A8CC60026757B /* LegacyMockCDM.cpp in Sources */,
+                               A1891054246E1A34006BA9FC /* MockApplePaySetupFeature.cpp in Sources */,
                                CDF4B7311E03D00700E235A2 /* MockCDMFactory.cpp in Sources */,
                                A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */,
                                A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */,
diff --git a/Source/WebCore/testing/MockApplePaySetupFeature.cpp b/Source/WebCore/testing/MockApplePaySetupFeature.cpp
new file mode 100644 (file)
index 0000000..86b1ecc
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MockApplePaySetupFeature.h"
+
+#if ENABLE(APPLE_PAY_SETUP)
+
+namespace WebCore {
+
+Ref<MockApplePaySetupFeature> MockApplePaySetupFeature::create(ApplePaySetupFeatureState state, ApplePaySetupFeatureType type, bool supportsInstallments)
+{
+    return adoptRef(*new MockApplePaySetupFeature(state, type, supportsInstallments));
+}
+
+MockApplePaySetupFeature::MockApplePaySetupFeature(ApplePaySetupFeatureState state, ApplePaySetupFeatureType type, bool supportsInstallments)
+    : ApplePaySetupFeature()
+    , m_state(state)
+    , m_type(type)
+#if ENABLE(APPLE_PAY_INSTALLMENTS)
+    , m_supportsInstallments(supportsInstallments)
+#endif
+{
+    UNUSED_PARAM(supportsInstallments);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY_SETUP)
diff --git a/Source/WebCore/testing/MockApplePaySetupFeature.h b/Source/WebCore/testing/MockApplePaySetupFeature.h
new file mode 100644 (file)
index 0000000..7705f29
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(APPLE_PAY_SETUP)
+
+#include "ApplePaySetupFeatureWebCore.h"
+
+namespace WebCore {
+
+class MockApplePaySetupFeature final : public ApplePaySetupFeature {
+public:
+    static Ref<MockApplePaySetupFeature> create(ApplePaySetupFeatureState, ApplePaySetupFeatureType, bool supportsInstallments);
+    
+    ApplePaySetupFeatureState state() const final { return m_state; }
+    ApplePaySetupFeatureType type() const final { return m_type; }
+
+#if ENABLE(APPLE_PAY_INSTALLMENTS)
+    bool supportsInstallments() const final { return m_supportsInstallments; }
+#endif
+
+private:
+    MockApplePaySetupFeature(ApplePaySetupFeatureState, ApplePaySetupFeatureType, bool supportsInstallments);
+
+    ApplePaySetupFeatureState m_state;
+    ApplePaySetupFeatureType m_type;
+#if ENABLE(APPLE_PAY_INSTALLMENTS)
+    bool m_supportsInstallments;
+#endif
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY_SETUP)
index 782dd7e..d89d87b 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(APPLE_PAY)
 
 #include "ApplePaySessionPaymentRequest.h"
+#include "MockApplePaySetupFeature.h"
 #include "MockPayment.h"
 #include "MockPaymentContact.h"
 #include "MockPaymentMethod.h"
@@ -231,6 +232,28 @@ void MockPaymentCoordinator::paymentCoordinatorDestroyed()
     delete this;
 }
 
+#if ENABLE(APPLE_PAY_SETUP)
+
+void MockPaymentCoordinator::addSetupFeature(ApplePaySetupFeatureState state, ApplePaySetupFeatureType type, bool supportsInstallments)
+{
+    m_setupFeatures.append(MockApplePaySetupFeature::create(state, type, supportsInstallments));
+}
+
+void MockPaymentCoordinator::getSetupFeatures(const ApplePaySetupConfiguration& configuration, const URL&, CompletionHandler<void(Vector<Ref<ApplePaySetupFeature>>&&)>&& completionHandler)
+{
+    m_setupConfiguration = configuration;
+    auto setupFeaturesCopy = m_setupFeatures;
+    completionHandler(WTFMove(setupFeaturesCopy));
+}
+
+void MockPaymentCoordinator::beginApplePaySetup(const ApplePaySetupConfiguration& configuration, const URL&, Vector<RefPtr<ApplePaySetupFeature>>&&, CompletionHandler<void(bool)>&& completionHandler)
+{
+    m_setupConfiguration = configuration;
+    completionHandler(true);
+}
+
+#endif
+
 } // namespace WebCore
 
 #endif // ENABLE(APPLE_PAY)
index a444162..881fa0a 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "ApplePayInstallmentConfigurationWebCore.h"
 #include "ApplePayLineItem.h"
+#include "ApplePaySetupConfiguration.h"
 #include "ApplePayShippingMethod.h"
 #include "MockPaymentAddress.h"
 #include "MockPaymentContactFields.h"
@@ -53,6 +54,11 @@ public:
     void changePaymentMethod(ApplePayPaymentMethod&&);
     void acceptPayment();
     void cancelPayment();
+    
+#if ENABLE(APPLE_PAY_SETUP)
+    void addSetupFeature(ApplePaySetupFeatureState, ApplePaySetupFeatureType, bool supportsInstallments);
+    const ApplePaySetupConfiguration& setupConfiguration() const { return m_setupConfiguration; }
+#endif
 
     const ApplePayLineItem& total() const { return m_total; }
     const Vector<ApplePayLineItem>& lineItems() const { return m_lineItems; }
@@ -90,6 +96,11 @@ private:
 
     bool isAlwaysOnLoggingAllowed() const final { return true; }
 
+#if ENABLE(APPLE_PAY_SETUP)
+    void getSetupFeatures(const ApplePaySetupConfiguration&, const URL&, CompletionHandler<void(Vector<Ref<ApplePaySetupFeature>>&&)>&&) final;
+    void beginApplePaySetup(const ApplePaySetupConfiguration&, const URL&, Vector<RefPtr<ApplePaySetupFeature>>&&, CompletionHandler<void(bool)>&&) final;
+#endif
+
     void updateTotalAndLineItems(const ApplePaySessionPaymentRequest::TotalAndLineItems&);
 
     Page& m_page;
@@ -107,6 +118,10 @@ private:
 #if ENABLE(APPLE_PAY_INSTALLMENTS)
     ApplePayInstallmentConfiguration m_installmentConfiguration;
 #endif
+#if ENABLE(APPLE_PAY_SETUP)
+    ApplePaySetupConfiguration m_setupConfiguration;
+    Vector<Ref<ApplePaySetupFeature>> m_setupFeatures;
+#endif
 };
 
 } // namespace WebCore
index 7934b50..3c64106 100644 (file)
@@ -35,6 +35,8 @@
     void acceptPayment();
     void cancelPayment();
 
+    [Conditional=APPLE_PAY_SETUP] void addSetupFeature(ApplePaySetupFeatureState state, ApplePaySetupFeatureType type, boolean supportsInstallments);
+
     readonly attribute ApplePayLineItem total;
     readonly attribute sequence<ApplePayLineItem> lineItems;
     readonly attribute sequence<MockPaymentError> errors;
@@ -42,6 +44,8 @@
     readonly attribute MockPaymentContactFields requiredBillingContactFields;
     readonly attribute MockPaymentContactFields requiredShippingContactFields;
 
+    [Conditional=APPLE_PAY_SETUP] readonly attribute ApplePaySetupConfiguration setupConfiguration;
+
     attribute boolean supportsUnrestrictedApplePay;
 
     [Conditional=APPLE_PAY_INSTALLMENTS] readonly attribute ApplePayInstallmentConfiguration installmentConfiguration;
index ac54fc6..cbe62fe 100644 (file)
@@ -1,3 +1,20 @@
+2020-05-19  Andy Estes  <aestes@apple.com>
+
+        [Apple Pay] Add testing and logging for ApplePaySetup
+        https://bugs.webkit.org/show_bug.cgi?id=211972
+        <rdar://problem/63291965>
+
+        Reviewed by Alex Christensen.
+
+        * Shared/ApplePay/PaymentSetupConfiguration.mm:
+        (WebKit::toPlatformConfiguration):
+        (WebKit::PaymentSetupConfiguration::PaymentSetupConfiguration):
+        * Shared/ApplePay/PaymentSetupConfigurationWebKit.h:
+        * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
+        (WebKit::WebPaymentCoordinator::getSetupFeatures):
+        (WebKit::WebPaymentCoordinator::beginApplePaySetup):
+        * WebProcess/ApplePay/WebPaymentCoordinator.h:
+
 2020-05-19  Brent Fulgham  <bfulgham@apple.com>
 
         REGRESSION(r243149): createMediaElementSource not working
index 622b329..b15d113 100644 (file)
@@ -31,6 +31,7 @@
 #import "ArgumentCodersCocoa.h"
 #import "Decoder.h"
 #import "Encoder.h"
+#import <WebCore/ApplePaySetupConfiguration.h>
 #import <wtf/URL.h>
 
 #import <pal/cocoa/PassKitSoftLink.h>
@@ -41,7 +42,7 @@
 
 namespace WebKit {
 
-static RetainPtr<PKPaymentSetupConfiguration> toPlatformConfiguration(const WebCore::ApplePaySetup::Configuration& coreConfiguration, const URL& url)
+static RetainPtr<PKPaymentSetupConfiguration> toPlatformConfiguration(const WebCore::ApplePaySetupConfiguration& coreConfiguration, const URL& url)
 {
 #if PLATFORM(MAC)
     if (!PAL::getPKPaymentSetupConfigurationClass())
@@ -66,7 +67,7 @@ ALLOW_NEW_API_WITHOUT_GUARDS_END
     return configuration;
 }
 
-PaymentSetupConfiguration::PaymentSetupConfiguration(const WebCore::ApplePaySetup::Configuration& configuration, const URL& url)
+PaymentSetupConfiguration::PaymentSetupConfiguration(const WebCore::ApplePaySetupConfiguration& configuration, const URL& url)
     : m_configuration { toPlatformConfiguration(configuration, url) }
 {
 }
index 8bee36a..ec9beb9 100644 (file)
@@ -27,7 +27,6 @@
 
 #if HAVE(PASSKIT_PAYMENT_SETUP)
 
-#include <WebCore/ApplePaySetupWebCore.h>
 #include <wtf/Forward.h>
 #include <wtf/RetainPtr.h>
 
@@ -38,12 +37,16 @@ class Decoder;
 class Encoder;
 }
 
+namespace WebCore {
+struct ApplePaySetupConfiguration;
+}
+
 namespace WebKit {
 
 class PaymentSetupConfiguration {
 public:
     PaymentSetupConfiguration() = default;
-    PaymentSetupConfiguration(const WebCore::ApplePaySetup::Configuration&, const URL&);
+    PaymentSetupConfiguration(const WebCore::ApplePaySetupConfiguration&, const URL&);
 
     void encode(IPC::Encoder&) const;
     static Optional<PaymentSetupConfiguration> decode(IPC::Decoder&);
index 60cebb1..f811042 100644 (file)
@@ -224,12 +224,12 @@ bool WebPaymentCoordinator::remoteUIEnabled() const
 
 #if ENABLE(APPLE_PAY_SETUP)
 
-void WebPaymentCoordinator::getSetupFeatures(const WebCore::ApplePaySetup::Configuration& configuration, const URL& url, CompletionHandler<void(Vector<Ref<WebCore::ApplePaySetupFeature>>&&)>&& completionHandler)
+void WebPaymentCoordinator::getSetupFeatures(const WebCore::ApplePaySetupConfiguration& configuration, const URL& url, CompletionHandler<void(Vector<Ref<WebCore::ApplePaySetupFeature>>&&)>&& completionHandler)
 {
     m_webPage.sendWithAsyncReply(Messages::WebPaymentCoordinatorProxy::GetSetupFeatures(PaymentSetupConfiguration { configuration, url }), WTFMove(completionHandler));
 }
 
-void WebPaymentCoordinator::beginApplePaySetup(const WebCore::ApplePaySetup::Configuration& configuration, const URL& url, Vector<RefPtr<WebCore::ApplePaySetupFeature>>&& features, CompletionHandler<void(bool)>&& completionHandler)
+void WebPaymentCoordinator::beginApplePaySetup(const WebCore::ApplePaySetupConfiguration& configuration, const URL& url, Vector<RefPtr<WebCore::ApplePaySetupFeature>>&& features, CompletionHandler<void(bool)>&& completionHandler)
 {
     m_webPage.sendWithAsyncReply(Messages::WebPaymentCoordinatorProxy::BeginApplePaySetup(PaymentSetupConfiguration { configuration, url }, PaymentSetupFeatures { WTFMove(features) }), WTFMove(completionHandler));
 }
index 3e66d02..8bb6058 100644 (file)
@@ -86,8 +86,8 @@ private:
     String userAgentScriptsBlockedErrorMessage() const final;
 
 #if ENABLE(APPLE_PAY_SETUP)
-    void getSetupFeatures(const WebCore::ApplePaySetup::Configuration&, const URL&, CompletionHandler<void(Vector<Ref<WebCore::ApplePaySetupFeature>>&&)>&&) final;
-    void beginApplePaySetup(const WebCore::ApplePaySetup::Configuration&, const URL&, Vector<RefPtr<WebCore::ApplePaySetupFeature>>&&, CompletionHandler<void(bool)>&&) final;
+    void getSetupFeatures(const WebCore::ApplePaySetupConfiguration&, const URL&, CompletionHandler<void(Vector<Ref<WebCore::ApplePaySetupFeature>>&&)>&&) final;
+    void beginApplePaySetup(const WebCore::ApplePaySetupConfiguration&, const URL&, Vector<RefPtr<WebCore::ApplePaySetupFeature>>&&, CompletionHandler<void(bool)>&&) final;
     void endApplePaySetup() final;
 #endif