Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<iframe src="resources/select-restore-invalid-option-iframe.html"></iframe>
<script>
const iframe = document.querySelector('iframe');
promise_test(async () => {
await new Promise(resolve => iframe.onload = resolve);
await test_driver.bless();
iframe.contentDocument.querySelector('select').innerHTML = `
<option value=A>a</option>
<option value=B>b</option>
`;
iframe.contentDocument.querySelector('form').submit();
await new Promise(resolve => iframe.onload = resolve);
assert_equals(iframe.contentDocument.querySelector('select'), null,
'There should not be a select element on the blank page.');
await test_driver.bless();
iframe.contentWindow.history.back();
await new Promise(resolve => iframe.onload = resolve);
await new Promise(requestAnimationFrame);
await new Promise(requestAnimationFrame);
assert_equals(iframe.contentDocument.querySelector('select').value, 'a',
'The selects value should be reset after navigating back.');
}, 'The select element should reset to its initial state when restoring a mismatched value.');
</script>