summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/reset-autofilled.html
blob: 7511385fbc9ebe87269fcdcb41b28b4f47c1812d (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
45
46
47
48
49
<head>
    <script src="../../resources/js-test.js"></script>
    <script>
    function countAutofilledElements() {
        return document.querySelectorAll(':-webkit-autofill').length;
    }

    function test() {
        if (window.testRunner) {
            testRunner.dumpAsText();
        }

        var field = document.getElementById('field');
        var select = document.getElementById('select');
        var textarea = document.getElementById('textarea');
        if (window.internals) {
            window.internals.setAutofilled(field, true);
            window.internals.setAutofilled(select, true);
            window.internals.setAutofilled(textarea, true);
        } else {
            testFailed('This test requires a LayoutTestController.');
            return;
        }

        shouldBe('countAutofilledElements()', '3');

        var form = document.getElementById('form');
        form.reset();

        shouldBe('countAutofilledElements()', '0');
    }
    </script>

    <style>
    #tf {
      color: #FFFFFF;
      background-color: #FFFFFF;
    }
    </style>
</head>
<body onload="test()">
    This tests that a field's autofilled state is reverted when the form is reset.  It can only be run using the test harness.<br>
    <form id="form">
        <input type="text" id="field">
        <select id="select"></select>
        <textarea id="textarea"></textarea>
    </form>
    <div id="console"></div>
</body>