Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE HTML>
<html>
<!--
Tests that Notification permissions are denied in insecure context.
-->
<head>
<title>Notification permission in insecure context</title>
<script 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 class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
// Add an allow permission for the mochitest origin to test this.
let script = SpecialPowers.loadChromeScript(function() {
/* eslint-env mozilla/chrome-script */
let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin("http://mochi.test:8888");
Services.perms.addFromPrincipal(principal, "desktop-notification", Services.perms.ALLOW_ACTION);
addMessageListener("destroy", function() {
Services.perms.removeFromPrincipal(principal, "desktop-notification");
});
});
(async function runTest() {
let response = await Notification.requestPermission();
is(response, "denied", "Denied permission in insecure context");
script.sendAsyncMessage("destroy");
script.destroy();
SimpleTest.finish();
})();
</script>
</pre>
</body>
</html>