Re: [w3c/webcomponents] [WebDriver] Testability of web components (#771)

I think there is some confusion here :)

It's clear that testing APIs should be able to pierce the shadow trees in ways that content APIs are forbidden to. This is already how e.g. devtools behaves, so it's clearly also something that's possible to implement in browsers.

The WebDriver issue (https://github.com/w3c/webdriver/pull/1320) contains a couple of plausible suggestions for how to handle this, basically variants of @rniwa's suggeseted "given an element get me the shadow root". One (from @gsnedders) is literally that; the other one is "Find shadow elements" where you use a (standard) selector to get a set of elements but return the shadow root attached to the elements (if any) rather than the elements themselves.

One other suggestion that came up there was to ressurrect the shadow piercing CSS selectors but only for a test context. My suspicion is that's a bigger implementation change and we should hold off until we have a better feeling for the pain points in testing this stuff.

The other question was around interactability testing; WebDriver uses `elementsFromPoint` to figure out if events like click should reach an element. Naively this doesn't work for shadow DOM since `elementsFromPoint` called on the document will always result in the top-level shadow host being returned. However it looks like there's some intent to add `elementsFromPoint` to the `DocumentOrShadowRoot` interface, which I think solves this problem ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/elementsFromPoint) lists it as a member, but afaict the [CSSOM Spec](https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface) lists it on `Document` only). Assuming this is on `DocumentOrShadowRoot`, I think you just need to perform the interactability check on all the `ShadowRoot` or `Document` nodes up to the root.

So my suspicion is that modulo the CSSOM spec not putting the necessary interfaces on `ShadowRoot`, we have enough information/features to put together a complete proposal and ask for review.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/771#issuecomment-438995540

Received on Thursday, 15 November 2018 10:38:34 UTC