<!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>