mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-02 07:05:24 +00:00
64 lines
1.6 KiB
HTML
64 lines
1.6 KiB
HTML
<!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>
|