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 57 58 59 60 61 62 63 64 65
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test Enabling/Disabling Screen with Power Management API</title>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
  <script type="application/javascript">

  "use strict";

  function testEnableScreen() {
    try {
      navigator.mozPower.screenEnabled = true;
      ok(navigator.mozPower.screenEnabled === true, "Enabled screen.");
    } catch (e) {
      ok(false, "Unexpected exception trying to enable screen.");
    }
  }

  function testDisableScreen() {
    try {
      navigator.mozPower.screenEnabled = false;
      ok(navigator.mozPower.screenEnabled === false, "Disabled screen.");
    } catch (e) {
      ok(false, "Unexpected exception trying to disable screen.");
    }
  }

  function startTests() {

    // Make sure we don't suspend
    navigator.mozPower.cpuSleepAllowed = false;

    testDisableScreen();
    testEnableScreen();

    SimpleTest.finish();
  }

  SimpleTest.expectAssertions(0, 9);
  SimpleTest.waitForExplicitFinish();
  if (SpecialPowers.hasPermission("power", document)) {
    // Currently only applicable on FxOS
    if (navigator.userAgent.indexOf("Mobile") != -1 &&
        navigator.appVersion.indexOf("Android") == -1) {
      startTests();
    } else {
      ok(true, "mozPower on Firefox OS only.");
      SimpleTest.finish();
    }
  } else {
    // Add the permission and reload so it's propogated
    SpecialPowers.addPermission("power", true, document);
    window.location.reload();
  }
  </script>
</pre>
</body>
</html>