| <!DOCTYPE html> |
| <meta charset="UTF-8"> |
| <title>CSS Highlight API Test: </title> |
| <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/"> |
| <link rel="match" href="custom-highlight-painting-staticrange-001-ref.html"> |
| <meta name="assert" value="StaticRanges that are invalid, collapsed or that cross only one boundary of a css-contain node should not be painted when they're in a Highlight"> |
| <style> |
| ::highlight(example-highlight) { |
| background-color: yellow; |
| color: blue; |
| } |
| #second { |
| contain: style; |
| } |
| </style> |
| <body><span id="first">One </span><span id="second">two </span><span id="third">three…</span> |
| <script> |
| let h = new Highlight("example-highlight"); |
| h.add(new StaticRange({startContainer: document.body, startOffset: 0, endContainer: document.body, endOffset: 0})); |
| h.add(new StaticRange({startContainer: document.body, startOffset: 1, endContainer: document.body, endOffset: 0})); |
| h.add(new StaticRange({startContainer: document.body, startOffset: 1, endContainer: document.body, endOffset: 100})); |
| h.add(new StaticRange({startContainer: document, startOffset: 0, endContainer: document, endOffset: 1})); |
| h.add(new StaticRange({startContainer: document.querySelector("#third").firstChild, startOffset: 1, endContainer: document.querySelector("#first").firstChild, endOffset: 2})); |
| h.add(new StaticRange({startContainer: document.querySelector("#first").firstChild, startOffset: 1, endContainer: document.querySelector("#second").firstChild, endOffset: 2})); |
| h.add(new StaticRange({startContainer: document.querySelector("#second").firstChild, startOffset: 1, endContainer: document.querySelector("#third").firstChild, endOffset: 2})); |
| CSS.highlights.add(h); |
| </script> |