ISSUE-155: Enable Feature Detection

Enable Feature Detection

State:
POSTPONED
Product:
Vibration API
Raised by:
Anssi Kostiainen
Opened on:
2013-10-10
Description:
On behalf of Michael van Ouwerkerk

Hi, I'm currently working on implementing the Vibration API in Blink and
Chromium, and I'd like to propose making feature detection possible.

In its current form, the Vibration API exposes the navigator.vibrate
method. When you call it with valid arguments, it returns true. However,
this only indicates that the arguments were valid. It does not mean any
vibrations have been scheduled. Nothing might happen, perhaps because there
is no hardware for it. Do all phones have such hardware? How about tablets,
or laptops? Or, perhaps there is no permission for vibrating right now.

To give web developers an opportunity to provide a fallback for their
users, I think it should be possible to detect when they will not be able
to vibrate the device.

The simplest approach might appear to just not expose navigator.vibrate
when vibration is not available. However, this would require that the
browser detect availability of vibration in the startup path. It might be
an asynchronous process as well. This is a problem for implementation in
the browser.

My proposal is that we make use of Promises, so that the setup is
asynchronous, and it is clear how to handle failure.

In JavaScript, it would look something like this:
window.navigator.getVibrator().then(function(vibrator) {
vibrator.vibrate([100, 0, 50]);
}, function() {
// No vibrator is available. Provide fallback or exit.
});

What do you think?
Related Actions Items:
No related actions
Related emails:
  1. Re: Vibration API: making feature detection possible (from Frederick.Hirsch@nokia.com on 2013-10-17)
  2. [admin] Draft minutes 17 October 2013 teleconference (from Frederick.Hirsch@nokia.com on 2013-10-17)
  3. Re: Vibration API: making feature detection possible (from mvanouwerkerk@chromium.org on 2013-10-17)
  4. Re: Vibration API: making feature detection possible (from anssi.kostiainen@intel.com on 2013-10-17)
  5. Re: Agenda - Distributed Meeting 17 October 2013 (Thursday) (from jean-claude.dufourd@telecom-paristech.fr on 2013-10-17)
  6. Re: Agenda - Distributed Meeting 17 October 2013 (Thursday) (from dom@w3.org on 2013-10-17)
  7. Agenda - Distributed Meeting 17 October 2013 (Thursday) (from Frederick.Hirsch@nokia.com on 2013-10-17)
  8. [admin] Draft Minutes 10 October 2013 (from Frederick.Hirsch@nokia.com on 2013-10-16)
  9. Agenda - Distributed Meeting 10 October 2013 (Thursday) (from Frederick.Hirsch@nokia.com on 2013-10-10)
  10. DAP-ISSUE-155: Enable Feature Detection [Vibration API] (from sysbot+tracker@w3.org on 2013-10-10)

Related notes:

No additional notes.

Display change log ATOM feed


Anssi Kostiainen <anssi.kostiainen@intel.com>, Reilly Grant <reillyg@google.com>, Chairs, Fuqiao Xue <xfq@w3.org>, Staff Contact
Tracker: documentation, (configuration for this group), originally developed by Dean Jackson, is developed and maintained by the Systems Team <w3t-sys@w3.org>.
$Id: index.php,v 1.326 2018/10/13 17:29:51 vivien Exp $