-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Make testdriver click/send_keys/actions work in more browsing contexts #25550
Conversation
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.
Thanks for doing this, I think it's a great improvement to testdriver!
Looked at the non-test files so far.
a0d357c
to
5058bf5
Compare
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.
Generally LGTM modulo comments, but seems like there are some failures in the unittests (unable to find the target window?) and the lint (mostly trailing-whitespace, one usage of console).
5058bf5
to
b8be26d
Compare
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.
LGTM after the infra tests are fixed.
b8be26d
to
af6dbe8
Compare
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.
Shall we revert a9d6d1b#diff-8f0dc082cb16d568172a0e6f39f0045c as well?
This is a slightly hacky change to allow testdriver actions to work in more browsing contexts. The basic idea is that when we want to run an action in a different borsing context, we pass wptrunner a context list like [window_id, frame_id...], and use that to select the correct browsing context just for the duration of the action, before switching back. There are a number of limitations with the current patch, some more serious than others: * So far this is only implmented for testdriver commands that take an explicit element. Other commands could be modified to also allow passing in an explicit context. * It must be possible to get a window reference and set the name property (see below). This means this approach only works for windows that are same origin with the test window. * WebDriver implementations don't generally support returning a window object from script, so we can't return a window handle directly. Instead we either use the existing window.name property or add a window.name when we try to start the action. Then in wptrunner we do a linear search of all windows to find the one with the appropriate name. We have to use window.name rather than writing a custom property into the window global because the way marionette sandboxes js we aren't able to read the global property. However despite these limitations this makes the feature considerably more versatile than it was previously.
Co-authored-by: Robert Ma <robertma@chromium.org>
a50e1a3
to
820fd31
Compare
This is a slightly hacky change to allow testdriver actions to work in
more browsing contexts. The basic idea is that when we want to run an
action in a different borsing context, we pass wptrunner a context
list like [window_id, frame_id...], and use that to select the correct
browsing context just for the duration of the action, before switching
back.
There are a number of limitations with the current patch, some more
serious than others:
So far this is only implmented for testdriver commands that take an
explicit element. Other commands could be modified to also allow
passing in an explicit context.
It must be possible to get a window reference and set the name
property (see below). This means this approach only works for
windows that are same origin with the test window.
WebDriver implementations don't generally support returning a window
object from script, so we can't return a window handle
directly. Instead we either use the existing window.name property or
add a window.name when we try to start the action. Then in wptrunner
we do a linear search of all windows to find the one with the
appropriate name. We have to use window.name rather than writing a
custom property into the window global because the way marionette
sandboxes js we aren't able to read the global property.
However despite these limitations this makes the feature considerably
more versatile than it was previously.