5 <ul id="list"><li><span></span></li></ul>
6 <div id="console"></div>
10 testRunner.dumpAsText();
12 var listElement = document.getElementById('list');
13 var templateElement = list.firstChild;
14 var inputElement = document.getElementById('input');
16 function test(numberOfElements, focusInput)
21 var startTime = Date.now();
22 for (var i = 0; i < numberOfElements; i++) {
23 var clone = templateElement.cloneNode(true);
24 clone.childNodes[0].textContent = i;
25 listElement.appendChild(clone);
27 var endTime = Date.now();
32 while (listElement.firstChild != listElement.lastChild)
33 listElement.removeChild(listElement.lastChild);
35 return endTime - startTime;
40 var element = document.createElement('div');
41 element.appendChild(document.createTextNode(str));
42 document.getElementById('console').appendChild(element);
45 var timeWithoutFocus = test(1000, false);
46 var timeWithFocus = test(1000, true);
48 if (Math.abs(timeWithFocus - timeWithoutFocus) <= timeWithoutFocus) {
49 log('PASS. Cloning elements takes roughly as long with as without focus.');
51 log('FAIL. Cloning 1000 elements with focus took ' + timeWithFocus + 'ms, without took ' + timeWithoutFocus + 'ms.');