text-match-document-change.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <!DOCTYPE html>
  2. <script src="resources/text-based-repaint.js"></script>
  3. <script>
  4. function highlightRange(id, start, end) {
  5. var frameWindow = document.getElementById('iframe').contentWindow;
  6. var range = frameWindow.document.createRange();
  7. var elem = frameWindow.document.getElementById(id).firstChild;
  8. range.setStart(elem, start);
  9. range.setEnd(elem, end);
  10. frameWindow.internals.addTextMatchMarker(range, 'kInactive');
  11. }
  12. function repaintTest() {
  13. document.getElementById('iframe').contentDocument.getElementById('to-be-changed').textContent = 'After change';
  14. }
  15. if (window.internals) {
  16. onload = function() {
  17. highlightRange('unchanged', 11, 17);
  18. highlightRange('to-be-changed', 15, 21);
  19. runRepaintAndPixelTest();
  20. };
  21. }
  22. </script>
  23. Tests paint invalidation of the scrollbar (to repaint tickmarks) on document change when there are text match markers.
  24. Passes if the tickmarks are updated on document change.<br>
  25. <!-- Currently paint invalidation of main frame scrollbar is not tracked,
  26. so use a frame to show the invalidation of tickmarks. -->
  27. <iframe id="iframe" style="position: absolute; top: 100px; height: 400px" srcdoc="
  28. <div id='unchanged'>
  29. Unchanged: findme
  30. </div>
  31. <div id='to-be-changed' onclick='this.textContent=&amp;quot;After change&amp;quot;'>
  32. To be changed: findme (Manual testing: Find-in-page 'findme', then click here)
  33. </div>
  34. <div style='height: 1000px'><!-- To show the scrollbar --></div>">
  35. </iframe>