[Win] Correct handling of autogenerated WebInspectorUI files
[WebKit-https.git] / PerformanceTests / Mutation / remove-child.html
1 <!DOCTYPE html>
2 <body>
3 <pre id="log"></pre>
4 <script src="../resources/runner.js"></script>
5 <div id="sandbox" style="display:none"></div>
6 <script>
7 var sandbox = document.getElementById('sandbox');
8 var observing = false;
9
10 var observer = new WebKitMutationObserver(listener);
11 var tickledSpan = document.createElement('span');
12 observer.observe(tickledSpan, {attributes: true});
13
14 function resetState() {
15     window.start = null;
16     window.numRuns = 25;
17     window.times = [];
18 }
19
20 function runAgain() {
21     tickledSpan.setAttribute('data-foo', numRuns);
22 }
23
24 function hideFromObservation(func) {
25     if (observing)
26         observer.disconnect()
27     func();
28     if (observing)
29         observer.observe(sandbox, {childList: true});
30 }
31
32 function listener(mutations) {
33     if (start) {
34         var time = Date.now() - start;
35         times.push(time);
36         PerfTestRunner.log(time);
37     }
38     if (numRuns-- >= 0) {
39         runAgain();
40         hideFromObservation(function() {
41             for (var i = 0; i < 50000; ++i)
42                 sandbox.appendChild(document.createElement('div'));
43         });
44         start = Date.now();
45         while (sandbox.firstChild)
46             sandbox.removeChild(sandbox.firstChild);
47     } else {
48         PerfTestRunner.logStatistics(times);
49         if (!observing) {
50             observer.observe(sandbox, {childList: true});
51             observing = true;
52             resetState();
53             PerfTestRunner.log('\n------------\n');
54             PerfTestRunner.log('Running ' + numRuns + ' times with observation');
55             setTimeout(runAgain, 0);
56         }
57     }
58 }
59
60 resetState();
61 PerfTestRunner.log('Running ' + numRuns + ' times without observation');
62 window.addEventListener('load', runAgain);
63 </script>
64 </body>