mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1235050 - Add basic SimplePush testing. r=kitcambridge
This commit is contained in:
parent
6ab3d8f9ca
commit
1e750d0b2d
@ -12,3 +12,7 @@ EXTRA_COMPONENTS += [
|
||||
EXTRA_JS_MODULES += [
|
||||
'PushService.jsm',
|
||||
]
|
||||
|
||||
MOCHITEST_MANIFESTS += [
|
||||
'test/mochitest.ini',
|
||||
]
|
||||
|
6
dom/simplepush/test/mochitest.ini
Normal file
6
dom/simplepush/test/mochitest.ini
Normal file
@ -0,0 +1,6 @@
|
||||
[DEFAULT]
|
||||
run-if = toolkit == "gonk"
|
||||
|
||||
[test_permissions.html]
|
||||
[test_register.html]
|
||||
[test_prefs.html]
|
60
dom/simplepush/test/test_permissions.html
Normal file
60
dom/simplepush/test/test_permissions.html
Normal file
@ -0,0 +1,60 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Bug 1235050: SimplePush permissions tests.
|
||||
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1235050</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
|
||||
</head>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1235050">Mozilla Bug 1235050</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
|
||||
function already_has_permission() {
|
||||
return SpecialPowers.hasPermission("push", document);
|
||||
}
|
||||
|
||||
function add_permission() {
|
||||
var allow = SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION;
|
||||
SpecialPowers.addPermission("push", allow, document);
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
function test_no_permission() {
|
||||
ok((!("push" in navigator)), "push object is NOT exposed");
|
||||
}
|
||||
|
||||
function test_has_permission() {
|
||||
ok(("push" in navigator), "push object is exposed");
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
if (already_has_permission()) {
|
||||
test_has_permission();
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
test_no_permission();
|
||||
add_permission();
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
63
dom/simplepush/test/test_prefs.html
Normal file
63
dom/simplepush/test/test_prefs.html
Normal file
@ -0,0 +1,63 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Bug 1235050: SimplePush basics tests.
|
||||
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1235050</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
|
||||
</head>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1235050">Mozilla Bug 1235050</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
function test_navigator() {
|
||||
ok(("push" in navigator), "push object is exposed");
|
||||
}
|
||||
|
||||
function test_register(expected, next) {
|
||||
var pushReq = navigator.push.register();
|
||||
pushReq.onsuccess = e => {
|
||||
ok(expected, "push.register() triggered onsuccess");
|
||||
next();
|
||||
};
|
||||
pushReq.onerror = e => {
|
||||
ok(!expected, "push.register() triggered onerror");
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
test_navigator();
|
||||
test_register(false, () => {
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["services.push.connection.enabled", true],
|
||||
]}, () => {
|
||||
test_register(true, () => {
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.addPermission("push", true, document);
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["services.push.connection.enabled", false],
|
||||
]}, runTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
57
dom/simplepush/test/test_register.html
Normal file
57
dom/simplepush/test/test_register.html
Normal file
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Bug 1235050: SimplePush basics tests.
|
||||
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1235050</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
|
||||
</head>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1235050">Mozilla Bug 1235050</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
function test_navigator() {
|
||||
ok(("push" in navigator), "push object is exposed");
|
||||
ok(("register" in navigator.push), "push object is exposed with register");
|
||||
ok(("unregister" in navigator.push), "push object is exposed with unregister");
|
||||
}
|
||||
|
||||
function test_register(next) {
|
||||
var pushReq = navigator.push.register();
|
||||
pushReq.onsuccess = e => {
|
||||
ok(true, "push.register() triggered onsuccess");
|
||||
next();
|
||||
};
|
||||
pushReq.onerror = e => {
|
||||
ok(false, "push.register() triggered onerror");
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
test_navigator();
|
||||
test_register(() => {
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.addPermission("push", true, document);
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user