Skip to content

Clean up IndexedDB previous-page listener state #52

@issackjohn

Description

@issackjohn

Follow-up from WebKit#531 review.

Review context:

Current state:

  • experimental/javascript-wc-indexeddb/src/workload-test.mjs and the checked-in dist/src/workload-test.mjs define iterationFinishedListener() inside DeletingAllItems.
  • The listener stores the active resolver as a property on the function object:
function iterationFinishedListener() {
    iterationFinishedListener.promiseResolve();
}
window.addEventListener("previous-page-loaded", iterationFinishedListener);
...
const iterationFinishedPromise = new Promise((resolve) => {
    iterationFinishedListener.promiseResolve = resolve;
});

Why this is worth cleaning up:

  • It works, but the resolver is hidden mutable state on a function object.
  • The listener is registered once and never removed.
  • The pattern is surprising for future benchmark maintenance.

Suggested direction:

  • Replace the function-property resolver with a local promise/event helper, e.g. waitForPreviousPageLoaded() that registers a one-shot listener before clicking the previous-page button.
  • Keep the listener registration before the click, so the event cannot be missed.
  • Update both source and generated/dist copies consistently if the workload still keeps checked-in dist sources.

Validation:

  • Run the IndexedDB workload in the browser matrix, or at least npm run test-e2e:safari / npm run test-e2e:chrome if available locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions