blob: b560a6c3c9faca5977d4dc00a3f146243722acb5 [file] [log] [blame]
<!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>
</head>
<body>
<script>
description("Test basic creation of an ApplePaySession object.");
window.jsTestIsAsync = true;
function validRequest() {
return {
countryCode: 'US',
currencyCode: 'USD',
supportedNetworks: ['visa', 'masterCard', 'carteBancaire'],
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 supportsVersion");
debug("");
shouldThrow("ApplePaySession.supportsVersion(0)");
shouldBeTrue("ApplePaySession.supportsVersion(1)");
shouldBeTrue("ApplePaySession.supportsVersion(2)");
shouldBeTrue("ApplePaySession.supportsVersion(3)");
shouldBeTrue("ApplePaySession.supportsVersion(4)");
shouldBeTrue("ApplePaySession.supportsVersion(5)");
debug("");
debug("Testing PaymentRequest (v5)")
debug("");
shouldThrow("new ApplePaySession(5, { })");
shouldNotThrow("new ApplePaySession(5, validRequest())");
debug("");
document.querySelector("button").remove();
finishJSTest();
}
window.onload = function() {
UIHelper.activateElement(document.querySelector("button"));
}
</script>
<button onclick='go()'>Go</button>
<script src="/resources/js-test-post.js"></script>
</body>
</html>