author James Graham <james@hoppipolla.co.uk>
Mon, 18 Jan 2016 12:54:03 +0000
changeset 281258 7d68d3d864e5a2f63c508bfab2b2ffcbcecb42b6
parent 235060 f8de9b743d15a6a50f54230fe3b2e0a475abcadb
permissions -rw-r--r--
Bug 1241948 - Update web-platform-tests to revision 967dfa72eaa149af854c6c38cb64e28b4961a480, a=testonly

<!DOCTYPE html>
<meta charset="utf-8">
<title>Battery Test: battery neither empty or full, charger plugged in</title>
<meta name="flags" content="interact">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

  This test validates that all of the BatteryManager attributes exist and are set to their correct values when battery is charging.

    The device is plugged in to the charger before this test is run.
    The battery must neither be empty or full, nor reach empty or full capacity during the test.
    Waiting for battery level change to fire levelchange event, maybe need a long time


setup({ explicit_timeout: true });

async_test(function (t) {
  navigator.getBattery().then(function (battery) {
    t.step(function () {
      assert_true(battery.charging, 'charging must be set to true');
      assert_equals(battery.dischargingTime, Infinity, 'dischargingTime must be set to Infinity');
      assert_greater_than(battery.level, 0, 'level must be greater than 0');
      assert_less_than_equal(battery.level, 1.0, 'level must be less than or equal to 1.0');

      var battery_level = battery.level;
      battery.onlevelchange = t.step_func(function () {
        assert_greater_than(battery.level, battery_level, 'The value of the level attribute must increase');
  }, function (error) {
    t.step(function () {
}, document.title);