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

Prompt handler #681

Merged
merged 4 commits into from
Jun 24, 2024
Merged

Prompt handler #681

merged 4 commits into from
Jun 24, 2024

Conversation

jgraham
Copy link
Member

@jgraham jgraham commented Mar 8, 2024

@jgraham
Copy link
Member Author

jgraham commented Mar 8, 2024

whatwg/html#10189 is the HTML side of this change. It also depends on landing w3c/webdriver#1791

Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

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

@jgraham what is the current status of this and the WhatWG PRs? Both are still marked as draft. Thanks.

index.bs Show resolved Hide resolved
@jgraham jgraham closed this Apr 9, 2024
@jgraham jgraham reopened this Apr 9, 2024
@jgraham jgraham marked this pull request as ready for review April 9, 2024 09:03
Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

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

Sorry for the delay @jgraham. But I decided to wait a bit with further feedback until the general handling of the capability has finished. I've a couple of questions that I've added inline. Maybe you can have a look at these? Thanks.

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
@whimboo
Copy link
Contributor

whimboo commented Jun 7, 2024

@jgraham as it looks like you missed to specify the steps for handling a user prompt.

@whimboo
Copy link
Contributor

whimboo commented Jun 11, 2024

@jgraham as it looks like you missed to specify the steps for handling a user prompt.

Please disregard this comment. I was searching for beforeunload in the preview document but the paragraph here lists the prompt as prompt to unload steps.

@jgraham jgraham requested a review from OrKoN June 11, 2024 08:32
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
Copy link
Contributor

@OrKoN OrKoN left a comment

Choose a reason for hiding this comment

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

LGTM

@css-meeting-bot
Copy link
Member

The Browser Testing and Tools Working Group just discussed Prompt Handler for beforeunload.

The full IRC log of that discussion <jgraham> Topic: Prompt Handler for beforeunload
<jgraham> github: https://github.com//pull/681
<orkon> jgraham: the next topic is about prompt handling, not only the beforeunload. The context is: there is a PR to add the prompt handling support based on the WebDriver spec changes. It allows to specify defaults for the BiDi only sessions. In WebDriver the handler applied to all prompt types except for beforeunload. In BiDi, you can get an event that
<orkon> there was a beforeunload prompt and the client can handle it. But that means that the way things are specified in Classic, default prompt handler does not apply to beforeunload. The question is if we want to carry this over to by and what to do when we start treating file dialogs and auth prompts. The default in classic to always ignore. And for
<orkon> file dialogs the accept does not make sense as a value. What should we do about that?
<jgraham> https://github.com//pull/681#discussion_r1634703120
<orkon> jgraham: there are multiple options. For example, we can overwrite the behavior in Classic. We could change the semantics but it might mean that things might break when updating from Classic to BiDi. We could also only allow ignore and dismiss in BiDi or remove the default.
<orkon> q+
<jgraham> ScribeNick: jgraham
<jgraham> ack next
<jgraham> orkon: We discussed on the PR. From our perspective changing the semantics and having the default apply to all prompt types seems best for BiDi. But not sure about compatibility with classic. If you're updating from classic, users might expect the default to apply to all dialogs including beforeUnload, so maybe it would fix expectations.
<jgraham> orkon: In general it's not a blocker for this proposal. We could live with accept not working for all prompt types.
<orkon> ScribeNick: orkon
<orkon> orkon: we could just make it completely breaking if you switch to BiDi. We could make it than we support only what we currently support. You can still make it work for classic+bidi session so that the syntax changes then.
<orkon> s/orkon:/jgraham:
<simonstewart> q+
<orkon> jgraham: question to the selenium users: do you want to do more with the prompt handling compared to classic?
<jgraham> ack simonstewart
<orkon> simonstewart: in the selenium project, we will be migrating the users to WebDriver BiDi as soon as possible
<jimevans> q+
<orkon> simonstewart: everyone knows that the long term future will be BiDi. The only thing we need Classic for, for teh browsers that do not support BiDi
<jgraham> ack next
<orkon> jimevans: also in selenium, we can, for a mixed session, tailor the behavior of the prompt handler for the prompts that are not part of the classic spec to match the existing behavior. Because once we enable BiDi in Selenium, we can have in one go update our methods that do prompt handling to accomodate the behavior so that the user experience is
<orkon> no different
<orkon> jimevans: so I do not see a problem with having the prompt handlers being different for bidi than for classic
<orkon> q?
<orkon> jgraham: ok what I should try is for classic: you can either provide a string value or you can provide an object and if you provide a default key on the object, then it is the default for everything. And specific keys need to be defined to override the default. Then any navigation will fail if you do not re-define the default for the beforeunload.
<orkon> If we cancel the prompt, the navigation is also cancelled. I think it is compatible with classic but also has better semantics for BiDi
<orkon> q?

Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

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

I think it looks fine now. If I detect something not working as expected we can do it in a follow-up PR.

Tests will be added as part of my work on https://bugzilla.mozilla.org/show_bug.cgi?id=1824220

@OrKoN OrKoN self-requested a review June 18, 2024 08:56
@OrKoN
Copy link
Contributor

OrKoN commented Jun 18, 2024

@jgraham so to summarize we will move on with allowing "accept" in the default values or do we still want to completely decouple from classic and drop "accept" in the default configuration and for prompts where it does not make sense? I am not sure if the PR is already updated with the latest discussions? I will take another look if it is ready.

@jgraham
Copy link
Member Author

jgraham commented Jun 18, 2024

My take is that we should allow "accept" in the default configuration, but for file it should act like cancel unless we extend with some future way to provide a default path. We kind of already do that for alert where dismiss and accept do the same thing.

But I'm also more or less OK with dropping accept from the possible default values. However it does mean you basically always have to override beforeUnload unless you actually want that to cancel navigations with unload prompts, at which point I think the default value isn't that useful at all.

index.bs Outdated
@@ -4514,6 +4541,7 @@ failed</dfn> steps given |context| and |navigation status|:
browsingContext.UserPromptClosedParameters = {
context: browsingContext.BrowsingContext,
accepted: bool,
type: "alert" / "confirm" / "prompt" / "beforeunload",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: perhaps it makes sense to extract this into a separate type and re-use between UserPromptClosedParameters and UserPromptOpenedParameters to make sure they are always the same?

The key part of this is that with BiDi HTML calls into the spec when
it's going to show a prompt. So at that point we can see if there's a
handler defined, and if so return the handler to HTML.

All the actual logic to handle the dialogs ends up in the HTML spec.

From the BiDi point of view, the intended lifecycle is that you always
get the session.userPromptOpened and session.userPromptClosed events,
even if the prompt is automatically handled. But the
session.UserPromptOpened event gets a new `handler` property that
tells you whether the prompt will be automatically handled; if this is
set to "none" the automation has to send a session.handleUserPrompt
command (or wait for the prompt to be dismissed by the user).
@jgraham jgraham requested a review from OrKoN June 24, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants