Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / deleting / delete-character-002.html
blobe2077202ddf6e5839cf4aba8a87ce7698b41ba45
1 <div id="container">
2 <textarea id="sample"></textarea>
3 </div>
4 <script src="../../resources/js-test.js"></script>
5 <script>
6 function $(id) { return document.getElementById(id); }
7 var sample = $('sample');
9 function testIt(source, expectedText, expectedOffset)
11 var caretPos = source.indexOf('|');
12 sample.value = source.substring(0, caretPos) + source.substring(caretPos + 1);
13 sample.setSelectionRange(caretPos, caretPos);
14 sample.focus();
15 document.execCommand('Delete', false);
16 debug(source.replace(/\n/g, '\\n'));
17 shouldBeEqualToString('sample.value', expectedText);
18 shouldBe('sample.selectionStart', expectedOffset.toString());
19 shouldBe('sample.selectionEnd', expectedOffset.toString());
20 debug('');
23 testIt('a\n|', 'a', 1);
24 testIt('a\n\n|', 'a\n', 2);
25 testIt('a\n\n\n|', 'a\n\n', 3);
27 testIt('a|\n', '\n', 0);
28 testIt('a\n|\n', 'a\n', 1);
29 testIt('a\n\n|\n', 'a\n\n', 2);
31 testIt('a\n|\n\n', 'a\n\n', 1);
32 testIt('a\n\n|\n\n', 'a\n\n\n', 2);
34 testIt('a\n|b', 'ab', 1);
35 testIt('a\n\n|b', 'a\nb', 2);
36 testIt('a\n\n\n|b', 'a\n\nb', 3);
38 testIt('a\nb|', 'a\n', 2);
39 testIt('a\n\nb|', 'a\n\n', 3);
40 testIt('a\n\n\nb|', 'a\n\n\n', 4);
42 if (window.testRunner)
43 $('container').outerHTML = '';
44 </script>