Bug 802312 - test_power_basics.html is failing on b2g mochitest, r=kchen

This commit is contained in:
Martijn Wargers 2012-10-21 05:19:00 -07:00
Родитель 05be6d2bcf
Коммит 72e9c813de
1 изменённых файлов: 30 добавлений и 12 удалений

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

@ -4,12 +4,6 @@
<title>Test for Power API</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">
/** Test for Power API **/
@ -17,18 +11,42 @@
ok('mozPower' in navigator, "navigator.mozPower should exist");
/** Test permission **/
// In b2g, addPermission 'power' is only working after a document reload
// See bug 802312
SpecialPowers.removePermission("power", document);
SimpleTest.waitForExplicitFinish();
power = navigator.mozPower;
ok(!power, "Shouldn't be able to access power manager without permission.");
function startTest() {
window.frames[0].frameElement.setAttribute('onload', 'doTest2()');
power = window.frames[0].navigator.mozPower;
ok(!power, "Shouldn't be able to access power manager without permission.");
SpecialPowers.addPermission("power", true, document);
SpecialPowers.addPermission("power", true, window.frames[0].document);
window.frames[0].location.reload();
}
power = navigator.mozPower;
ok(power, "Shouldn be able to access power manager with permission.");
function doTest2() {
window.frames[0].frameElement.setAttribute('onload', 'doTest3()');
power = window.frames[0].navigator.mozPower;
ok(power, "Should be able to access power manager with permission.");
SpecialPowers.removePermission("power", window.frames[0].document);
window.frames[0].location.reload();
}
function doTest3() {
power = window.frames[0].navigator.mozPower;
ok(!power, "Shouldn't be able to access power manager without permission.");
SimpleTest.finish();
}
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<iframe onload="startTest()"></iframe>
<pre id="test">
</pre>
</body>
</html>