Skip to content
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

Custom handlers automation #8267

Merged
merged 29 commits into from
Jan 11, 2023

Conversation

javifernandez
Copy link
Contributor

@javifernandez javifernandez commented Sep 6, 2022

This commit adds a new subsection about User Agent Automation in the Custom Handlers section. The purpose of this new subsection is to define a new WebDriver extension command to define auto-replies for the prompt dialog that the spec suggests to offer to the user in order to grant the registration of a new protocol handler.

Fixes #8251.


/index.html ( diff )
/infrastructure.html ( diff )
/references.html ( diff )
/system-state.html ( diff )

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated

<hr>

<p>The <dfn>current registration automation mode</dfn> tracks what
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the "current registration automation mode" belong to? Is it user-agent wide? Window? Browsing context?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut feeling is that it should belong to a Browser Context, but I'd appreciate comments and / or suggestions on that regard.

Since this flag/attribute is intended for testing purposes only, and give than we might encourage that the user agent first verify that its handled in an automation context, it makes sense that its indeed associated to a browser context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My default suggestion would be Document. I would be surprised if you set this, and then navigated to a totally different page (e.g. on another origin), and the setting persisted.

However, if such browsing context-wide impacts are normal for WebDriver, then maybe browsing context is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admit you are right that is difficult to imagine a scenario where is useful to keep this flag across different Documents. However, many of the currently defined WebDriver commands "happen in the context of either the current browsing context or current top-level browsing context".

Additionally, if I've understood it correctly, the WPT's testdriver,js, which is the JS implementation of the WebDriver client, is expected to operate across different browser context.

I'm not sure whether restricting the use of the "current registration automation mode" to the Document would limit how we could use it to define certain tests.

The Secure Payment Confirmation spec, which inspired me to define this new extension command, doesn't specify where the current-transaction-automation-mode belongs to. I agree we could do better in this PR and specify clearly that this flag is stored either in the current browser context or in its associated active document, whatever we end up agreeing on.

I'd like to get feedback from @jgraham on this regard, but my opinion is still that using the Browser Context is more convenient in this case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most current WebDriver commands aren't setting state that persists across navigation, so although they operate at the level of browsing contexts, the action of the command is on the active document in that context.

The exceptions are mostly WebDriver-internal state which is mostly per session (i.e. global). Argably the closest analogue to this feature is the User Prompt handler, which is a global setting which affects what happens when an alert appears. I don't think that's good design, but in the context of WebDriver it makes sense; in particular if the handler was per-document then it wouldn't be possible to reliably setup the handling before an alert appears.

So I think the question is: do you need to handle cases where registerProtocolHandler is called without user interaction? If not per-document state is probably fine. If you do then it's hard to see how to make that work without the state being global.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least Chrome, and I believe is Firefox too, require that calls to registerProtocolHandler are done under a transient user activation. Hence, in order to define automated tests we would need to use the test_driver.bless function. You can see some WPT examples in the PR I have for this proposal.

The state we are adding here would only apply under a testing context and only modified via the WebDriver extension command. I agree that its goal is almost the same than the User Prompt Handler; as a matter of fact II tried to implement the automated tests using it, but it only works with simple dialogs so its not an option in this case.

As I commented in the issue where I introduced the proposal, we already have a WebDriver extension command that provides a similar feature, the Set SPC Transaction Mode command. Unfortunately, in that spec it doesn't specify where the state belongs to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most current WebDriver commands aren't setting state that persists across navigation, so although they operate at the level of browsing contexts, the action of the command is on the active document in that context.

Based on this comment from @jgraham and @domenic's preference for Document as the owner of this new flag, I'll change the PR to sate it explicitly.

source Outdated Show resolved Hide resolved
source Outdated
argument</span>.</p>
</li>
<li>
<p>Set the <span>current registration automation mode</span> to <i>mode</i>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem here with what object the current registration automation mode belongs to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said before, I believe this should belong to the browser context.

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@javifernandez
Copy link
Contributor Author

Thanks for the review. See my comments inline.

@javifernandez
Copy link
Contributor Author

Hi @domenic I pushed some changes, trying to address all the changes requested in the last review. Could you please take another look ?

source Outdated Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Outdated

<hr>

<p>The <dfn>current registration automation mode</dfn> tracks what
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My default suggestion would be Document. I would be surprised if you set this, and then navigated to a totally different page (e.g. on another origin), and the setting persisted.

However, if such browsing context-wide impacts are normal for WebDriver, then maybe browsing context is better.

source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, mostly editorial stuff, plus the big question of where the current registration mode should be stored, which is still outstanding.

source Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I made a variety of changes in my last few commits to fix remaining errors. Please take a look and let me know if they look reasonable. In that case, we can proceed to merge this.

@javifernandez
Copy link
Contributor Author

Hi @domenic, thanks for the reviews and the last edits; they all look good to me.

@domenic
Copy link
Member

domenic commented Nov 23, 2022

Hmm, I realized this doesn't actually have multi-implementer support? I guess you are implementing for Chromium, but you linked to mozilla/standards-positions#685 for Mozilla, which has no replies.

Let me know when you have a second implementer interested, and then we can merge.

@javifernandez
Copy link
Contributor Author

Let me know when you have a second implementer interested, and then we can merge.

Yes, I''ve got some informal support from @jgraham during a meeting to review the WPT RFC , but I agree we should wait until we got explicit support in the position request. There is also an ongoing conversation in the Firefox bug I've filed, but again still not clear support there either.

@javifernandez
Copy link
Contributor Author

Hmm, I realized this doesn't actually have multi-implementer support? I guess you are implementing for Chromium, but you linked to mozilla/standards-positions#685 for Mozilla, which has no replies.

Let me know when you have a second implementer interested, and then we can merge.

There was some recent feedback on the mozilla standard-position request; do you think it'd be enough to move forward ?

@domenic
Copy link
Member

domenic commented Dec 7, 2022

Let's ask: @jgraham, based on your comments there, would you be happy to see this in the HTML Standard?

@javifernandez
Copy link
Contributor Author

Let's ask: @jgraham, based on your comments there, would you be happy to see this in the HTML Standard?

FWIW, I'm in conversations with some Firefox devs regarding the implementation of this webdriver extension command in Marionette.

@jgraham
Copy link
Member

jgraham commented Jan 10, 2023

I'd say if other implementors are happy with this approach then Mozilla are too.

@domenic domenic merged commit 3ea8e08 into whatwg:main Jan 11, 2023
T3-M4 pushed a commit to bayandin/chromedriver that referenced this pull request Feb 4, 2023
The PR#8267 [1] for the HTML spec introduced a new WebDriver extension
command to allow testing automation for the registerProtocolHandler
method of the Custom Handlers API.

This CL adds support in ChromeDriver for such extension command. See
also the Web Platform Test PR [2] and RFC [3] for further details.

The extension command relies on a new CDP command implemented in a different CL [4].

[1] whatwg/html#8267
[2] web-platform-tests/wpt#35792
[3] web-platform-tests/rfcs#121
[4] https://crrev.com/c/4203529

Bug: 1359103
Change-Id: Ifd4385815ab30a40f46c2f083dc9604024060613
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4200660
Reviewed-by: Vladimir Nechaev <nechaev@chromium.org>
Commit-Queue: Javier Fernandez <jfernandez@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1100968}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

WebDriver extension for Custom Handlers
3 participants