[Tech review] BiDi - Add pages for navigation and page load events of browsingContext module#44571
[Tech review] BiDi - Add pages for navigation and page load events of browsingContext module#44571dipikabh wants to merge 5 commits into
Conversation
| - `userContext` {{optional_inline}} | ||
| - : A string that contains the ID of the [user context](/en-US/docs/Web/WebDriver/Reference/BiDi/Modules/browser#user_contexts) in which the HTML document is being parsed. |
There was a problem hiding this comment.
I was thinking to leave this field out, but I noticed in the implementation tracker that Firefox support is coming in 154. So I've included it, though examples of all events in this PR are currently missing this field.
I would have asked for clarification on when this field is included vs. omitted in the payload - but from the comment in the spreadsheet, it seems that this field will eventually become required.
But let me know, if in the meantime, any more details need to be added here
There was a problem hiding this comment.
This is similar to #44121 (review) , it might be better to leave those out until they are mandatory in the spec.
We implemented it in Firefox 154, but AFAIK Chrome doesn't support it yet.
| ```json | ||
| { | ||
| "type": "event", | ||
| "method": "browsingContext.navigationFailed", | ||
| "params": { | ||
| "context": "5e5e96e8-5247-4f22-9b35-a4a2d841cbaa", | ||
| "navigation": "a1b2c3d4-5678-90ab-cdef-1234567890ab", | ||
| "timestamp": 1712345678901, | ||
| "url": "https://not-a-valid-domain.example" | ||
| } | ||
| } | ||
| ``` |
There was a problem hiding this comment.
I wasn't able to reproduce this. I used https://not-a-valid-domain.example as the URL but this returned:
"error": "unknown error",
"message": "Error: NS_ERROR_UNKNOWN_HOST",
as a browsingContext.navigate command error rather than firing the browsingContext.navigationFailed event. The stacktrace showed #onNavigationCommitted being called.
Is the example documented here good enough? Any other variables I can tweak to trigger the event?
There was a problem hiding this comment.
A navigation to an unknown host is not going to trigger navigationFailed, you can find the list of scenarios in the following comment: https://bugzilla.mozilla.org/show_bug.cgi?id=1846601#c9
The easiest to explain might be onbeforeunload where the user (or the test) rejects the unload?
Note that based on the HTML spec, there are some situations where we shouldn't emit navigationStarted (step 9 and 12 of https://html.spec.whatwg.org/#beginning-navigation, navigation started is step 18) but I'm not sure we implement that properly at the moment. I would maybe not mention navigationStarted here.
On my side: I will file a bug for your initial scenario. I'm not sure exactly how we should handle navigating to this https://not-a-valid-domain.example URL, but normally unknown error should be reserved for failed navigations, so that error looks fishy and in any case the error message means we didn't handle the navigation properly.
juliandescottes
left a comment
There was a problem hiding this comment.
(answers for the inline questions, reviewing the rest of the PR still, thanks!)
| - `userContext` {{optional_inline}} | ||
| - : A string that contains the ID of the [user context](/en-US/docs/Web/WebDriver/Reference/BiDi/Modules/browser#user_contexts) in which the HTML document is being parsed. |
There was a problem hiding this comment.
This is similar to #44121 (review) , it might be better to leave those out until they are mandatory in the spec.
We implemented it in Firefox 154, but AFAIK Chrome doesn't support it yet.
| ```json | ||
| { | ||
| "type": "event", | ||
| "method": "browsingContext.navigationFailed", | ||
| "params": { | ||
| "context": "5e5e96e8-5247-4f22-9b35-a4a2d841cbaa", | ||
| "navigation": "a1b2c3d4-5678-90ab-cdef-1234567890ab", | ||
| "timestamp": 1712345678901, | ||
| "url": "https://not-a-valid-domain.example" | ||
| } | ||
| } | ||
| ``` |
There was a problem hiding this comment.
A navigation to an unknown host is not going to trigger navigationFailed, you can find the list of scenarios in the following comment: https://bugzilla.mozilla.org/show_bug.cgi?id=1846601#c9
The easiest to explain might be onbeforeunload where the user (or the test) rejects the unload?
Note that based on the HTML spec, there are some situations where we shouldn't emit navigationStarted (step 9 and 12 of https://html.spec.whatwg.org/#beginning-navigation, navigation started is step 18) but I'm not sure we implement that properly at the moment. I would maybe not mention navigationStarted here.
On my side: I will file a bug for your initial scenario. I'm not sure exactly how we should handle navigating to this https://not-a-valid-domain.example URL, but normally unknown error should be reserved for failed navigations, so that error looks fishy and in any case the error message means we didn't handle the navigation properly.
juliandescottes
left a comment
There was a problem hiding this comment.
Thanks, just some comments on my end, will take another look once they are addressed.
| - : A string that contains the [UUID](/en-US/docs/Glossary/UUID) that uniquely identifies this navigation. | ||
| This ID matches the `navigation` value in the response of the [`browsingContext.navigate`](/en-US/docs/Web/WebDriver/Reference/BiDi/Modules/browsingContext/navigate) and [`browsingContext.reload`](/en-US/docs/Web/WebDriver/Reference/BiDi/Modules/browsingContext/reload) commands. | ||
| - `timestamp` | ||
| - : A non-negative integer that represents the time in UTC when the event was fired, as milliseconds elapsed since the [epoch](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#the_epoch_timestamps_and_invalid_date). |
There was a problem hiding this comment.
Isn't it confusing to mention UTC here? This is just a number of ms since epoch, timezones should not matter.
| - : A string that contains the ID of the context in which the HTML document is being parsed. | ||
| - `navigation` | ||
| - : A string that contains the [UUID](/en-US/docs/Glossary/UUID) that uniquely identifies this navigation. | ||
| This ID matches the `navigation` value in the response of the [`browsingContext.navigate`](/en-US/docs/Web/WebDriver/Reference/BiDi/Modules/browsingContext/navigate) and [`browsingContext.reload`](/en-US/docs/Web/WebDriver/Reference/BiDi/Modules/browsingContext/reload) commands. |
There was a problem hiding this comment.
As a general note, navigation (and navigation events) can be triggered by other means than calling navigate or reload. Maybe hint at that by saying "if the navigation was started through a command". Otherwise it might give the impression that the navigation id is not going to be set for navigations which were not initiated by the command?
Could also be nice to mention that the navigation id is shared by all the events related to this navigation: that is all browsingContext navigation events, as well as the network events.
|
|
||
| ## Description | ||
|
|
||
| In the lifecycle of a failed navigation, this event fires after [`browsingContext.navigationStarted`](/en-US/docs/Web/WebDriver/Reference/BiDi/Modules/browsingContext/navigationStarted) when the navigation cannot be completed. |
There was a problem hiding this comment.
Cannot be completed is too vague, but at the same time I don't have a good short definition for this. Based on the list of examples, we could say that the navigation is blocked (could be for security/csp reason, because the user canceled the unload prompt...)
Maybe having navigationAborted documented could help a bit, Chrome implements it AFAIK. This one is triggered when we abort a document load.
Description
This PR adds pages for the following navigation and page load events:
browsingContext.navigationStartedbrowsingContext.navigationCommittedbrowsingContext.domContentLoadedbrowsingContext.loadbrowsingContext.navigationFailedbrowsingContext.fragmentNavigatedbrowsingContext.historyUpdatedNote
browsingContext.navigationAbortedis not documented yet. The BCD key is also missing for this event. I'll cover it when there is an implementation.Spec links
Related issue
Doc issue: mdn/mdn#339