4 <meta name=
"viewport" content=
"width=device-width, initial-scale=1">
5 <title>Second batch JS
</title>
14 background: repeating-linear-gradient(
26 border: solid thin darkorange;
30 .spinner-loaded #spinner {
31 background: repeating-linear-gradient(
39 #spinner-container.spinner-loaded {
40 border: solid thin steelblue;
51 <div id=
"spinner-container">
52 <div id=
"spinner"></div>
55 <input id=
"load" type=
"button" value=
"Start loading" onclick=
"kickOffLoading()"></input>
56 <input id=
"run" style='display: none'
type=
"button" value=
"Click me!" onclick=
"onRunClick()"></input>
60 <p>Note: running this test interactively may activate compositor
61 prioritization during loading, which may skew the results.
</p>
65 // Flag that indicates the test is ready to begin.
66 window
.__ready
= false;
68 // Flag that indicates the test has finished executing.
69 window
.__finished
= false;
71 var results
= document
.getElementById('results');
73 function kickOffLoading() {
74 var loadButton
= document
.getElementById('load');
75 loadButton
.disabled
= true;
78 location
.search
.length
> 0 ? location
.search
.substr(1) : 'medium';
79 var script
= document
.createElement('script');
80 script
.setAttribute('type', 'text/javascript')
81 script
.setAttribute('src', 'second_batch_js_' + variant
+ '.min.js')
82 script
.addEventListener('load', onLoadComplete
);
83 document
.body
.appendChild(script
);
86 function onLoadComplete() {
87 var loadButton
= document
.getElementById('load');
88 var runButton
= document
.getElementById('run');
89 loadButton
.style
.display
= 'none';
90 runButton
.style
.display
= 'block';
91 spinnerContainer
.classList
.add('spinner-loaded');
92 window
.__ready
= true;
95 function onRunClick() {
96 results
.innerText
= 'Your lucky number is: ' + main(1);
97 window
.requestAnimationFrame(finishTest
);
100 function finishTest() {
101 window
.__finished
= true;
104 // Perform main thread animation during the benchmark to gauge main thread
106 var spinner
= document
.getElementById('spinner');
107 var spinnerContainer
= document
.getElementById('spinner-container');
108 function animateSpinner(timestamp
) {
109 var width
= parseInt(window
.getComputedStyle(spinnerContainer
).width
);
110 var x
= -(timestamp
/ 8) % width
;
111 spinner
.style
.left
= x
+ 'px';
112 window
.requestAnimationFrame(animateSpinner
);
114 window
.requestAnimationFrame(animateSpinner
);