MessageHandler should automatically retry commands if the browsing context is initial or loading
Categories
(Remote Protocol :: WebDriver BiDi, task, P2)
Tracking
(firefox132 fixed)
Tracking | Status | |
---|---|---|
firefox132 | --- | fixed |
People
(Reporter: whimboo, Assigned: jdescottes)
References
(Blocks 2 open bugs)
Details
(Whiteboard: [webdriver:m12][webdriver:relnote])
Attachments
(1 file, 1 obsolete file)
It turns out that we emit browsingContext.contextCreated
too early triggering clients to assume the tab is ready and to start interacting with it, while we are still in the process of loading about:blank. This causes various issues for other commands that might run in parallel. I'm going to add those known issues as blockers for this bug.
We probably have to wait for a solution of the discussion on https://github.com/w3c/webdriver-bidi/issues/766.
But given the importance of this issue (especially for Playwright) we should prioritize this bug and start working on it in M12.
Reporter | ||
Comment 1•3 months ago
|
||
Julian will check if it's more stable when we emit the browsingContext.contextCreated
event later when the initial about:blank
was loaded. At this point we might also have to not send out any of the navigation events.
Reporter | ||
Updated•3 months ago
|
Assignee | ||
Comment 2•3 months ago
|
||
Delaying the contextCreated
using waitForInitialNavigationCompleted
seems to fix issues for playwright (eg frequent failures when running npm run biditest -- --project='bidi-firefox-beta*' page-click.spec.ts:24 -x --repeat-each=30
).
However we still have the issue that in some cases there will be no navigation, and the context will stay on the initial about:blank document.
From quick local tests it seems to happen with iframes and with popups created using window.open().
To test things out, I simply skipped iframes and popups for now, and added a new flag on the navigation helper resolveWhenNotInitial
in order to resolve as soon as the document is no longer the initial document. This seems to consistently happen on a NOTIFY_LOCATION notification, which we already listen to.
However, when we start delaying this contextCreated
event, we have the issue that some other events occur earlier. For now I spotted browsingContext.navigationStarted
and network.*
events, but there could be more?
So on top of what I prototyped here, I imagine we would also need to queue some events until we emit contextCreated, otherwise we would notify about events for a context which has not been sent to the client.
diff --git a/remote/webdriver-bidi/modules/root/browsingContext.sys.mjs b/remote/webdriver-bidi/modules/root/browsingContext.sys.mjs
--- a/remote/webdriver-bidi/modules/root/browsingContext.sys.mjs
+++ b/remote/webdriver-bidi/modules/root/browsingContext.sys.mjs
@@ -1734,12 +1734,15 @@ class BrowsingContextModule extends Root
}
);
- await lazy.waitForInitialNavigationCompleted(
- browsingContext.webProgress,
- {
- unloadTimeout: 5000,
- }
- );
+ if (!browsingContext.parent && !browsingContext.opener) {
+ await lazy.waitForInitialNavigationCompleted(
+ browsingContext.webProgress,
+ {
+ resolveWhenNotInitial: true,
+ unloadTimeout: 5000,
+ }
+ );
+ }
+
this._emitEventForBrowsingContext(
browsingContext.id,
"browsingContext.contextCreated",
Assignee | ||
Comment 3•3 months ago
|
||
contextCreated is emitted as soon the initialDocument is created for a new context.
However the corresponding browsing context is soon to be replaced with another one, delay the event
until the final document is loaded.
Updated•3 months ago
|
Assignee | ||
Comment 4•3 months ago
|
||
Updated•3 months ago
|
Comment 6•3 months ago
|
||
bugherder |
Assignee | ||
Updated•3 months ago
|
Assignee | ||
Comment 7•3 months ago
|
||
Renaming the bug to match what we actually landed here.
Reporter | ||
Updated•2 months ago
|
Description
•