| OLD | NEW |
| (Empty) |
| 1 <!doctype html> | |
| 2 <script src="../resources/runner.js"></script> | |
| 3 <div id="sample"></div> | |
| 4 <script> | |
| 5 const kElements = 10000; | |
| 6 | |
| 7 const metaElements = (() => { | |
| 8 const result = []; | |
| 9 for (let count = 0; count < kElements; ++count) | |
| 10 result.push('<meta>', '</meta>'); | |
| 11 return result; | |
| 12 })(); | |
| 13 const sample = document.getElementById('sample'); | |
| 14 sample.innerHTML = [ | |
| 15 '<h1 id="before">first line of renderered text</h1>', | |
| 16 '<div hidden>', ...metaElements, '</div>', | |
| 17 '<h1 id="target">second line of renderered text</h1>', | |
| 18 '<div hidden>', ...metaElements, '</div>', | |
| 19 '<h1 id="after">third line of renderered text</h1>', | |
| 20 ].join(''); | |
| 21 | |
| 22 const selection = window.getSelection(); | |
| 23 | |
| 24 PerfTestRunner.measureTime({ | |
| 25 description: 'Measures performance of move-up through non-renderered elements'
, | |
| 26 setup: () => { | |
| 27 selection.removeAllRanges(); | |
| 28 const target = document.getElementById('target'); | |
| 29 selection.collapse(target.firstChild, 5); | |
| 30 selection.extend(target.firstChild, 10); | |
| 31 }, | |
| 32 run: () => { | |
| 33 selection.modify('extend', 'backward', 'line'); | |
| 34 }, | |
| 35 }); | |
| 36 </script> | |
| OLD | NEW |