-
Notifications
You must be signed in to change notification settings - Fork 46
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
Best practices for feature detection of DOM API #137
Comments
https://www.w3.org/2001/tag/doc/promises-guide/#rejections-should-be-exceptional applies here I think. In particular, this does not seem exceptional. |
We have some text in section 2.3 (New Features should be Detectable) so if we have more to say on this topic it should probably be added here. |
I think there is some overlap between feature detection and fingerprinting (and private browsing mode). Of the top of my head I have heard different recommendations at different times. Examples:
All of this leads to different design and confuses users and spec authors. I am not sure what would be the right answer but it deserves some thought and it also requires some research on what kind of different solutions are in use today. |
Suggest having a dedicated breakout session on this during the non-design-review week next month. |
Things to keep in mind
Current different ways (non-exaustive):
if ('bluetooth' in navigator)
if ('NFCReader' in window)
const capabilities = videoTrack.getCapabilities();
if ("pan" in capabilities) { ... } |
@triblondon do you have opinions here? |
Not strictly feature detection, but maybe still interesting: the Shape Detection API has a |
I wonder if there is a solution that enables developers to detect features, but also restricts/reduces fingerprinting? e.g. browsers are smart enough now to differentiate between a user-driven-event like a mouse click vs. a simulated .click() event applied to a link/button to determine if triggered code like a window.open() call should be allowed or not. This was done to stop spammy websites from launching popup ads, but still allow "desired" popups in web applications. As such, for many of these features... I wonder if a Just In Time (JIT) model might work where by a check to detect a feature would only be allowed if the code following it attempts to use it.
Not foolproof by any means, but mixed with browser permissions by domain etc. might cover most cases. |
It seems like this doesn't help much with fingerprinting, since it's still exposing the information about whether the device is available or not (unless the latter response is after a permission prompt). It's also worth noting that "implementation doesn't support X" and "implementation supports X but there aren't any devices available" are different results that pages might want to handle in different ways. |
... so what I'm saying is that detection of the support for a feature in the implementation should generally be separate from detection of whether a device to do something with that feature is available. (And the latter might be after a request for user permission.) |
…ection. While discussing w3ctag#137 with @kenchris and @atanassov I realized that the existing advice in this section could be misinterpreted. This clarifies that advice. (It's not a fix for that issue, though, but it is related.)
…ection. While discussing w3ctag#137 with @kenchris and @atanassov I realized that the existing advice in this section could be misinterpreted. This clarifies that advice. (It's not a fix for that issue, though, but it is related.)
…ection (#201) * Add paragraph about device detection to clarify advice on feature detection. While discussing #137 with @kenchris and @atanassov I realized that the existing advice in this section could be misinterpreted. This clarifies that advice. (It's not a fix for that issue, though, but it is related.) * Link to section on device enumeration.
Discussed and agreed to close at our f2f. |
One example: WebXR have a feature detection method,
supportsSession()
, which returns a promise which rejects if the session type is not supported.Should this return a
Promise<boolean>
, on the principle that feature detection shouldn't throw?Also, what other best practices are there for feature detection?
cc @torgo
The text was updated successfully, but these errors were encountered: