Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Test Enabling/Disabling CPU Sleep with Power Management API</title>
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
8 </head>
9 <body>
10 <p id="display"></p>
11 <div id="content" style="display: none"></div>
12 <pre id="test">
13 <script type="application/javascript">
15 "use strict";
17 function testEnableSleep() {
18 try {
19 navigator.mozPower.cpuSleepAllowed = true;
20 ok(navigator.mozPower.cpuSleepAllowed === true, "Allow entering suspend state.");
21 } catch (e) {
22 ok(false, "Unexpected exception trying to enable entering suspend state.");
23 }
24 }
26 function testDisableSleep() {
27 try {
28 navigator.mozPower.cpuSleepAllowed = false;
29 ok(navigator.mozPower.cpuSleepAllowed === false, "Deny entering suspend state.");
30 } catch (e) {
31 ok(false, "Unexpected exception trying to disable entering suspend state.");
32 }
33 }
35 function startTests() {
36 testDisableSleep();
37 testEnableSleep();
39 SimpleTest.finish();
40 }
42 SimpleTest.expectAssertions(0, 9);
43 SimpleTest.waitForExplicitFinish();
44 if (SpecialPowers.hasPermission("power", document)) {
45 // Currently only applicable on FxOS
46 if (navigator.userAgent.indexOf("Mobile") != -1 &&
47 navigator.appVersion.indexOf("Android") == -1) {
48 startTests();
49 } else {
50 ok(true, "mozPower on Firefox OS only.");
51 SimpleTest.finish();
52 }
53 } else {
54 // Add the permission and reload so it's propogated
55 SpecialPowers.addPermission("power", true, document);
56 window.location.reload();
57 }
58 </script>
59 </pre>
60 </body>
61 </html>