2014-07-24 23:57:02 +04:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1009645
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Test for Bug 1009645</title>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1009645">Mozilla Bug 1009645</a>
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
2015-08-25 13:35:17 +03:00
|
|
|
var b2gOnly;
|
2014-07-24 23:57:02 +04:00
|
|
|
|
2015-08-25 13:35:17 +03:00
|
|
|
function pref(name) {
|
|
|
|
try {
|
|
|
|
return SpecialPowers.getBoolPref(name);
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2014-07-24 23:57:02 +04:00
|
|
|
|
2015-08-25 13:35:17 +03:00
|
|
|
function testAPIs() {
|
2014-07-24 23:57:02 +04:00
|
|
|
var APIEndPoints = [
|
|
|
|
{ name: "MozMobileNetworkInfo", enabled: pref("dom.mobileconnection.enabled") },
|
|
|
|
// { name: "Navigator.mozBluetooth", enabled: b2gOnly }, // conditional on MOZ_B2G_BT, tricky to test
|
|
|
|
{ name: "Navigator.mozContacts", enabled: pref("dom.mozContacts.enabled") },
|
|
|
|
{ name: "Navigator.getDeviceStorage", enabled: pref("device.storage.enabled") },
|
|
|
|
{ name: "Navigator.addIdleObserver", enabled: true },
|
|
|
|
{ name: "Navigator.mozNetworkStats", enabled: pref("dom.mozNetworkStats.enabled") },
|
|
|
|
{ name: "Navigator.push", enabled: pref("services.push.enabled") },
|
2014-08-12 20:50:12 +04:00
|
|
|
// { name: "Navigator.mozTime", enabled: b2gOnly }, // conditional on MOZ_TIME_MANAGER, tricky to test
|
2014-07-24 23:57:02 +04:00
|
|
|
// { name: "Navigator.mozFMRadio", enabled: b2gOnly }, // conditional on MOZ_B2G_FM, tricky to test
|
|
|
|
{ name: "Navigator.mozCameras", enabled: true },
|
|
|
|
{ name: "Navigator.mozAlarms", enabled: pref("dom.mozAlarms.enabled") },
|
|
|
|
{ name: "Navigator.mozTCPSocket", enabled: pref("dom.mozTCPSocket.enabled") },
|
|
|
|
{ name: "Navigator.mozInputMethod", enabled: pref("dom.mozInputMethod.enabled") },
|
|
|
|
{ name: "Navigator.mozMobileConnections", enabled: pref("dom.mobileconnection.enabled") },
|
|
|
|
{ name: "Navigator.getMobileIdAssertion", enabled: b2gOnly },
|
|
|
|
{ name: "XMLHttpRequest.mozSystem", enabled: true }
|
|
|
|
];
|
|
|
|
|
|
|
|
var promises = [];
|
|
|
|
APIEndPoints.forEach(function(v) {
|
|
|
|
promises.push(navigator.hasFeature("api.window." + v.name));
|
|
|
|
});
|
2015-08-25 13:35:17 +03:00
|
|
|
|
|
|
|
return Promise.all(promises).then(function(values) {
|
2014-07-24 23:57:02 +04:00
|
|
|
for (var i = 0; i < values.length; ++i) {
|
2015-05-13 02:52:01 +03:00
|
|
|
is(values[i], APIEndPoints[i].enabled,
|
|
|
|
"Endpoint " + APIEndPoints[i].name + " resolved with the correct value. " +
|
|
|
|
"If this is failing because you're changing how an API is exposed, you " +
|
|
|
|
"must contact the Marketplace team to let them know about the change.");
|
2014-07-24 23:57:02 +04:00
|
|
|
}
|
|
|
|
}, function() {
|
|
|
|
ok(false, "The Promise should not be rejected");
|
2015-08-25 13:35:17 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function testExtensions() {
|
|
|
|
if (!b2gOnly) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
return navigator.hasFeature("web-extensions").then(function(value) {
|
|
|
|
is(value, true, "Resolve the Promise with " + value + " for web-extensions");
|
|
|
|
}, function() {
|
|
|
|
ok(false, "The Promise should not be rejected");
|
2014-07-24 23:57:02 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
SpecialPowers.pushPermissions([
|
|
|
|
{type: "feature-detection", allow: true, context: document}
|
|
|
|
], function() {
|
2015-08-25 13:35:17 +03:00
|
|
|
b2gOnly = (function() {
|
|
|
|
var isAndroid = !!navigator.userAgent.includes("Android");
|
|
|
|
var isMulet = pref("b2g.is_mulet");
|
|
|
|
var isB2g = isMulet || (!isAndroid && /Mobile|Tablet/.test(navigator.userAgent));
|
|
|
|
return isB2g ? true : undefined;
|
|
|
|
})();
|
|
|
|
|
2014-07-24 23:57:02 +04:00
|
|
|
ok('hasFeature' in navigator, "navigator.hasFeature should exist");
|
2015-08-25 13:35:17 +03:00
|
|
|
testAPIs().then(testExtensions).catch(function(e) {
|
|
|
|
ok(false, "The Promise should not be rejected: " + e);
|
|
|
|
}).then(SimpleTest.finish);
|
2014-07-24 23:57:02 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|