Bug 783500 - Tests for IdleAPI permissions. r=mounir

This commit is contained in:
Steven Lee 2012-10-09 09:32:43 +01:00
Родитель c8e9ba64cc
Коммит 95d337696a
2 изменённых файлов: 48 добавлений и 0 удалений

Просмотреть файл

@ -46,6 +46,7 @@ MOCHITEST_FILES = \
file_moving_nodeList.html \ file_moving_nodeList.html \
test_performance_now.html \ test_performance_now.html \
test_interfaces.html \ test_interfaces.html \
test_idleapi_permissions.html \
$(NULL) $(NULL)
# Disable this test until bug 795711 is fixed. # Disable this test until bug 795711 is fixed.

Просмотреть файл

@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for idle api permissions</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/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 run_test() {
// addIdleObserver checks whether time is > 0.
this.idleObserver.time = 100;
var added = false;
try {
navigator.addIdleObserver(this.idleObserver);
added = true;
} catch (e) { }
ok(!added, "Should not be able to add idle observer without permission");
SpecialPowers.addPermission("idle", true, document);
added = false;
try {
navigator.addIdleObserver(this.idleObserver);
added = true;
} catch (e) { }
ok(added, "Should be able to add idle observer with permission.");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(run_test);
</script>
</pre>
</body>
</html>