Diff
Modified: trunk/LayoutTests/ChangeLog (217722 => 217723)
--- trunk/LayoutTests/ChangeLog 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/LayoutTests/ChangeLog 2017-06-02 18:14:47 UTC (rev 217723)
@@ -1,3 +1,15 @@
+2017-06-02 Andy Estes <aes...@apple.com>
+
+ [Cocoa] Add a "supportedCountries" property to ApplePayPaymentRequest
+ https://bugs.webkit.org/show_bug.cgi?id=172832
+ <rdar://problem/30735544>
+
+ Reviewed by Alex Christensen.
+
+ * http/tests/ssl/applepay/ApplePaySessionV3-expected.txt: Added.
+ * http/tests/ssl/applepay/ApplePaySessionV3.html: Added.
+ * platform/mac-wk2/TestExpectations:
+
2017-06-02 Devin Rousso <drou...@apple.com>
Web Inspector: Should see active Web Sockets when opening Web Inspector
Added: trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3-expected.txt (0 => 217723)
--- trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3-expected.txt 2017-06-02 18:14:47 UTC (rev 217723)
@@ -0,0 +1,50 @@
+Test basic creation of an ApplePaySession object.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing PaymentRequest (v3)
+
+PASS new ApplePaySession(3, { }) threw exception TypeError: Member ApplePayPaymentRequest.countryCode is required and must be an instance of DOMString.
+PASS new ApplePaySession(3, validRequest()) did not throw exception.
+
+Testing PaymentRequest.supportedCountries
+
+SETUP: request = validRequest(); request.supportedCountries = ['invalid'];
+PASS new ApplePaySession(3, request) threw exception TypeError: "invalid" is not a valid country code..
+
+SETUP: request = validRequest(); request.supportedCountries = ['US', 'invalid'];
+PASS new ApplePaySession(3, request) threw exception TypeError: "invalid" is not a valid country code..
+
+SETUP: request = validRequest(); request.supportedCountries = ['US', 7];
+PASS new ApplePaySession(3, request) threw exception TypeError: "7" is not a valid country code..
+
+SETUP: request = validRequest(); request.supportedCountries = '';
+PASS new ApplePaySession(3, request) threw exception TypeError: Value is not a sequence.
+
+SETUP: request = validRequest(); request.supportedCountries = 7;
+PASS new ApplePaySession(3, request) threw exception TypeError: Value is not a sequence.
+
+SETUP: request = validRequest(); request.supportedCountries = null;
+PASS new ApplePaySession(3, request) threw exception TypeError: Value is not a sequence.
+
+SETUP: request = validRequest(); delete request.supportedCountries;
+PASS new ApplePaySession(3, request) did not throw exception.
+
+SETUP: request = validRequest(); request.supportedCountries = undefined;
+PASS new ApplePaySession(3, request) did not throw exception.
+
+SETUP: request = validRequest(); request.supportedCountries = [];
+PASS new ApplePaySession(3, request) did not throw exception.
+
+SETUP: request = validRequest(); request.supportedCountries = ['US'];
+PASS new ApplePaySession(3, request) did not throw exception.
+
+SETUP: request = validRequest(); request.supportedCountries = ['US', 'US'];
+PASS new ApplePaySession(3, request) did not throw exception.
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3.html (0 => 217723)
--- trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3.html (rev 0)
+++ trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3.html 2017-06-02 18:14:47 UTC (rev 217723)
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<script>
+
+description("Test basic creation of an ApplePaySession object.");
+
+window.jsTestIsAsync = true;
+
+function validRequest() {
+ return {
+ countryCode: 'US',
+ currencyCode: 'USD',
+ supportedNetworks: ['visa', 'masterCard'],
+ merchantCapabilities: ['supports3DS'],
+ total: { label: 'Your Label', amount: '10.00' },
+ }
+}
+
+function logAndShouldThrow(setup, test) {
+ debug("SETUP: " + setup)
+ eval(setup);
+ shouldThrow(test);
+ debug("")
+}
+
+function logAndShouldNotThrow(setup, test) {
+ debug("SETUP: " + setup)
+ eval(setup);
+ shouldNotThrow(test);
+ debug("")
+}
+
+function go() {
+ debug("Testing PaymentRequest (v3)")
+ debug("");
+ shouldThrow("new ApplePaySession(3, { })");
+ shouldNotThrow("new ApplePaySession(3, validRequest())");
+ debug("");
+
+ debug("Testing PaymentRequest.supportedCountries");
+ debug("");
+
+ logAndShouldThrow("request = validRequest(); request.supportedCountries = ['invalid'];", "new ApplePaySession(3, request)");
+ logAndShouldThrow("request = validRequest(); request.supportedCountries = ['US', 'invalid'];", "new ApplePaySession(3, request)");
+ logAndShouldThrow("request = validRequest(); request.supportedCountries = ['US', 7];", "new ApplePaySession(3, request)");
+ logAndShouldThrow("request = validRequest(); request.supportedCountries = '';", "new ApplePaySession(3, request)");
+ logAndShouldThrow("request = validRequest(); request.supportedCountries = 7;", "new ApplePaySession(3, request)");
+ logAndShouldThrow("request = validRequest(); request.supportedCountries = null;", "new ApplePaySession(3, request)");
+ logAndShouldNotThrow("request = validRequest(); delete request.supportedCountries;", "new ApplePaySession(3, request)");
+ logAndShouldNotThrow("request = validRequest(); request.supportedCountries = undefined;", "new ApplePaySession(3, request)");
+ logAndShouldNotThrow("request = validRequest(); request.supportedCountries = [];", "new ApplePaySession(3, request)");
+ logAndShouldNotThrow("request = validRequest(); request.supportedCountries = ['US'];", "new ApplePaySession(3, request)");
+ logAndShouldNotThrow("request = validRequest(); request.supportedCountries = ['US', 'US'];", "new ApplePaySession(3, request)");
+ debug("");
+
+ document.querySelector("button").remove();
+
+ finishJSTest();
+}
+
+function clickElement(element) {
+ let x = element.offsetLeft + 2;
+ let y = element.offsetTop + 2;
+
+ var supportsTouchEvents = "TouchEvent" in window;
+ if (supportsTouchEvents && window.testRunner && testRunner.runUIScript) {
+ testRunner.runUIScript(`(function() { uiController.singleTapAtPoint(${x}, ${y}, function() { }); })();`, function () { });
+ } else if (window.eventSender) {
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+}
+
+window._onload_ = function() {
+ clickElement(document.querySelector("button"));
+}
+
+</script>
+<button _onclick_='go()'>Go</button>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (217722 => 217723)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2017-06-02 18:14:47 UTC (rev 217723)
@@ -24,6 +24,7 @@
[ Sierra+ ] http/tests/ssl/applepay/ [ Pass ]
http/tests/ssl/applepay/ApplePayError.html [ Skip ]
+http/tests/ssl/applepay/ApplePaySessionV3.html [ Skip ]
fast/visual-viewport/rubberbanding-viewport-rects.html [ Pass ]
fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html [ Pass ]
Modified: trunk/Source/WebCore/ChangeLog (217722 => 217723)
--- trunk/Source/WebCore/ChangeLog 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/Source/WebCore/ChangeLog 2017-06-02 18:14:47 UTC (rev 217723)
@@ -1,3 +1,24 @@
+2017-06-02 Andy Estes <aes...@apple.com>
+
+ [Cocoa] Add a "supportedCountries" property to ApplePayPaymentRequest
+ https://bugs.webkit.org/show_bug.cgi?id=172832
+ <rdar://problem/30735544>
+
+ Reviewed by Alex Christensen.
+
+ Test: http/tests/ssl/applepay/ApplePaySessionV3.html
+
+ * Modules/applepay/ApplePayPaymentRequest.h:
+ * Modules/applepay/ApplePayPaymentRequest.idl:
+ * Modules/applepay/ApplePaySession.cpp:
+ (WebCore::convertAndValidate):
+ * Modules/applepay/PaymentRequest.h:
+ (WebCore::PaymentRequest::supportedCountries):
+ (WebCore::PaymentRequest::setSupportedCountries):
+ * Modules/applepay/PaymentRequestValidator.cpp:
+ (WebCore::PaymentRequestValidator::validate):
+ * platform/spi/cocoa/PassKitSPI.h:
+
2017-06-02 Devin Rousso <drou...@apple.com>
Web Inspector: Should see active Web Sockets when opening Web Inspector
Modified: trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h (217722 => 217723)
--- trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h 2017-06-02 18:14:47 UTC (rev 217723)
@@ -58,6 +58,7 @@
std::optional<Vector<ApplePayLineItem>> lineItems;
String applicationData;
+ Vector<String> supportedCountries;
};
}
Modified: trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.idl (217722 => 217723)
--- trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.idl 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.idl 2017-06-02 18:14:47 UTC (rev 217723)
@@ -71,4 +71,5 @@
sequence<ApplePayShippingMethod> shippingMethods;
DOMString applicationData;
+ [Conditional=APPLE_PAY_SESSION_V3] sequence<DOMString> supportedCountries;
};
Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp (217722 => 217723)
--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp 2017-06-02 18:14:47 UTC (rev 217723)
@@ -369,6 +369,9 @@
result.setApplicationData(paymentRequest.applicationData);
+ if (version >= 3)
+ result.setSupportedCountries(WTFMove(paymentRequest.supportedCountries));
+
// FIXME: Merge this validation into the validation we are doing above.
auto validatedPaymentRequest = PaymentRequestValidator::validate(result);
if (validatedPaymentRequest.hasException())
Modified: trunk/Source/WebCore/Modules/applepay/PaymentRequest.h (217722 => 217723)
--- trunk/Source/WebCore/Modules/applepay/PaymentRequest.h 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/Source/WebCore/Modules/applepay/PaymentRequest.h 2017-06-02 18:14:47 UTC (rev 217723)
@@ -128,6 +128,9 @@
const String& applicationData() const { return m_applicationData; }
void setApplicationData(const String& applicationData) { m_applicationData = applicationData; }
+ const Vector<String>& supportedCountries() const { return m_supportedCountries; }
+ void setSupportedCountries(Vector<String>&& supportedCountries) { m_supportedCountries = WTFMove(supportedCountries); }
+
private:
String m_countryCode;
String m_currencyCode;
@@ -148,6 +151,7 @@
LineItem m_total;
String m_applicationData;
+ Vector<String> m_supportedCountries;
};
struct PaymentError {
Modified: trunk/Source/WebCore/Modules/applepay/PaymentRequestValidator.cpp (217722 => 217723)
--- trunk/Source/WebCore/Modules/applepay/PaymentRequestValidator.cpp 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/Source/WebCore/Modules/applepay/PaymentRequestValidator.cpp 2017-06-02 18:14:47 UTC (rev 217723)
@@ -69,6 +69,12 @@
if (validatedShippingMethods.hasException())
return validatedShippingMethods.releaseException();
+ for (auto& countryCode : paymentRequest.supportedCountries()) {
+ auto validatedCountryCode = validateCountryCode(countryCode);
+ if (validatedCountryCode.hasException())
+ return validatedCountryCode.releaseException();
+ }
+
return { };
}
Modified: trunk/Source/WebCore/platform/spi/cocoa/PassKitSPI.h (217722 => 217723)
--- trunk/Source/WebCore/platform/spi/cocoa/PassKitSPI.h 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/Source/WebCore/platform/spi/cocoa/PassKitSPI.h 2017-06-02 18:14:47 UTC (rev 217723)
@@ -168,6 +168,9 @@
@property (nonatomic, copy, nullable) NSArray<PKShippingMethod *> *shippingMethods;
@property (nonatomic, assign) PKShippingType shippingType;
@property (nonatomic, copy, nullable) NSData *applicationData;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
+@property (nonatomic, copy, nullable) NSSet<NSString *> *supportedCountries;
+#endif
@end
@interface PKPaymentAuthorizationViewController : NSViewController
Modified: trunk/Source/WebKit2/ChangeLog (217722 => 217723)
--- trunk/Source/WebKit2/ChangeLog 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/Source/WebKit2/ChangeLog 2017-06-02 18:14:47 UTC (rev 217723)
@@ -1,3 +1,18 @@
+2017-06-02 Andy Estes <aes...@apple.com>
+
+ [Cocoa] Add a "supportedCountries" property to ApplePayPaymentRequest
+ https://bugs.webkit.org/show_bug.cgi?id=172832
+ <rdar://problem/30735544>
+
+ Reviewed by Alex Christensen.
+
+ * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+ (IPC::ArgumentCoder<PaymentRequest>::encode):
+ (IPC::ArgumentCoder<PaymentRequest>::decode):
+ * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+ (WebKit::toNSSet):
+ (WebKit::toPKPaymentRequest):
+
2017-06-02 Dan Bernstein <m...@apple.com>
[Xcode] Header postprocessing should be based on the target OS version rather than the builder OS version
Modified: trunk/Source/WebKit2/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (217722 => 217723)
--- trunk/Source/WebKit2/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/Source/WebKit2/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2017-06-02 18:14:47 UTC (rev 217723)
@@ -248,6 +248,7 @@
encoder << request.lineItems();
encoder << request.total();
encoder << request.applicationData();
+ encoder << request.supportedCountries();
}
bool ArgumentCoder<PaymentRequest>::decode(Decoder& decoder, PaymentRequest& request)
@@ -317,6 +318,11 @@
return false;
request.setApplicationData(applicationData);
+ Vector<String> supportedCountries;
+ if (!decoder.decode(supportedCountries))
+ return false;
+ request.setSupportedCountries(WTFMove(supportedCountries));
+
return true;
}
Modified: trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (217722 => 217723)
--- trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm 2017-06-02 17:58:24 UTC (rev 217722)
+++ trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm 2017-06-02 18:14:47 UTC (rev 217723)
@@ -476,7 +476,21 @@
return result;
}
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+static RetainPtr<NSSet> toNSSet(const Vector<String>& strings)
+{
+ if (strings.isEmpty())
+ return nil;
+ auto mutableSet = adoptNS([[NSMutableSet alloc] initWithCapacity:strings.size()]);
+ for (auto& string : strings)
+ [mutableSet addObject:string];
+
+ return WTFMove(mutableSet);
+}
+#endif
+
RetainPtr<PKPaymentRequest> toPKPaymentRequest(WebPageProxy& webPageProxy, const WebCore::URL& originatingURL, const Vector<WebCore::URL>& linkIconURLs, const WebCore::PaymentRequest& paymentRequest)
{
auto result = adoptNS([allocPKPaymentRequestInstance() init]);
@@ -532,6 +546,10 @@
[result setApplicationData:applicationData.get()];
}
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+ [result setSupportedCountries:toNSSet(paymentRequest.supportedCountries()).get()];
+#endif
+
// FIXME: Instead of using respondsToSelector, this should use a proper #if version check.
auto& configuration = webPageProxy.process().processPool().configuration();