<!DOCTYPE html>
<html>
<head>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<iframe></iframe>
<script>
window.isSecondVisit = false;
const iframe = document.querySelector('iframe');
let t = async_test('Test to NOT save sate for non-edited controls');
t.step(() => {
iframe.src = 'resources/state-restore-to-non-edited-controls-frame.html';
iframe.addEventListener('load', t.step_func(() => {
if (!isSecondVisit) {
isSecondVisit = true;
let doc = iframe.contentDocument;
doc.getElementById('text1').value = 'edit';
doc.getElementById('text3').value = 'edit';
// Submit form in a timeout to make sure that we create a new back/forward list item.
t.step_timeout(function() {doc.getElementById('form1').submit();}, 100);
} else if (iframe.contentDocument.URL.indexOf('blank') != -1) {
history.back();
} else {
t.step_timeout(() => {
let doc = iframe.contentDocument
assert_equals(doc.getElementById('button').value, '2');
assert_equals(doc.getElementById('hidden').value, '2');
assert_equals(doc.getElementById('image').value, '2');
assert_equals(doc.getElementById('reset').value, '2');
assert_equals(doc.getElementById('submit1').value, '2');
assert_equals(doc.getElementById('text0').value, '2');
assert_equals(doc.getElementById('text1').value, 'edit', 'Non-initial value should be restored.');
assert_equals(doc.getElementById('text2').value, '2');
assert_equals(doc.getElementById('text3').value, 'z', 'User-edit value should be preserved.');
assert_equals(doc.getElementById('textarea').value, '2');
t.done();
}, 1);
}
}));
});
</script>
</body>