1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<!DOCTYPE HTML>
<html>
<!--
Tests that Notification permissions are denied in cross-origin iframes.
https://bugzilla.mozilla.org/show_bug.cgi?id=1560741
-->
<head>
<title>Notification permission in cross-origin iframes</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();
const kBlankURL = "https://example.com/tests/dom/notification/test/mochitest/blank.html";
(async function runTest() {
await SpecialPowers.pushPrefEnv({"set": [
["notification.prompt.testing", true],
["notification.prompt.testing.allow", true],
["dom.webnotifications.allowinsecure", true],
]});
let iframe = document.createElement("iframe");
iframe.src = kBlankURL;
document.body.appendChild(iframe);
await new Promise(resolve => {
iframe.onload = resolve;
});
let checkRequest = async (expectedResponse, msg) => {
let response = await this.content.Notification.requestPermission();
Assert.equal(response, expectedResponse, msg);
};
await SpecialPowers.spawn(iframe,
["denied", "Denied permission in cross-origin iframe"],
checkRequest);
let checkPermission = async (expectedPermission, msg) => {
let permission = this.content.Notification.permission;
Assert.equal(permission, expectedPermission, msg);
};
await SpecialPowers.spawn(iframe,
["denied", "Permission is denied in cross-origin iframe"],
checkPermission);
await SpecialPowers.pushPrefEnv({"set": [["dom.webnotifications.allowcrossoriginiframe", true]]});
await SpecialPowers.spawn(iframe,
["granted", "Granted permission in cross-origin iframe with pref set"],
checkRequest);
await SpecialPowers.spawn(iframe,
["granted", "Permission is granted in cross-origin iframe with pref set"],
checkPermission);
SimpleTest.finish();
})();
</script>
</pre>
</body>
</html>
|