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.

     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>

mercurial