зеркало из https://github.com/mozilla/gecko-dev.git
59 строки
1.5 KiB
HTML
59 строки
1.5 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test Enabling/Disabling Screen with Power Management API</title>
|
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
</head>
|
|
<body>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none"></div>
|
|
<pre id="test">
|
|
<script type="application/javascript">
|
|
|
|
"use strict";
|
|
|
|
function testEnableKeyLight() {
|
|
try {
|
|
navigator.mozPower.keyLightEnabled = true;
|
|
ok(navigator.mozPower.keyLightEnabled === true, "Enabled key backlight.");
|
|
} catch (e) {
|
|
ok(false, "Unexpected exception trying to enable key backlight.");
|
|
}
|
|
}
|
|
|
|
function testDisableKeyLight() {
|
|
try {
|
|
navigator.mozPower.keyLightEnabled = false;
|
|
ok(navigator.mozPower.keyLightEnabled === false, "Disabled key backlight.");
|
|
} catch (e) {
|
|
ok(false, "Unexpected exception trying to disable key backlight.");
|
|
}
|
|
}
|
|
|
|
function startTests() {
|
|
|
|
// Make sure we don't suspend
|
|
navigator.mozPower.cpuSleepAllowed = false;
|
|
|
|
testDisableKeyLight();
|
|
testEnableKeyLight();
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
// Currently only applicable on FxOS
|
|
if (navigator.userAgent.indexOf("Mobile") != -1 &&
|
|
navigator.appVersion.indexOf("Android") == -1) {
|
|
startTests();
|
|
} else {
|
|
ok(true, "mozPower on Firefox OS only.");
|
|
SimpleTest.finish();
|
|
}
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|