Description
iframe.src = url;
Right now, it's difficult to know when the iframe commits its navigation. There's the 'load' event, but that waits on inner resources to load, so it can be long after the navigation is committed.
I think this timing information is already available, as you can poll iframe.contentDocument
until it changes or starts throwing. At which point you know the navigation has commited.
A callback for this would solve #2161, as you could add a DOMContentLoaded
listener at this point if the iframe is same-origin.
Suggested API:
iframe.addEventListener('navigated', () => {
// Fired when a navigation commits.
});
await iframe.navigated;
// Resolves when the iframe's navigation commits.
// This promise changes each time src is set.
It's unclear if 'navigated' should fire on a failed navigation, and if .navigated
should reject, due to #125, #1230, and #4247 (h/t @domenic).
I'm not sure how you'd do the same thing for WindowProxy
. Would we be able to hang a .navigated
promise off WindowProxy
?