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.

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

mercurial