blob: 53fd395b04839ef2b3f1b38a3fe3783d7f601e13 [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 src='/resources/payment-request.js'></script>
<script>
description('Tests that a page with a PaymentRequest in the Created state 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');
UIHelper.withUserGesture(async function() {
debug('Testing that PaymentRequest remains in the Created state.')
responsePromise = request.show();
await request.abort();
await shouldRejectWithErrorName('responsePromise', 'AbortError');
finishJSTest();
});
}, false);
window.addEventListener('pagehide', function(event) {
debug('pagehide - ' + (event.persisted ? '' : 'not ') + 'entering cache');
if (event.persisted)
return;
testFailed('Page failed to enter the back/forward cache.');
finishJSTest();
}, false);
window.addEventListener('load', function() {
debug('Creating a PaymentRequest in the Created state.');
request = new PaymentRequest([validPaymentMethod()], validPaymentDetails());
setTimeout(function() {
window.location.href = '/navigation/resources/page-cache-helper.html';
}, 0);
}, false);
</script>
</body>
</html>