range-in-two-selections.html (924B)
1 <!DOCTYPE html> 2 <html> 3 4 <head> 5 <script src=/resources/testharness.js></script> 6 <script src=/resources/testharnessreport.js></script> 7 </head> 8 9 <body> 10 <span>One two</span> 11 <script> 12 promise_test(async function (t) { 13 await new Promise(resolve => { 14 window.onload = resolve; 15 }) 16 const range = document.createRange(); 17 range.setStart(document.body, 0); 18 range.setEnd(document.body, 1); 19 const highlight = new Highlight(range); 20 CSS.highlights.set("foo", highlight); 21 document.getSelection().addRange(range); 22 23 const highlightRange = highlight.entries().next().value[0]; 24 const selectionRange = document.getSelection().getRangeAt(0); 25 assert_equals( 26 highlightRange, 27 selectionRange, 28 "The same range must be present in the highlight and the Selection." 29 ); 30 }, "Range is shared between a custom highlight and the document's Selection."); 31 </script> 32 </body> 33 34 </html>