Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../../resources/testharness.js"></script> | |
| 3 <script src="../../resources/testharnessreport.js"></script> | |
| 4 <p>abcdef</p> | |
| 5 <script> | |
| 6 test(() => { | |
| 7 let selection = getSelection(); | |
| 8 selection.removeAllRanges(); | |
| 9 let range = document.createRange(); | |
| 10 let text = document.querySelector('p').firstChild; | |
| 11 range.setStart(text, 1); | |
| 12 range.setEnd(text, 2); | |
| 13 | |
| 14 selection.addRange(range); | |
| 15 assert_equals(selection.anchorNode, text); | |
|
yosin_UTC9
2017/02/10 10:26:27
Could you use assesrt_selection()? It is easier to
tkent
2017/02/13 07:31:40
We can't test Range-Selection relationship behavio
| |
| 16 assert_equals(selection.anchorOffset, 1); | |
| 17 assert_equals(selection.focusNode, text); | |
| 18 assert_equals(selection.focusOffset, 2); | |
| 19 | |
| 20 range.setStart(text, 0); | |
| 21 assert_equals(selection.anchorOffset, 0); | |
| 22 }, 'Mutation of Range after adding it to Selection should update Selection attri butes.'); | |
| 23 </script> | |
| OLD | NEW |