summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/state-save-of-detached-control.html
blob: ad3402d83055535093e1226c5dbe1ec919737640 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body onload="runTest()">
<p>Test to NOT save state of a detached form control.</p>
<div id="console"></div>

<input id=emptyOnFirstVisit>
<form action="data:text/html,<script>history.back()&lt;/script>" id=form1>
<input name=user id=input2>
</form>

<script>
var i1;

function runTest()
{
    var form1 = document.getElementById('form1');
    var state = document.getElementById('emptyOnFirstVisit');
    if (!state.value) {
        // First visit.
        if (window.testRunner)
            testRunner.waitUntilDone();
        state.value = 'visited';

        form1.innerHTML = '<input name=user id=input1>';
        i1 = document.getElementById('input1');
        i1.value = 'value1';
        form1.removeChild(i1);
        // Submit form in a timeout to make sure that we create a new back/forward list item.
        setTimeout(function() {document.getElementById('form1').submit();}, 0);
    } else {
        // Second visit.
        shouldBe('document.getElementById("input2").value', '""'); // Not 'value1'.

        if (window.testRunner)
            testRunner.notifyDone();
    }
 }
</script>
</body>
</html>