3 <script src="../js/resources/js-test-pre.js"></script>
6 <p>This tests for problems where we'd lose the selection in a textarea when making style and value changes.</p>
7 <div id="console"></div>
8 <p><textarea id="ta">abc123
10 <script type="text/javascript">
11 var ta = document.getElementById('ta');
12 ta.selectionStart = 3;
14 shouldBe('ta.selectionStart', '3');
15 shouldBe('ta.selectionEnd', '4');
16 debug("- add background style");
17 ta.setAttribute("style", "background-color: yellow");
18 shouldBe('ta.selectionStart', '3');
19 shouldBe('ta.selectionEnd', '4');
20 debug("- set value to same value");
21 ta.value = "abc123\n";
22 shouldBe('ta.selectionStart', '3');
23 shouldBe('ta.selectionEnd', '4');
24 debug("- set value to a different value");
26 shouldBe('ta.selectionStart', '6');
27 shouldBe('ta.selectionEnd', '6');
28 debug("- set selection so we can test again without a trailing newline");
29 ta.selectionStart = 3;
31 ta.removeAttribute("style");
32 shouldBe('ta.selectionStart', '3');
33 shouldBe('ta.selectionEnd', '4');
34 debug("- add background style");
35 ta.setAttribute("style", "background-color: yellow");
36 shouldBe('ta.selectionStart', '3');
37 shouldBe('ta.selectionEnd', '4');
38 debug("- set value to same value");
40 shouldBe('ta.selectionStart', '3');
41 shouldBe('ta.selectionEnd', '4');
43 <script type="text/javascript" src="../js/resources/js-test-post.js"></script>