diff --git a/resources/main.mjs b/resources/main.mjs index a94671b73..310d20ba2 100644 --- a/resources/main.mjs +++ b/resources/main.mjs @@ -26,16 +26,17 @@ class MainBenchmarkClient { _steppingPromise = null; _steppingResolver = null; _benchmarkConfiguratorPromise = null; + _isInitialized = false; + + get isInitialized() { + return this._isInitialized; + } constructor() { this._benchmarkConfiguratorPromise = import("./benchmark-configurator.mjs"); this.prepareUI(); this.evaluateParams(); this._showSection(window.location.hash); - - this._benchmarkConfiguratorPromise.then(() => { - window.dispatchEvent(new Event("SpeedometerReady")); - }); } isRunning() { @@ -389,10 +390,14 @@ class MainBenchmarkClient { document.body.append(this._developerModeContainer); } + if (!params.startAutomatically) + this._setBenchmarkState(BENCHMARK_STATE.READY); + + this._isInitialized = true; + window.dispatchEvent(new Event("SpeedometerReady")); + if (params.startAutomatically) this.start(); - else - this._setBenchmarkState(BENCHMARK_STATE.READY); } async _setBenchmarkState(state) { diff --git a/tests/run-end2end.mjs b/tests/run-end2end.mjs index d36b3b18d..1f023ee15 100644 --- a/tests/run-end2end.mjs +++ b/tests/run-end2end.mjs @@ -18,7 +18,7 @@ async function testPage(url) { await driver.get(`http://localhost:${port}/${url}`); await driver.executeAsyncScript((callback) => { - if (globalThis.benchmarkClient) + if (globalThis.benchmarkClient.isInitialized) callback(); else globalThis.addEventListener("SpeedometerReady", () => callback(), { once: true });