DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (dcc6d7a0dc00)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for Power API</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">

/** Test for Power API **/

/** Test permission **/
// In b2g, addPermission 'power' is only working after a document reload
// See bug 802312

SimpleTest.waitForExplicitFinish();

function startTest() {
  SpecialPowers.pushPermissions([
    {type: "power", allow: true, context: window.frames[0].document}
  ], doTest1);
}

function doTest1() {
  window.frames[0].frameElement.setAttribute('onload', 'doTest2()');
  power = window.frames[0].navigator.mozPower;
  ok(power, "Should be able to access power manager with permission.");

  SpecialPowers.removePermission("power", window.frames[0].document);
  window.frames[0].location.reload();
}

function doTest2() {
  window.frames[0].frameElement.setAttribute('onload', 'doTest3()');
  power = window.frames[0].navigator.mozPower;
  ok(!power, "Shouldn't be able to access power manager with permission.");

  SpecialPowers.addPermission("power",true, window.frames[0].document);
  window.frames[0].location.reload();
}

function doTest3() {
  power = window.frames[0].navigator.mozPower;
  ok(power, "Should be able to access power manager with permission.");
  SimpleTest.finish();
}
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<iframe onload="startTest()"></iframe>
<pre id="test">
</pre>
</body>
</html>