Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: LayoutTests/fast/forms/textarea-selection-preservation.html

Issue 392573002: HTMLTextAreaElement.setSelectionRange should not change focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix tests Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../resources/js-test.js"></script> 3 <script src="../../resources/js-test.js"></script>
4 </head> 4 </head>
5 <body> 5 <body>
6 <p>This tests for problems where we'd lose the selection in a textarea when maki ng style and value changes.</p> 6 <p>This tests for problems where we'd lose the selection in a textarea when maki ng style and value changes.</p>
7 <div id="console"></div> 7 <div id="console"></div>
8 <p><textarea id="ta">abc123 8 <form id="form"><textarea id="ta">abc123
9 </textarea></p> 9 </textarea></form>
10 <script type="text/javascript"> 10 <script type="text/javascript">
11 var ta = document.getElementById('ta'); 11 var ta = document.getElementById('ta');
12 debug("- default value");
13 shouldBe('ta.selectionStart', '0');
14 shouldBe('ta.selectionEnd', '0');
15 debug("- set selectionStart/End");
12 ta.selectionStart = 3; 16 ta.selectionStart = 3;
13 ta.selectionEnd = 4; 17 ta.selectionEnd = 4;
14 shouldBe('ta.selectionStart', '3'); 18 shouldBe('ta.selectionStart', '3');
15 shouldBe('ta.selectionEnd', '4'); 19 shouldBe('ta.selectionEnd', '4');
16 debug("- add background style"); 20 debug("- add background style");
17 ta.setAttribute("style", "background-color: yellow"); 21 ta.setAttribute("style", "background-color: yellow");
18 shouldBe('ta.selectionStart', '3'); 22 shouldBe('ta.selectionStart', '3');
19 shouldBe('ta.selectionEnd', '4'); 23 shouldBe('ta.selectionEnd', '4');
20 debug("- set value to same value"); 24 debug("- set value to same value");
21 ta.value = "abc123\n"; 25 ta.value = "abc123\n";
(...skipping 10 matching lines...) Expand all
32 shouldBe('ta.selectionStart', '3'); 36 shouldBe('ta.selectionStart', '3');
33 shouldBe('ta.selectionEnd', '4'); 37 shouldBe('ta.selectionEnd', '4');
34 debug("- add background style"); 38 debug("- add background style");
35 ta.setAttribute("style", "background-color: yellow"); 39 ta.setAttribute("style", "background-color: yellow");
36 shouldBe('ta.selectionStart', '3'); 40 shouldBe('ta.selectionStart', '3');
37 shouldBe('ta.selectionEnd', '4'); 41 shouldBe('ta.selectionEnd', '4');
38 debug("- set value to same value"); 42 debug("- set value to same value");
39 ta.value = "abc123"; 43 ta.value = "abc123";
40 shouldBe('ta.selectionStart', '3'); 44 shouldBe('ta.selectionStart', '3');
41 shouldBe('ta.selectionEnd', '4'); 45 shouldBe('ta.selectionEnd', '4');
46
47 debug("- reset form");
48 form.reset();
49 shouldBe('ta.selectionStart', '7');
50 shouldBe('ta.selectionEnd', '7');
51
52 debug("- set new defaultValue");
53 ta.defaultValue = 'abc123456';
54 shouldBe('ta.selectionStart', '9');
55 shouldBe('ta.selectionEnd', '9');
56
57 debug("- set same defaultValue");
58 ta.setSelectionRange(2, 3);
59 ta.defaultValue = 'abc123456';
60 shouldBe('ta.selectionStart', '9');
61 shouldBe('ta.selectionEnd', '9');
62
63 debug("- append a text node");
64 ta.appendChild(document.createTextNode('foo'));
65 shouldBe('ta.selectionStart', '12');
66 shouldBe('ta.selectionEnd', '12');
67
68 debug("- append a empty text node");
69 ta.setSelectionRange(2, 3);
70 ta.appendChild(document.createTextNode(''));
71 shouldBe('ta.selectionStart', '12');
72 shouldBe('ta.selectionEnd', '12');
42 </script> 73 </script>
43 </body> 74 </body>
44 </html> 75 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698