Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / deleting / delete-br-001.html
blob8f3c0f459ddd370d0a9ed1d34a0869aadae4baea
1 <body>
2 <div id="container">
3 <div contenteditable="true" id="work"></div>
4 </div>
5 </div>
6 <script src="../../resources/js-test.js"></script>
7 <script>
8 function $(id) { return document.getElementById(id); }
10 var sampleHTML = 'abc<br id="a"><br id="b"><br id="c">def';
11 var selection = window.getSelection();
12 function testIt(nth, numberOfDeletes, expectedOffset, expectedHTML) {
13 $('work').innerHTML = sampleHTML;
14 var range = document.createRange();
15 range.setStartAfter($('work').querySelectorAll('br')[nth]);
16 selection.removeAllRanges();
17 selection.addRange(range);
18 for (var i = 0; i < numberOfDeletes; ++i)
19 document.execCommand('Delete');
20 shouldBeEqualToString('$("work").innerHTML', expectedHTML);
21 shouldBeEqualToString('selection.type', 'Caret');
22 shouldBe('selection.anchorOffset', expectedOffset + '');
25 testIt(0, 1, 3, 'abc<br id="b"><br id="c">def');
26 testIt(1, 1, 2, 'abc<br id="a"><br id="c">def');
27 testIt(2, 1, 0, 'abc<br id="a"><br id="b">def');
28 testIt(1, 2, 3, 'abc<br id="c">def');
29 testIt(2, 2, 0, 'abc<br id="a">def');
30 testIt(2, 3, 3, 'abcdef');
32 if (window.testRunner)
33 $('container').outerHTML = '';
34 else
35 $('work').innerHTML = sampleHTML;
36 </script>
37 </body>