blob: 4f690f46297911ba4bd4fbb2dfd244292c8e0891 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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>
|