Sat, 03 Jan 2015 20:18:00 +0100
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 Setting Screen Brightness 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 // Test setting brightness to a value < 0
18 function testInvalidBrightness1() {
19 try {
20 navigator.mozPower.screenBrightness = -1;
21 } catch (e) {
22 return ok(true, "Invalid brightness level results in exception.");
23 }
24 ok(false, "Exeception not thrown for invalid brightness level.");
25 }
27 // Test setting brightness to a value > 1
28 function testInvalidBrightness2() {
29 try {
30 navigator.mozPower.screenBrightness = 2;
31 } catch (e) {
32 return ok(true, "Invalid brightness level results in exception.");
33 }
34 ok(false, "Exeception not thrown for invalid brightness level.");
35 }
37 function testSettingBrightness() {
38 var newBright = 0.312;
39 navigator.mozPower.screenBrightness = newBright;
40 ok(fuzzyEq(newBright, navigator.mozPower.screenBrightness),
41 "Set new brightness value.");
42 }
44 function startTests() {
45 testInvalidBrightness1();
46 testInvalidBrightness2();
47 testSettingBrightness();
49 SimpleTest.finish();
50 }
52 function fuzzyEq(a, b) {
53 var epsilon = 0.002;
54 return Math.abs(a - b) < epsilon;
55 }
57 SimpleTest.expectAssertions(0, 9);
58 SimpleTest.waitForExplicitFinish();
59 if (SpecialPowers.hasPermission("power", document)) {
60 // Currently only applicable on FxOS
61 if (navigator.userAgent.indexOf("Mobile") != -1 &&
62 navigator.appVersion.indexOf("Android") == -1) {
63 startTests();
64 } else {
65 ok(true, "mozPower on Firefox OS only.");
66 SimpleTest.finish();
67 }
68 } else {
69 // Add the permission and reload so it's propogated
70 SpecialPowers.addPermission("power", true, document);
71 window.location.reload();
72 }
73 </script>
74 </pre>
75 </body>
76 </html>