Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=author href="mailto:gulukesh@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
function runTest(type, testValue) {
promise_test(async () => {
const w = window.open(`resources/${type}-restore-events.html`);
// Unfortunately, navigating |w| doesn't fire load events in this parent
// window, so we have to make the child window manually tell this parent
// window when it has loaded.
await new Promise(resolve => window.loadResolver = resolve);
// We can't navigate the child window until after a setTimeout.
await new Promise(resolve => step_timeout(resolve, 0));
assert_not_equals(
w.document.querySelector('input').value,
testValue,
`Test shouldn't start with the new value already in the input.`);
w.document.querySelector('input').value = testValue;
w.location.href = 'resources/loadresolver.html';
await new Promise(resolve => window.loadResolver = resolve);
w.history.back();
await new Promise(resolve => window.loadResolver = resolve);
// The value doesn't get restored until after a setTimeout.
await new Promise(resolve => step_timeout(resolve, 0));
assert_equals(w.document.querySelector('input').value, testValue,
'The input should have its value restored.');
assert_false(w.seeninput || false,
'The input event should not have been fired after restoration.');
assert_false(w.seenchange || false,
'The change event should not have been fired after restoration.');
w.close();
}, `Verifies that form restoration does not fire input or change events for <input type=${type}>.`);
}
runTest('range', '8');
runTest('text', 'foo');
</script>