#53976: refactor: settle the loadURL() promise natively
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
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses - PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: none
Backports
Semver Impact
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