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     <div id="host"></div>
     10 </div>
     11 
     12 <script>
     13 var numShadowRoots = 20;
     14 var numDivsInHost = 10;
     15 var nLoops = 300;
     16 
     17 function setup()
     18 {
     19     var nDivs = numDivsInHost;
     20 
     21     for (var i = 0; i < nDivs; ++i) {
     22         var div = document.createElement('div');
     23         div.appendChild(document.createTextNode('div' + i));
     24         host.appendChild(div);
     25     }
     26 
     27     for (var i = 0; i < numShadowRoots; ++i) {
     28         var content = document.createElement('shadow');
     29         var shadowRoot = host.webkitCreateShadowRoot();
     30         shadowRoot.appendChild(content);
     31     }
     32 }
     33 
     34 function run()
     35 {
     36     var host = document.getElementById('host');
     37     var nLoops = window.nLoops;
     38 
     39     var div = document.createElement('div');
     40     for (var i = 0; i < nLoops; ++i) {
     41         host.appendChild(div);
     42         host.removeChild(div);
     43         host.offsetLeft;
     44     }
     45 }
     46 
     47 function done()
     48 {
     49     wrapper.innerHTML = '';
     50 }
     51 
     52 
     53 setup();
     54 
     55 PerfTestRunner.measureTime({
     56     description: "Measure Distribution and Layout time in a case there are multiple ShadowRoots",
     57     run: run,
     58     done: done
     59 });
     60 </script>
     61 </body>
     62 </html>
     63