-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invoke WebDriver BiDi history updated #10587
Conversation
LGTM (I'm not a committer, so cannot formally approve it) |
I am working on the WPT tests but I think this change is ready for initial review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about all the other history updates? E.g. navigation API, document.open(), updates from about:blank
to about:blank#foo
, ...
I believe the use of the navigation API would end up in the navigate steps where we already have instrumentation using WebDriver BiDi navigation started and WebDriver BiDi fragment navigated (also, covers fragment navigations).
What I tried to implement in this PR is to track history updated but exclude any history updates internal to the HTML spec that are a side-effect of using other navigation mechanisms, e.g., of navigate steps or processing of iframe elements. Please correct me if I am wrong about some aspects of how the spec handles history updates. |
If the navigation is intercepted by using
It changes the URL of the document in step 12.3 of https://html.spec.whatwg.org/#document-open-steps
So in particular the case like const iframe = document.createElement("iframe");
iframe.src = "about:blank?foo";
document.body.append(iframe); will first navigate to |
good point, I think we would want to emit an aborted or a failed event here. cc @jgraham
Interesting, when testing (in Chrome and Firefox) this I do not observe the fragment change on document.open. Do you know if there are existing WPT tests for this feature? I think if the URL can actually change here we would want to notify the client.
That is a special case for about:blank URLs, right? I think we should capture that, I will update the patch. |
It is conditional on "If entryDocument is not document" but I am not quite sure yet when this is the case. |
I think given these cases, we probably want to move the hook to https://html.spec.whatwg.org/#url-and-history-update-steps it looks like all the invocations could be actually relevant for automation. |
@domenic I see notes like |
The case is tested by the various files starting with
This is prohibited by https://html.spec.whatwg.org/#update-the-navigation-api-entries-for-a-same-document-navigation step 1.
This seems like the right move to me. I'll approve this and give a day or three to see if anyone else has comments, since this is a complex area, but what you've done makes sense from my perspective. |
Thanks for reviewing! let's keep it open for a week or two to let everyone review and I want to add more WPT tests. Regarding https://github.com/web-platform-tests/wpt/blob/03c258eab4bb0dc037d0b3822049cada69a49427/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url.window.js#L1-L9: it appears that initial URL is about:blank and after a change it is still about:blank. I am also confused by this test https://github.com/web-platform-tests/wpt/blob/03c258eab4bb0dc037d0b3822049cada69a49427/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/url-fragment.window.js#L1: it looks like the hash is changed on the parent, but the change is asserted on the frame document? And the second test there seems to assert the same before and after URL? |
No, on line 4 it is
The point is that
Yes, in that case the entry document is the relevant document, so there's no change, per https://html.spec.whatwg.org/#document-open-steps step 12.2. |
Thanks, I got a bit confused by DevTools, it actually does not handle this update well (still shows about:blank in the tree): Edit: filed https://crbug.com/370690261 |
We have landed the change in the WebDriver BiDi spec so this change is ready to be merged from our perspective. cc @domenic |
This PR adds a callback to the WebDriver BiDi specification to notify about history updates.
WebDriver BiDi change: w3c/webdriver-bidi#740
(See WHATWG Working Mode: Changes for more details.)
/browsing-the-web.html ( diff )
/infrastructure.html ( diff )