summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/onchange-setvalueforuser.html
blob: f6b2398c23063ce4a19d3794caa6435948b129a7 (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
<html>
<head>
    <script src="../../resources/js-test.js"></script>
    <script>
    function test() {
        var tf = document.getElementById('tf');

        var didFireOnChange = false;
        tf.onchange = function() {
          didFireOnChange = true;
        }

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

        tf.focus();
        if (window.internals) {
            internals.setValueForUser(tf, 'Hello!');
        }

        // Should not fire the event until focus is lost.
        if (didFireOnChange) {
            testFailed('onchange fired too early');
            return;
        }

        tf.blur();
        if (didFireOnChange) {
            testPassed('');
        } else {
            testFailed('onchange never fired')
        }
    }
    </script>
</head>
<body onload="test()">
    This tests that onchange correctly fires after calling setValueForUser().  It can only be run using DumpRenderTree.<br>
    <form name="fm">
        <input type="text" id="tf" />
    </form>
    <div id="console"></div>
</body>
</html>