Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions resources/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ class MainBenchmarkClient {
_steppingPromise = null;
_steppingResolver = null;
_benchmarkConfiguratorPromise = null;
_isInitialized = false;

get isInitialized() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:
Does this need to be a getter instead of just a method like isRunning and hasFinished?

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() {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-end2end.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Loading