Back out bc8eeacc3c8a (bug 843893) for (at least) desktop bustage in test_power_basics.html

This commit is contained in:
Phil Ringnalda 2013-03-19 14:27:55 -07:00
parent af416ef4e2
commit 8f82505fcd
4 changed files with 46 additions and 76 deletions

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>Test Non-Permitted Application for Alarm 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>
@ -12,37 +13,21 @@
"use strict";
function alarmtests() {
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.mozAlarms.enabled", true]]}, function() {
// mozAlarms is intalled on all platforms except Android for the moment.
if (navigator.appVersion.indexOf("Android") != -1) {
ok(!('mozAlarms' in navigator), "navigator.mozAlarms should not exist");
} else {
ok('mozAlarms' in navigator, "navigator.mozAlarms should exist");
is(navigator.mozAlarms, null, "navigator.mozAlarms should return null");
}
SpecialPowers.addPermission("alarms", true, document);
SimpleTest.finish();
});
}
if(!SpecialPowers.hasPermission("alarms", document)) {
var head = document.getElementsByTagName('head')[0];
var js = document.createElement("script");
js.type = "application/javascript";
js.src = "/tests/SimpleTest/SimpleTest.js";
js.onload = alarmtests;
head.appendChild(js);
} else {
SpecialPowers.pushPrefEnv({"set": [["dom.mozAlarms.enabled", true]]}, function() {
SpecialPowers.removePermission("alarms", document);
window.location = window.location;
}
// mozAlarms is intalled on all platforms except Android for the moment.
if (navigator.appVersion.indexOf("Android") != -1) {
ok(!('mozAlarms' in navigator), "navigator.mozAlarms should not exist");
} else {
ok('mozAlarms' in navigator, "navigator.mozAlarms should exist");
is(navigator.mozAlarms, null, "navigator.mozAlarms should return null");
}
SimpleTest.finish();
});
</script>
</pre>

View File

@ -13,7 +13,6 @@ include $(DEPTH)/config/autoconf.mk
MOCHITEST_FILES = \
test_power_basics.html \
test_power_non_permitted_app.html \
$(NULL)
MOCHITEST_BROWSER_FILES = \

View File

@ -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,11 +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
power = navigator.mozPower;
ok(power, "Should be able to access power manager with permission.");
SimpleTest.waitForExplicitFinish();
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, window.frames[0].document);
window.frames[0].location.reload();
}
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>

View File

@ -1,39 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Power API</title>
<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 **/
function powertests() {
SimpleTest.waitForExplicitFinish();
power = navigator.mozPower;
ok(!power, "Shouldn't be able to access power manager without permission.");
SimpleTest.finish();
}
if(!SpecialPowers.hasPermission("power", document)) {
var head = document.getElementsByTagName('head')[0];
var js = document.createElement("script");
js.type = "application/javascript";
js.src = "/tests/SimpleTest/SimpleTest.js";
js.onload = powertests;
head.appendChild(js);
} else {
SpecialPowers.removePermission("power", document);
window.location = window.location;
}
</script>
</pre>
</body>
</html>