1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/power/test/test_power_set_cpusleepallowed.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <meta charset="utf-8"> 1.8 + <title>Test Enabling/Disabling CPU Sleep with Power Management API</title> 1.9 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.10 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 +</head> 1.12 +<body> 1.13 +<p id="display"></p> 1.14 +<div id="content" style="display: none"></div> 1.15 +<pre id="test"> 1.16 + <script type="application/javascript"> 1.17 + 1.18 + "use strict"; 1.19 + 1.20 + function testEnableSleep() { 1.21 + try { 1.22 + navigator.mozPower.cpuSleepAllowed = true; 1.23 + ok(navigator.mozPower.cpuSleepAllowed === true, "Allow entering suspend state."); 1.24 + } catch (e) { 1.25 + ok(false, "Unexpected exception trying to enable entering suspend state."); 1.26 + } 1.27 + } 1.28 + 1.29 + function testDisableSleep() { 1.30 + try { 1.31 + navigator.mozPower.cpuSleepAllowed = false; 1.32 + ok(navigator.mozPower.cpuSleepAllowed === false, "Deny entering suspend state."); 1.33 + } catch (e) { 1.34 + ok(false, "Unexpected exception trying to disable entering suspend state."); 1.35 + } 1.36 + } 1.37 + 1.38 + function startTests() { 1.39 + testDisableSleep(); 1.40 + testEnableSleep(); 1.41 + 1.42 + SimpleTest.finish(); 1.43 + } 1.44 + 1.45 + SimpleTest.expectAssertions(0, 9); 1.46 + SimpleTest.waitForExplicitFinish(); 1.47 + if (SpecialPowers.hasPermission("power", document)) { 1.48 + // Currently only applicable on FxOS 1.49 + if (navigator.userAgent.indexOf("Mobile") != -1 && 1.50 + navigator.appVersion.indexOf("Android") == -1) { 1.51 + startTests(); 1.52 + } else { 1.53 + ok(true, "mozPower on Firefox OS only."); 1.54 + SimpleTest.finish(); 1.55 + } 1.56 + } else { 1.57 + // Add the permission and reload so it's propogated 1.58 + SpecialPowers.addPermission("power", true, document); 1.59 + window.location.reload(); 1.60 + } 1.61 + </script> 1.62 +</pre> 1.63 +</body> 1.64 +</html>