2 <script src=
"../resources/runner.js"></script>
3 <div id=
"container" style=
"background-color:lime;" contenteditable
></div>
5 var div
= document
.querySelector('div');
8 PerfTestRunner
.measureRunsPerSecond({
9 description
: "Measures performance of adding new lines to an editable div using document.execCommand, then clearing it.",
11 for (var i
= 0; i
< 500; ++i
)
12 document
.execCommand('InsertLineBreak');
13 for (var i
= 0; i
< 500; ++i
)
14 document
.execCommand('Delete');
16 for (var i
= 0; i
< 500; ++i
)
17 document
.execCommand('InsertLineBreak');
18 // Move cursor to the beginning of div.
19 var range
= document
.createRange();
20 range
.selectNodeContents(div
);
22 getSelection().removeAllRanges();
23 getSelection().addRange(range
);
24 for (var i
= 0; i
< 500; ++i
)
25 document
.execCommand('ForwardDelete');