Home | History | Annotate | Download | only in ShadowDOM
      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4     <script type="text/javascript" src="../resources/runner.js"></script>
      5 </head>
      6 <body>
      7 
      8 <div id="wrapper">
      9     <h2>Selected</h2>
     10     <div id="selected"></div>
     11     <h2>NonSelected</h2>
     12     <div id="nonselected"></div>
     13 </div>
     14 
     15 <script>
     16 var numDivsInHost = 100;
     17 var array = new Array(numDivsInHost);
     18 
     19 function setup()
     20 {
     21     var nDivs = numDivsInHost;
     22     var nonSelected = document.getElementById('nonselected');
     23 
     24     for (var i = 0; i < nDivs; ++i) {
     25         var div = document.createElement('div');
     26         div.appendChild(document.createTextNode('div' + i));
     27         array[i] = div;
     28         nonSelected.appendChild(div);
     29     }
     30 }
     31 
     32 function run()
     33 {
     34     var nDivs = numDivsInHost;
     35     var array = window.array;
     36 
     37     var selected = document.getElementById('selected');
     38     var nonSelected = document.getElementById('nonselected');
     39 
     40     for (var i = 2; i < 100; ++i) {
     41         for (var j = 0; j < nDivs; ++j) {
     42             if (j % i == 0) {
     43                 array[j].className = 'selected';
     44                 selected.appendChild(array[j]);
     45             } else {
     46                 array[j].className = '';
     47                 nonSelected.appendChild(array[j]);
     48             }
     49         }
     50         selected.offsetLeft;
     51         nonSelected.offsetLeft;
     52     }
     53 }
     54 
     55 function done()
     56 {
     57     wrapper.innerHTML = '';
     58 }
     59 
     60 setup();
     61 
     62 PerfTestRunner.measureTime({
     63     description: "Measure distribution and layout performance when className is changed (without ShadowDOM)",
     64     run: run,
     65     done: done
     66 });
     67 </script>
     68 </body>
     69 </html>
     70