diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/battery-status/battery-unplugging-manual.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/battery-status/battery-unplugging-manual.html')
-rw-r--r-- | testing/web-platform/tests/battery-status/battery-unplugging-manual.html | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/testing/web-platform/tests/battery-status/battery-unplugging-manual.html b/testing/web-platform/tests/battery-status/battery-unplugging-manual.html new file mode 100644 index 000000000..bb576da2b --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-unplugging-manual.html @@ -0,0 +1,110 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Battery Test: charger unplugging</title> +<meta name="flags" content="interact"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + #note { + background-color: #fef1b5; + border: solid 1px #cdab2d; + padding: 5px; + margin: 15px; + display: block; + } +</style> + +<h2>Description</h2> +<p> + This test validates that all of the BatteryManager attributes exist and + are set to correct values, with corresponding events fired, + when the charger is unplugged. +</p> + +<h2>Preconditions</h2> +<ol> + <li> + The device is plugged in to the charger before this test is run. + </li> +</ol> + +<div id="note"> + Unplug the charger and wait for all the tests to complete. +</div> + +<div id="log"></div> + +<script> + +(function() { + + setup({ explicit_timeout: true }); + + var onchargingchange_test = async_test( + 'When the device is unplugged in and its charging state is updated, ' + + 'must set the charging attribute\'s value to false and ' + + 'fire a chargingchange event.'); + var onchargingtimechange_test = async_test( + 'When the device is unplugged in and its charging time is updated, ' + + 'must set the chargingTime attribute\'s value to Infinity and ' + + 'fire a chargingtimechange event.'); + var ondischargingtimechange_test = async_test( + 'When the device is unplugged in and its discharging time is updated, ' + + 'must set the dischargingTime attribute\'s value and ' + + 'fire a dischargingtimechange event.'); + var onlevelchange_test = async_test( + 'When the device is unplugged in and the battery level is updated, ' + + 'must set the level attribute\'s value and fire a levelchange event.'); + + var batterySuccess = function (battery) { + battery.onchargingchange = onchargingchange_test.step_func(function () { + assert_false(battery.charging, 'The charging attribute must be set to false.'); + onchargingchange_test.done(); + }); + + battery.onchargingtimechange = onchargingtimechange_test.step_func(function () { + assert_equals(battery.chargingTime, Infinity, + 'The value of the chargingTime attribute must be set to Infinity.'); + onchargingtimechange_test.done(); + }); + + battery.ondischargingtimechange = ondischargingtimechange_test.step_func(function () { + assert_less_than(battery.dischargingTime, Infinity, + 'The value of the dischargingTime attribute must be set to the remaining discharging time.'); + ondischargingtimechange_test.done(); + }); + + battery.onlevelchange = onlevelchange_test.step_func(function () { + assert_greater_than(battery.level, 0); + assert_less_than_equal(battery.level, 1.0); + onlevelchange_test.done(); + }); + }; + + var batteryFailure = function (error) { + onchargingchange_test.step(function () { + assert_unreached(error.message); + }); + onchargingchange_test.done(); + + onchargingtimechange_test.step(function () { + assert_unreached(error.message); + }); + onchargingtimechange_test.done(); + + ondischargingtimechange_test.step(function () { + assert_unreached(error.message); + }); + ondischargingtimechange_test.done(); + + onlevelchange_test.step(function () { + assert_unreached(error.message); + }); + onlevelchange_test.done(); + }; + + navigator.getBattery().then(batterySuccess, batteryFailure); + +})(); + +</script> |