dom/power/test/test_power_set_screen_enabled.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 Screen 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 testEnableScreen() {
    18     try {
    19       navigator.mozPower.screenEnabled = true;
    20       ok(navigator.mozPower.screenEnabled === true, "Enabled screen.");
    21     } catch (e) {
    22       ok(false, "Unexpected exception trying to enable screen.");
    23     }
    24   }
    26   function testDisableScreen() {
    27     try {
    28       navigator.mozPower.screenEnabled = false;
    29       ok(navigator.mozPower.screenEnabled === false, "Disabled screen.");
    30     } catch (e) {
    31       ok(false, "Unexpected exception trying to disable screen.");
    32     }
    33   }
    35   function startTests() {
    37     // Make sure we don't suspend
    38     navigator.mozPower.cpuSleepAllowed = false;
    40     testDisableScreen();
    41     testEnableScreen();
    43     SimpleTest.finish();
    44   }
    46   SimpleTest.expectAssertions(0, 9);
    47   SimpleTest.waitForExplicitFinish();
    48   if (SpecialPowers.hasPermission("power", document)) {
    49     // Currently only applicable on FxOS
    50     if (navigator.userAgent.indexOf("Mobile") != -1 &&
    51         navigator.appVersion.indexOf("Android") == -1) {
    52       startTests();
    53     } else {
    54       ok(true, "mozPower on Firefox OS only.");
    55       SimpleTest.finish();
    56     }
    57   } else {
    58     // Add the permission and reload so it's propogated
    59     SpecialPowers.addPermission("power", true, document);
    60     window.location.reload();
    61   }
    62   </script>
    63 </pre>
    64 </body>
    65 </html>

mercurial