tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

battery-unplugging-manual.https.html (3579B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Battery Test: charger unplugging</title>
      4 <link rel="author" title="Intel" href="http://www.intel.com">
      5 <link rel="help" href="https://www.w3.org/TR/battery-status/">
      6 <meta name="flags" content="interact">
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <style>
     10  #note {
     11    background-color: #fef1b5;
     12    border: solid 1px #cdab2d;
     13    padding: 5px;
     14    margin: 15px;
     15    display: block;
     16  }
     17 </style>
     18 
     19 <h2>Description</h2>
     20 <p>
     21  This test validates that all of the BatteryManager attributes exist and
     22  are set to correct values, with corresponding events fired,
     23  when the charger is unplugged.
     24 </p>
     25 
     26 <h2>Preconditions</h2>
     27 <ol>
     28  <li>
     29    The device is plugged in to the charger before this test is run.
     30  </li>
     31 </ol>
     32 
     33 <div id="note">
     34  Unplug the charger and wait for all the tests to complete.
     35 </div>
     36 
     37 <div id="log"></div>
     38 
     39 <script>
     40 
     41 (function() {
     42 
     43  setup({ explicit_timeout: true });
     44 
     45  var onchargingchange_test = async_test(
     46      'When the device is unplugged in and its charging state is updated, ' +
     47      'must set the charging attribute\'s value to false and ' +
     48      'fire a chargingchange event.');
     49  var onchargingtimechange_test = async_test(
     50      'When the device is unplugged in and its charging time is updated, ' +
     51      'must set the chargingTime attribute\'s value to Infinity and ' +
     52      'fire a chargingtimechange event.');
     53  var ondischargingtimechange_test = async_test(
     54      'When the device is unplugged in and its discharging time is updated, ' +
     55      'must set the dischargingTime attribute\'s value and ' +
     56      'fire a dischargingtimechange event.');
     57  var onlevelchange_test = async_test(
     58      'When the device is unplugged in and the battery level is updated, ' +
     59      'must set the level attribute\'s value and fire a levelchange event.');
     60 
     61  var batterySuccess = function (battery) {
     62    battery.onchargingchange = onchargingchange_test.step_func(function () {
     63      assert_false(battery.charging, 'The charging attribute must be set to false.');
     64      onchargingchange_test.done();
     65    });
     66 
     67    battery.onchargingtimechange = onchargingtimechange_test.step_func(function () {
     68      assert_equals(battery.chargingTime, Infinity,
     69          'The value of the chargingTime attribute must be set to Infinity.');
     70      onchargingtimechange_test.done();
     71    });
     72 
     73    battery.ondischargingtimechange = ondischargingtimechange_test.step_func(function () {
     74      assert_less_than(battery.dischargingTime, Infinity,
     75          'The value of the dischargingTime attribute must be set to the remaining discharging time.');
     76      ondischargingtimechange_test.done();
     77    });
     78 
     79    battery.onlevelchange = onlevelchange_test.step_func(function () {
     80      assert_greater_than(battery.level, 0);
     81      assert_less_than_equal(battery.level, 1.0);
     82      onlevelchange_test.done();
     83    });
     84  };
     85 
     86  var batteryFailure = function (error) {
     87    onchargingchange_test.step(function () {
     88      assert_unreached(error.message);
     89     });
     90    onchargingchange_test.done();
     91 
     92    onchargingtimechange_test.step(function () {
     93      assert_unreached(error.message);
     94    });
     95    onchargingtimechange_test.done();
     96 
     97    ondischargingtimechange_test.step(function () {
     98      assert_unreached(error.message);
     99    });
    100    ondischargingtimechange_test.done();
    101 
    102    onlevelchange_test.step(function () {
    103      assert_unreached(error.message);
    104    });
    105    onlevelchange_test.done();
    106  };
    107 
    108  navigator.getBattery().then(batterySuccess, batteryFailure);
    109 
    110 })();
    111 
    112 </script>