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

test_driver actions don't work on targets in shadow DOM #41257

Open
nt1m opened this issue Jul 31, 2023 · 9 comments
Open

test_driver actions don't work on targets in shadow DOM #41257

nt1m opened this issue Jul 31, 2023 · 9 comments
Labels

Comments

@nt1m
Copy link
Member

nt1m commented Jul 31, 2023

After merging #41251 (which works fine on webkit's test runner infrastructure), I realized test_driver does not actually support targets in shadow DOM, because it tries to create a selector, which doesn't really work in a shadow dom context.

cc @domenic @mfreed7 @josepharhar @rniwa @gsnedders @jgraham

@mfreed7
Copy link
Contributor

mfreed7 commented Aug 1, 2023

Can you point to where it's trying to create a selector from element? I feel like I've used test_driver.Actions().pointerMove(x,y,{origin: element}) with element in a shadow root and things worked correctly. But I could be mistaken. I do notice none of the popover/shadow tests use it.

@nt1m
Copy link
Member Author

nt1m commented Aug 1, 2023

action.origin = {selector: get_selector(action.origin)};

You can see the test failing here in Chrome for this exact reason: https://wpt.fyi/results/html/semantics/popovers/popover-light-dismiss-flat-tree.html?diff&filter=ADC&run_id=5102411146854400&run_id=5205993141567488

ValueError: Selector '#\69 \6e \6e \65 \72 \50 \6f \70 \6f \76 \65 \72 \54 \6f \67 \67 \6c \65 ' matches no elements

@mfreed7
Copy link
Contributor

mfreed7 commented Aug 1, 2023

Ahh, you're right. I think maybe right here:

https://source.chromium.org/chromium/chromium/src/+/main:third_party/wpt_tools/wpt/tools/wptrunner/wptrunner/testdriver-extra.js;l=95;drc=9bf3c522b764982e35548f83f3253741f70454f7

That seems quite baked into the WPT runner platform, which is unfortunate. No quick fix that I can see.

@domenic
Copy link
Member

domenic commented Aug 2, 2023

I feel like in the past there was talk of adding shadow-piercing selectors specifically for use in automation tooling, not exposed to the web at large. I don't know where those discussions happened or where they ended up though...

I'll blindly tag @mathiasbynens as my general "person who knows these sorts of things".

@mathiasbynens
Copy link
Contributor

We recently revisited this in the context of WebDriver BiDi: w3c/webdriver-bidi#342 The outcome was that at this point, this functionality should be implemented by clients rather than built into the spec.

@jgraham
Copy link
Contributor

jgraham commented Aug 2, 2023

Right, I think the WebDriver group in particular don't want to try to specify custom selectors. If the CSSWG wanted to specify it they would probably be used.

In the meantime this is fixable with some effort; if you can get a reference to the element with script then at least in theory we can split the element selection into multiple parts, one for each shadow tree. Then the WebDriver side should be able to do the shadow tree traversal. Alternatively one could make it work for the same-origin case by not depending on postMessage for communication with the top-level test window and directly sending the element back rather than a selector that should match the element.

We're probably also pretty close to the point where we could implement a WebDriver-BiDi backend for wptrunner / testdriver, which would solve this problem by allowing us to avoid the pile of hacks required to handle the fact that WebDriver requires synchronous, blocking communication with a single Window at a time.

@josepharhar
Copy link
Contributor

test_driver.click() doesn't work on elements in shadowdom, which I tried to fix here but it got complicated and I gave up for now: #37483
I don't think it was due to an issue with selectors, but it does fit under the title of this issue

@gsnedders
Copy link
Member

test_driver.click() doesn't work on elements in shadowdom, which I tried to fix here but it got complicated and I gave up for now: #37483 I don't think it was due to an issue with selectors, but it does fit under the title of this issue

See also #37942

@emilio
Copy link
Contributor

emilio commented Feb 29, 2024

I have a workaround for this for the popover tests in https://phabricator.services.mozilla.com/D203152.

moz-wptsync-bot pushed a commit that referenced this issue Mar 1, 2024
This works around #41257
and enables the tests.

Differential Revision: https://phabricator.services.mozilla.com/D203152

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1878104
gecko-commit: 343b540522ec81232a7eaa98161c1065d3391796
gecko-reviewers: dholbert
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Mar 1, 2024
moz-wptsync-bot pushed a commit that referenced this issue Mar 1, 2024
This works around #41257
and enables the tests.

Differential Revision: https://phabricator.services.mozilla.com/D203152

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1878104
gecko-commit: 343b540522ec81232a7eaa98161c1065d3391796
gecko-reviewers: dholbert
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants