Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / select-script-onchange.html
blobe7645874d1281d65f41d9d92c13e53e39b01cb24
1 <html>
2 <head>
3 <title></title>
4 <script type="text/javascript">
5 var changeCount = new Array(4);
6 changeCount[1] = changeCount[2] = changeCount[3] = 0;
8 function test()
10 if (!window.eventSender)
11 return;
13 testRunner.dumpAsText();
15 var popup = document.getElementById("switcher1");
16 popup.focus();
18 popup = document.getElementById("switcher2");
19 popup.focus();
21 eventSender.keyDown("t", null);
22 eventSender.keyDown("\r", null);
24 var popup = document.getElementById("switcher3");
25 popup.focus();
27 check();
30 function check() {
31 setTimeout("document.getElementById('switcher3').selectedIndex = 1;", 0);
33 var popup = document.getElementById("switcher2");
34 popup.focus();
36 var result = document.getElementById("result");
37 result.innerHTML = "";
38 if (changeCount[1] != 0) {
39 result.innerHTML += "<br/>FAILURE: onchange(1) called " + changeCount[1] + " times.";
41 if (changeCount[2] != 1) {
42 result.innerHTML += "<br/>FAILURE: onchange(2) called " + changeCount[2] + " times.";
44 if (changeCount[3] != 0) {
45 result.innerHTML += "<br/>FAILURE: onchange(3) called " + changeCount[3] + " times.";
47 if (result.innerHTML == "") result.innerHTML = "SUCCESS";
51 function changed(select)
53 changeCount[select]++;
55 </script>
56 </head>
57 <body onload="test()">
58 <p>
59 Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=23721">http://bugs.webkit.org/show_bug.cgi?id=23721</a>
60 Changing dropdown's selectedIndex within onchange handler fires another onchange</i>.
61 </p>
62 <p id="result">
63 To test interactively: focus on the first select (don't change it).<br/>
64 Change the second select to "two"<br/>
65 Focus on the third, then click <a href="#" onclick="check(); return false;">here</a>.
66 </p>
67 This select changes on focus: should not fire onchange.
68 <select name="switcher1" id="switcher1" onfocus="this.selectedIndex = 1;" onchange="changed(1)">
69 <option value="one">One</option>
70 <option value="two">Two</option>
71 </select>
72 <hr/>
73 This select changes on change: should only fire onchange once.
74 <select name="switcher2" id="switcher2" onchange="changed(2); if (this.selectedIndex == 1) this.selectedIndex = 2;">
75 <option value="one">One</option>
76 <option value="two">Two</option>
77 <option value="three">Three</option>
78 </select>
79 <hr/>
80 This select is changed by a timeout in the test script. It should not fire onchange.
81 <select name="switcher3" id="switcher3" onchange="changed(3)">
82 <option value="one">One</option>
83 <option value="two">Two</option>
84 </select>
85 </body>
86 </html>