зеркало из https://github.com/mozilla/gecko-dev.git
110 строки
3.0 KiB
HTML
110 строки
3.0 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=979109
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for Bug 979109</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=983502">Mozilla Bug 983502</a>
|
|
<script type="application/javascript">
|
|
|
|
function testSupported() {
|
|
var mem;
|
|
navigator.getFeature("hardware.memory").then(function(mem) {
|
|
|
|
var isLinux = (navigator.platform.indexOf('Linux') != -1);
|
|
var isAndroid = !!navigator.userAgent.contains("Android");
|
|
var isB2G = !isAndroid && /Mobile|Tablet/.test(navigator.userAgent);
|
|
|
|
if (isLinux) {
|
|
info("It is Linux version:");
|
|
}
|
|
if (isAndroid) {
|
|
info("It is Android version");
|
|
}
|
|
if (isB2G) {
|
|
info("It is B2G version");
|
|
}
|
|
|
|
if (isLinux || isAndroid || isB2G) {
|
|
ok(typeof mem === 'number' && (mem) % 1 === 0, "We should receive an integer on this platform");
|
|
ok(mem > 0, "hardware.memory is supported on this platform. mem=" + mem + "MiB");
|
|
} else {
|
|
ok(typeof mem === 'undefined', "hardware.memory is not support on this platform");
|
|
}
|
|
|
|
runNextTest();
|
|
|
|
},function(mem) {
|
|
ok(false, "The Promise should not be rejected");
|
|
});
|
|
}
|
|
|
|
function testNotSupported() {
|
|
var tv;
|
|
navigator.getFeature("hardware.tv").then(function(tv) {
|
|
ok(typeof tv === 'undefined', "Resolve the Promise with undefined value (hardware.tv)");
|
|
runNextTest();
|
|
},function(tv) {
|
|
ok(false, "The Promise should not be rejected")
|
|
});
|
|
}
|
|
|
|
function createManifestTest(aFeature) {
|
|
return function() {
|
|
var res;
|
|
navigator.getFeature(aFeature).then(function(res) {
|
|
ok(res === true, "Resolve the Promise with 'true' for " + aFeature);
|
|
runNextTest();
|
|
},function(tv) {
|
|
ok(false, "The Promise should not be rejected")
|
|
});
|
|
}
|
|
}
|
|
|
|
var currentTest = -1;
|
|
var tests = [
|
|
testNotSupported,
|
|
testSupported,
|
|
createManifestTest("manifest.origin"),
|
|
createManifestTest("manifest.redirects")
|
|
];
|
|
|
|
function runNextTest() {
|
|
currentTest++;
|
|
if (currentTest < tests.length) {
|
|
tests[currentTest]();
|
|
} else {
|
|
SimpleTest.finish();
|
|
}
|
|
}
|
|
|
|
info("About to run " + tests.length + " tests");
|
|
|
|
SpecialPowers.pushPermissions([
|
|
{type: "feature-detection", allow: 1, context: document}
|
|
], function() {
|
|
ok('getFeature' in navigator, "navigator.getFeature should exist");
|
|
// B2G specific manifest features.
|
|
// Touching navigator before pushPermissions makes it fail.
|
|
if (!navigator.userAgent.contains("Android") &&
|
|
/Mobile|Tablet/.test(navigator.userAgent)) {
|
|
info("Adding B2G specific tests");
|
|
tests.push(createManifestTest("manifest.chrome.navigation"));
|
|
tests.push(createManifestTest("manifest.precompile"));
|
|
}
|
|
runNextTest();
|
|
ok(true, "Test DONE");
|
|
});
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|