dom/power/test/test_power_basics.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   <title>Test for Power API</title>
     5   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     7 <script type="application/javascript">
     9 /** Test for Power API **/
    11 /** Test permission **/
    12 // In b2g, addPermission 'power' is only working after a document reload
    13 // See bug 802312
    15 SimpleTest.waitForExplicitFinish();
    17 function startTest() {
    18   SpecialPowers.pushPermissions([
    19     {type: "power", allow: true, context: window.frames[0].document}
    20   ], doTest1);
    21 }
    23 function doTest1() {
    24   window.frames[0].frameElement.setAttribute('onload', 'doTest2()');
    25   power = window.frames[0].navigator.mozPower;
    26   ok(power, "Should be able to access power manager with permission.");
    28   SpecialPowers.removePermission("power", window.frames[0].document);
    29   window.frames[0].location.reload();
    30 }
    32 function doTest2() {
    33   window.frames[0].frameElement.setAttribute('onload', 'doTest3()');
    34   power = window.frames[0].navigator.mozPower;
    35   ok(!power, "Shouldn't be able to access power manager with permission.");
    37   SpecialPowers.addPermission("power",true, window.frames[0].document);
    38   window.frames[0].location.reload();
    39 }
    41 function doTest3() {
    42   power = window.frames[0].navigator.mozPower;
    43   ok(power, "Should be able to access power manager with permission.");
    44   SimpleTest.finish();
    45 }
    46 </script>
    47 </head>
    48 <body>
    49 <p id="display"></p>
    50 <div id="content" style="display: none">
    51 </div>
    52 <iframe onload="startTest()"></iframe>
    53 <pre id="test">
    54 </pre>
    55 </body>
    56 </html>

mercurial