blob: 2c31135841d78479ef1ae89a235dc6291d5efc25 [file] [log] [blame]
<!-- webkit-test-runner [ enableBackForwardCache=true ] -->
<!DOCTYPE html>
<html>
<body>
<script src='/js-test-resources/js-test.js'></script>
<script src='/js-test-resources/ui-helper.js'></script>
<script>
description('Tests that a page with an inactive ApplePaySession goes into the back/forward cache.');
window.jsTestIsAsync = true;
window.addEventListener('pageshow', function(event) {
debug('pageshow - ' + (event.persisted ? '' : 'not ') + 'from cache');
if (!event.persisted)
return;
testPassed('Page did enter and was restored from the back/forward cache');
try {
session.begin();
session.abort();
testPassed('Idle ApplePaySession was able to begin and abort after restoring from the back/forward cache.');
} catch (e) {
testFailed('ApplePaySession was not idle after restoring from the back/forward cache.');
}
finishJSTest();
}, false);
window.addEventListener('pagehide', function(event) {
debug('pagehide - ' + (event.persisted ? '' : 'not ') + 'entering cache');
if (!event.persisted) {
testFailed('Page failed to enter the back/forward cache.');
finishJSTest();
}
}, false);
window.addEventListener('load', function() {
UIHelper.withUserGesture(function() {
session = new ApplePaySession(1, {
countryCode: 'US',
currencyCode: 'USD',
supportedNetworks: ['visa', 'masterCard'],
merchantCapabilities: ['supports3DS'],
total: { label: 'Total', amount: '1.00' },
});
});
setTimeout(function() {
window.location.href = '/navigation/resources/page-cache-helper.html';
}, 0);
}, false);
</script>
</body>
</html>