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

Implement consume_user_activation() web driver components #40699

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

marcoscaceres
Copy link
Contributor

Matches the consume-user-activation WebDriver command, which corresponds to these steps in HTML: https://html.spec.whatwg.org/#consume-user-activation

@marcoscaceres marcoscaceres force-pushed the only_consume_user_activation branch from 1cac50e to eb9278a Compare December 18, 2023 01:09
@wpt-pr-bot wpt-pr-bot added docs wptrunner The automated test runner, commonly called through ./wpt run labels Dec 18, 2023
@sideshowbarker sideshowbarker removed their request for review December 18, 2023 01:21
@marcoscaceres marcoscaceres force-pushed the only_consume_user_activation branch 3 times, most recently from bc3e0bc to 5cb66ef Compare December 18, 2023 01:25
Copy link
Member

@gsnedders gsnedders 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 this is my only comment here?

self.webdriver = self.parent.webdriver

def consume_user_activation(self):
return self.webdriver.send_session_command("POST", "consume-user-activation")
Copy link
Member

Choose a reason for hiding this comment

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

Can you instead just add this as a method somewhere on the WebDriver library (in tools/webdriver), rather than directly invoking the command?

Copy link
Member

Choose a reason for hiding this comment

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

Specifically, you probably want something like:

@command
def maximize(self):
return self.session.send_session_command("POST", "window/maximize")

And then this becomes:

Suggested change
return self.webdriver.send_session_command("POST", "consume-user-activation")
return self.webdriver.window.consume_user_activation()

Copy link
Member

Choose a reason for hiding this comment

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

Also, isn't the command window/consume-user-activation?

resources/testdriver.js Outdated Show resolved Hide resolved
tools/wptrunner/wptrunner/executors/actions.py Outdated Show resolved Hide resolved
tools/wptrunner/wptrunner/executors/executormarionette.py Outdated Show resolved Hide resolved
def setup(self):
self.webdriver = self.parent.webdriver

def consume_user_activation(self):
Copy link
Member

Choose a reason for hiding this comment

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

Does this not need to take a context argument, from tools/wptrunner/wptrunner/executors/actions.py above? Because otherwise we're just outright ignoring the context argument specified in testdriver.js in the sole implementation.

tools/wptrunner/wptrunner/executors/protocol.py Outdated Show resolved Hide resolved
self.webdriver = self.parent.webdriver

def consume_user_activation(self):
return self.webdriver.send_session_command("POST", "consume-user-activation")
Copy link
Member

Choose a reason for hiding this comment

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

Specifically, you probably want something like:

@command
def maximize(self):
return self.session.send_session_command("POST", "window/maximize")

And then this becomes:

Suggested change
return self.webdriver.send_session_command("POST", "consume-user-activation")
return self.webdriver.window.consume_user_activation()

Copy link
Member

@gsnedders gsnedders left a comment

Choose a reason for hiding this comment

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

To summarise what I just posted:

  • There's a context argument sometimes and not otherwise; it seems like you're currently just dropping it on the floor with the current implementation. I'd be happy to land this with no context argument (after all, that matches the WebDriver UX), which avoids needing to change much aside from the changing the JS side.
  • Adding the command to the webdriver module.

Also, can you also add some test to /infrastructure/testdriver to verify the testdriver command works where expected?

@marcoscaceres
Copy link
Contributor Author

marcoscaceres commented Feb 23, 2024

The context definitely matters, because you can deactivate cross origin frames... I saw a lot of other things take a context but also don't use it on the python side (so I has assumed magic happened... but it's also sad that people are dropping context on the floor).

Anyway, yes! Let's get that context passed around!!

@gsnedders
Copy link
Member

The context definitely matters, because you can deactivate cross origin frames... I saw a lot of other things take a context but also don't use it on the python side (so I has assumed magic happened... but it's also sad that people are dropping context on the floor).

Anyway, yes! Let's get that context passed around!!

it's plausible there's some magic somewhere, and I'm just unaware of it! digs around

seemingly ActionContext in tools/wptrunner/wptrunner/executors/base.py does this, ultimately.

@marcoscaceres marcoscaceres changed the title Add consume_user_activation() to testdriver.js Implement consume_user_activation() web driver components Feb 23, 2024
@wpt-pr-bot wpt-pr-bot requested review from domenic and jdm May 27, 2024 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants