1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 module.exports = async function (context, commands) {
8 context.log.info("Starting Speedometer 3 test");
9 let url = context.options.browsertime.url;
10 let page_cycles = context.options.browsertime.page_cycles;
11 let speedometer_iterations =
12 context.options.browsertime.speedometer_iterations;
13 let page_cycle_delay = context.options.browsertime.page_cycle_delay;
14 let post_startup_delay = context.options.browsertime.post_startup_delay;
15 let page_timeout = context.options.timeouts.pageLoad;
16 let expose_profiler = context.options.browsertime.expose_profiler;
19 "Waiting for %d ms (post_startup_delay)",
22 await commands.wait.byTime(post_startup_delay);
24 for (let count = 0; count < page_cycles; count++) {
25 context.log.info("Navigating to about:blank");
26 await commands.navigate("about:blank");
28 context.log.info("Cycle %d, waiting for %d ms", count, page_cycle_delay);
29 await commands.wait.byTime(page_cycle_delay);
31 context.log.info("Cycle %d, starting the measure", count);
32 if (expose_profiler === "true") {
33 context.log.info("Custom profiler start!");
34 await commands.profiler.start();
36 await commands.measure.start(url);
38 await commands.js.runAndWait(`
39 window.testDone = false;
40 window.suiteValues = [];
41 const benchmarkClient = {
42 didRunSuites(measuredValues) {
43 window.suiteValues.push(measuredValues);
45 didFinishLastIteration() {
46 window.testDone = true;
49 window.Suites.forEach((el) => {
52 // BenchmarkRunner is overriden as the InteractiveBenchmarkRunner
53 const runner = new BenchmarkRunner(window.Suites, ${speedometer_iterations});
54 runner._client = benchmarkClient;
59 let data_exists = false;
60 let starttime = await commands.js.run(`return performance.now();`);
63 (await commands.js.run(`return performance.now();`)) - starttime <
67 context.log.info("Waiting %d ms for data from speedometer...", wait_time);
68 await commands.wait.byTime(wait_time);
69 data_exists = await commands.js.run("return window.testDone;");
71 if (expose_profiler === "true") {
72 context.log.info("Custom profiler stop!");
73 await commands.profiler.stop();
77 (await commands.js.run(`return performance.now();`)) - starttime >=
80 context.log.error("Benchmark timed out. Aborting...");
83 let data = await commands.js.run(`return window.suiteValues;`);
84 context.log.info("Value of benchmark data: ", data);
86 commands.measure.addObject({ browsertime_benchmark: { s3: data } });