blob: ef5ccdf4001d8d5038bf0b9fb3c0d77465dbcb8b [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 Interactive state goes into the back/forward cache.');
window.jsTestIsAsync = true;
window.addEventListener('pageshow', async 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');
debug('Testing that the promise returned by show() was rejected with "AbortError".');
await shouldRejectWithErrorName('responsePromise', 'AbortError');
debug('Testing that PaymentRequest is now in the Closed state.');
await shouldRejectWithErrorName('request.abort()', 'InvalidStateError');
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() {
UIHelper.withUserGesture(async function() {
debug('Creating a PaymentRequest in the Interactive state.');
request = new PaymentRequest([validPaymentMethod()], validPaymentDetails());
responsePromise = request.show();
});
setTimeout(function() {
window.location.href = '/navigation/resources/page-cache-helper.html';
}, 0);
}, false);
</script>
</body>
</html>