diff options
Diffstat (limited to 'dom/tests/mochitest/general/test_idleapi_permissions.html')
-rw-r--r-- | dom/tests/mochitest/general/test_idleapi_permissions.html | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/dom/tests/mochitest/general/test_idleapi_permissions.html b/dom/tests/mochitest/general/test_idleapi_permissions.html new file mode 100644 index 000000000..4f690f462 --- /dev/null +++ b/dom/tests/mochitest/general/test_idleapi_permissions.html @@ -0,0 +1,48 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test for idle api permissions</title> + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> +</head> +<body> +<p id="display"></p> +<div id="content" style="display: none"> +</div> +<pre id="test"> +<script type="application/javascript"> + +var idleObserver = { + onidle: null, + onactive: null +}; + +function doAddIdleObserver(obs) { + var i = document.createElement("iframe"); + document.body.appendChild(i); + var added = false; + try { + i.contentWindow.navigator.addIdleObserver(obs); + added = true; + } catch (e) { } + i.remove(); + return added; +} + +function run_test() { + // addIdleObserver checks whether time is > 0. + this.idleObserver.time = 100; + + SpecialPowers.pushPermissions([{type: "idle", allow: true, context: document}], () => { + added = doAddIdleObserver(this.idleObserver, true); + ok(added, "Should be able to add idle observer with permission."); + SimpleTest.finish(); + }); +} + +SimpleTest.waitForExplicitFinish(); +addLoadEvent(run_test); +</script> +</pre> +</body> +</html> |