MarshallOfSound

#53976: refactor: settle the loadURL() promise natively

Merged
Created: Sep 15, 2026, 6:57:38 PM
Merged: Sep 16, 2026, 11:27:08 AM
2 comments
Target: main

Description of Change

webContents.loadURL()/loadFile() and navigationHistory.restore() built their promise in lib/ by attaching six listeners per call and running a small state machine over them. LoadURLPromises is that state machine in C++, fed by WebContents right before it emits did-finish-load / did-fail-load / did-start-navigation / did-navigate-in-page / did-stop-loading / destroyed, so loadURL is the native method and no listeners are added per navigation. Resolution, the {errno, code, url} rejection and its message, the handled/silent marking and the reaction timing (reactions still run before the emit returns to content/) are unchanged.

One intentional difference: a listener registered before loadURL() that synchronously starts another navigation from inside the event that settles the promise no longer changes that promise's outcome (e.g. from did-finish-load it used to become an ERR_ABORTED rejection and now stays resolved). Listeners added after loadURL() and async continuations behave as before.

~110 lines out of lib/browser/api/web-contents.ts; no measurable runtime change.

Checklist

Release Notes

Notes: none

Backports

45-x-y
Merged
PR Number
#54000
Merged At
Sep 16, 2026, 1:26:35 PM
Released In
Not yet
Release Date
Not yet

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron