summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/battery-status/battery-discharging-manual.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/battery-status/battery-discharging-manual.html')
-rw-r--r--testing/web-platform/tests/battery-status/battery-discharging-manual.html52
1 files changed, 52 insertions, 0 deletions
diff --git a/testing/web-platform/tests/battery-status/battery-discharging-manual.html b/testing/web-platform/tests/battery-status/battery-discharging-manual.html
new file mode 100644
index 000000000..c4ccbe445
--- /dev/null
+++ b/testing/web-platform/tests/battery-status/battery-discharging-manual.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Battery Test: battery neither empty or full, charger unplugged in</title>
+<meta name="flags" content="interact">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<h2>Description</h2>
+<p>
+ This test validates that all of the BatteryManager attributes exist and are set to their correct values when battery is discharging.
+</p>
+
+<h2>Preconditions</h2>
+<ol>
+ <li>
+ The device is unplugged from the charger before this test is run.
+ </li>
+ <li>
+ The battery must neither be empty or full, nor reach empty or full capacity during the test.
+ </li>
+ <li>
+ Waiting for battery level change to fire levelchange event, maybe need a long time
+ </li>
+</ol>
+
+<script>
+
+setup({ explicit_timeout: true });
+
+async_test(function (t) {
+ navigator.getBattery().then(function (battery) {
+ t.step(function () {
+ assert_false(battery.charging, 'charging must be set to false');
+ assert_equals(battery.chargingTime, Infinity, 'chargingTime 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_less_than(battery.level, battery_level, 'The value of the level attribute must decrease');
+ t.done();
+ });
+ });
+ }, function (error) {
+ t.step(function () {
+ assert_unreached(error.message);
+ });
+ t.done();
+ });
+}, document.title);
+
+</script>