OLD | NEW |
1 <!doctype HTML> | 1 <!doctype HTML> |
2 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
3 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
4 <script src="../assert_selection.js"></script> | 4 <script src="../assert_selection.js"></script> |
5 <script> | 5 <script> |
6 test(() => assert_selection( | 6 test(() => assert_selection( |
7 '<div contenteditable><p>A|B</p></div>', | 7 '<div contenteditable><p>A|B</p></div>', |
8 'insertText \ ', | 8 'insertText \ ', |
9 '<div contenteditable><p>A |B</p></div>'), | 9 '<div contenteditable><p>A |B</p></div>'), |
10 'insert a plain space in the middle of text node'); | 10 'insert a plain space in the middle of text node'); |
11 | 11 |
12 test(() => assert_selection( | 12 test(() => assert_selection( |
13 '<div contenteditable><p id="para"></p></div>', | 13 '<div contenteditable><p id="para"></p></div>', |
14 selection => { | 14 selection => { |
15 var para = selection.document.getElementById('para'); | 15 var para = selection.document.getElementById('para'); |
16 para.appendChild(selection.document.createTextNode('A')); | 16 para.appendChild(selection.document.createTextNode('A')); |
17 para.appendChild(selection.document.createTextNode('B')); | 17 para.appendChild(selection.document.createTextNode('B')); |
18 selection.collapse(para.firstChild, 1); | 18 selection.collapse(para.firstChild, 1); |
19 | 19 |
20 selection.document.execCommand('insertText', false, ' '); | 20 selection.document.execCommand('insertText', false, ' '); |
21 }, | 21 }, |
22 '<div contenteditable><p id="para">A |B</p></div>'), | 22 '<div contenteditable><p id="para">A |B</p></div>'), |
23 'insert a plain space between two inserted text nodes'); | 23 'insert a plain space between two inserted text nodes'); |
24 | 24 |
25 test(() => assert_selection( | 25 test(() => assert_selection( |
26 '<div contenteditable><p id="para"></p></div>', | 26 '<div contenteditable><p id="para"></p></div>', |
27 selection => { | 27 selection => { |
28 var para = selection.document.getElementById('para'); | 28 var para = selection.document.getElementById('para'); |
29 para.appendChild(selection.document.createTextNode('A')); | 29 para.appendChild(selection.document.createTextNode('A')); |
30 para.appendChild(selection.document.createTextNode('')); | 30 para.appendChild(selection.document.createTextNode('')); |
31 selection.collapse(para.firstChild, 1); | 31 selection.collapse(para.firstChild, 1); |
32 | 32 |
33 selection.document.execCommand('insertText', false, ' '); | 33 selection.document.execCommand('insertText', false, ' '); |
34 }, | 34 }, |
35 '<div contenteditable><p id="para">A\u00A0|</p></div>'), | 35 '<div contenteditable><p id="para">A\u00A0|</p></div>'), |
36 'Insert a instead of plain space when it is inserted before the empty t
ext node'); | 36 'Insert a instead of plain space when it is inserted before the empty t
ext node'); |
| 37 |
| 38 test(() => assert_selection( |
| 39 '<div contenteditable><p id="para"></p></div>', |
| 40 selection => { |
| 41 var para = selection.document.getElementById('para'); |
| 42 para.appendChild(selection.document.createTextNode('A')); |
| 43 para.appendChild(selection.document.createTextNode(' B')); |
| 44 selection.collapse(para.firstChild, 1); |
| 45 |
| 46 selection.document.execCommand('insertText', false, ' '); |
| 47 }, |
| 48 '<div contenteditable><p id="para">A\u00A0| B</p></div>'), |
| 49 'Insert a instead of plain space when it is inserted before the text no
de that has a leading plain space'); |
37 </script> | 50 </script> |
OLD | NEW |