dom/power/test/test_power_set_cpusleepallowed.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial