OLD | NEW |
1 <div id="container"> | 1 <div id="container"> |
2 <p id="description"></p> | 2 <p id="description"></p> |
3 <div id="sample"><span contenteditable="true">foobar</span></div> | 3 <div id="sample"><span contenteditable="true">foobar</span></div> |
4 </div> | 4 </div> |
5 <div id="console"></div> | 5 <div id="console"></div> |
6 <script src="../../fast/js/resources/js-test-pre.js"></script> | 6 <script src="../../resources/js-test.js"></script> |
7 <script> | 7 <script> |
8 description('Selection should be updated after set innerHTML.'); | 8 description('Selection should be updated after set innerHTML.'); |
9 | 9 |
10 function $(id) { return document.getElementById(id); } | 10 function $(id) { return document.getElementById(id); } |
11 | 11 |
12 var selection = window.getSelection(); | 12 var selection = window.getSelection(); |
13 document.addEventListener('blur', function () { | 13 document.addEventListener('blur', function () { |
14 selection.selectAllChildren($('sample').firstChild); | 14 selection.selectAllChildren($('sample').firstChild); |
15 }, true); | 15 }, true); |
16 | 16 |
17 selection.selectAllChildren($('sample').firstChild); | 17 selection.selectAllChildren($('sample').firstChild); |
18 $('sample').firstChild.focus(); | 18 $('sample').firstChild.focus(); |
19 $('sample').innerHTML = ''; | 19 $('sample').innerHTML = ''; |
20 | 20 |
21 shouldBe('selection.anchorOffset', '0'); | 21 shouldBe('selection.anchorOffset', '0'); |
22 shouldBe('selection.focusOffset', '0'); | 22 shouldBe('selection.focusOffset', '0'); |
23 | 23 |
24 if (window.testRunner) | 24 if (window.testRunner) |
25 $('container').outerHTML = ''; | 25 $('container').outerHTML = ''; |
26 </script> | 26 </script> |
OLD | NEW |