Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / double-focus.html
blob1b631ad969d6e5f248df85e9ef8abe6413d65a9a
1 <html>
2 <script type="text/javascript">
4 function print(message)
6 var paragraph = document.createElement("div");
7 if (message == "")
8 paragraph.appendChild(document.createElement("br"));
9 else
10 paragraph.appendChild(document.createTextNode(message));
11 document.getElementById("console").appendChild(paragraph);
14 function test()
16 if (window.testRunner)
17 testRunner.dumpAsText();
19 testElement(document.getElementById("textarea"));
20 testElement(document.getElementById("input"));
23 function testElement(element)
25 element.focus();
26 element.value = "This is a test value.";
27 element.setSelectionRange(3,7);
28 element.focus();
29 if (element.selectionStart == 3)
30 print("Passed.");
31 else
32 print("Failed, selection of " + element + " is " + element.selectionStart + "-" + element.selectionEnd + ".");
33 element.blur();
36 </script>
37 </head>
38 <body onload="test();">
39 <p>This test checks if a call to focus on an already-focused element causes a change in selection.</p>
40 <p>If the test passes for both textarea and text input elements you'll see two messages saying "passed" below.</p>
41 <hr>
42 <p id="console"></p>
43 <hr>
44 <form>
45 <p><textarea id="textarea" cols="20"></textarea></p>
46 <p><input type="text" id="input" size="20"></p>
47 </form>
48 </body>
49 </html>