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-promise-iframe.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-promise-iframe.html')
-rw-r--r-- | testing/web-platform/tests/battery-status/battery-promise-iframe.html | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/testing/web-platform/tests/battery-status/battery-promise-iframe.html b/testing/web-platform/tests/battery-status/battery-promise-iframe.html new file mode 100644 index 000000000..6add86106 --- /dev/null +++ b/testing/web-platform/tests/battery-status/battery-promise-iframe.html @@ -0,0 +1,80 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Battery Test: iframe has a different Navigator object</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + iframe { + display: none; + } +</style> +<div id="log"></div> +<iframe id="blank" src="about:blank"></iframe> +<iframe id="frame"></iframe> +<script> +promise_test(function(t) { + var iframe = document.querySelector('#blank'); + var originalPromise = navigator.getBattery(); + + return originalPromise.then(function(originalManager) { + var promise = iframe.contentWindow.navigator.getBattery(); + + assert_true(originalManager instanceof BatteryManager); + assert_not_equals(iframe.contentWindow.navigator, + navigator, + 'navigator objects shall be different'); + assert_not_equals(promise, + originalPromise, + 'battery promises in different navigators shall be different'); + assert_equals(iframe.contentWindow.navigator.getBattery(), + promise, + 'battery promises in same navigator shall be same'); + + return promise; + }).then(function(manager) { + assert_equals(manager.__proto__, + iframe.contentWindow.BatteryManager.prototype); + assert_true(manager instanceof iframe.contentWindow.BatteryManager); + }); + +}, 'iframe has a different Navigator object thus getting another battery promise'); + +async_test(function (t) { + var iframe = document.querySelector('#blank'); + var originalNavigator = iframe.contentWindow.navigator; + var originalPromise = iframe.contentWindow.navigator.getBattery(); + + iframe.onload = t.step_func(function() { + assert_equals(iframe.contentWindow.navigator, + originalNavigator, + 'navigator objects shall be same'); + assert_equals(iframe.contentWindow.navigator.getBattery(), + originalPromise, + 'battery status promises shall be same'); + t.done(); + }); + + iframe.src = 'support-iframe.html'; +}, 'setting src of an iframe with initial about:blank makes same Navigator object and battery promise'); + +async_test(function (t) { + var iframe = document.querySelector('#frame'); + iframe.src = 'support-iframe-initial.html'; + iframe.onload = t.step_func(function() { + var originalNavigator = iframe.contentWindow.navigator; + var originalPromise = iframe.contentWindow.navigator.getBattery(); + + iframe.onload = t.step_func(function() { + assert_not_equals(iframe.contentWindow.navigator, + originalNavigator, + 'navigator objects shall be changed'); + assert_not_equals(iframe.contentWindow.navigator.getBattery(), + originalPromise, + 'battery status promises shall be different'); + t.done(); + }); + + iframe.src = 'support-iframe.html'; + }); +}, 'setting src of an iframe with initial frame makes its Navigator object vary thus getting another battery promise'); +</script> |