Confirmed users
657
edits
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
= Navigator. | = Navigator.getFeature API = | ||
== Use Cases == | == Use Cases == | ||
Line 12: | Line 12: | ||
[NoInterfaceObject] | [NoInterfaceObject] | ||
interface NavigatorFeatures { | interface NavigatorFeatures { | ||
Promise getFeature(DOMString name); | Promise getFeature(DOMString name); | ||
}; | }; | ||
Line 19: | Line 18: | ||
== Semantics == | == Semantics == | ||
getFeature accepts a string argument to denote the feature name. getFeature resolves the promise with an undefined value if the feature name passed to them is unknown. For the "api" namespace as described below, getFeature will fullfill the promise with a true value if the feature exists on the "platform" (which means the current state and version of the hardware and the UA software) albeit hidden behind some runtime permissions, and it will fulfill the promise with a false value if the feature doesn't exist on the "platform". The type of that value depends on the feature being queried. | |||
The feature name specifies a namespaced value in the following form: | The feature name specifies a namespaced value in the following form: | ||
Line 64: | Line 63: | ||
The second example checks to see if the privileged FM Radio API is available. | The second example checks to see if the privileged FM Radio API is available. | ||
navigator. | navigator.getFeature("api.window.Navigator.mozFMRadio").then(function(enabled) { | ||
if (enabled) { | if (enabled) { | ||
alert("FM Radio support detected, my privileged app will work!"); | alert("FM Radio support detected, my privileged app will work!"); | ||
} | } | ||
}); | }); |