Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Errors

<!DOCTYPE HTML>
<html>
<!--
Tests that Notification permissions are denied in cross-origin iframes.
-->
<head>
<title>Notification permission in cross-origin iframes</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="GleanTest.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 kBlankPath = "/tests/dom/notification/test/mochitest/blank.html"
const kParentURL = "https://example.org" + kBlankPath;
const kChildURL = "https://example.com" + kBlankPath;
(async function runTest() {
let iframe = document.createElement("iframe");
iframe.src = kParentURL;
document.body.appendChild(iframe);
await new Promise(resolve => {
iframe.onload = resolve;
});
await SpecialPowers.spawn(iframe, [kChildURL], async (childURL) => {
const nested = this.content.document.createElement("iframe");
nested.src = childURL;
this.content.document.body.appendChild(nested);
await new Promise(resolve => {
nested.onload = resolve;
});
});
await GleanTest.testResetFOG();
await SpecialPowers.spawn(iframe, [], async () => {
const nested = this.content.document.querySelector("iframe");
await SpecialPowers.spawn(nested, [], async () => {
await this.content.Notification.requestPermission();
});
});
const requestCount = await GleanTest.webNotification.requestPermissionOrigin.nested_first_party.testGetValue();
is(requestCount, 1, "Notification nested first party request permission counter should increment once.");
await SpecialPowers.spawn(iframe, [], async () => {
const nested = this.content.document.querySelector("iframe");
await SpecialPowers.spawn(nested, [], async () => {
this.content.Notification.permission;
});
});
const permissionCount = await GleanTest.webNotification.permissionOrigin.nested_first_party.testGetValue();
is(permissionCount, 1, "Notification nested first party permission read counter should increment once.");
await SpecialPowers.spawn(iframe, [], async () => {
const nested = this.content.document.querySelector("iframe");
await SpecialPowers.spawn(nested, [], async () => {
new this.content.Notification("cross origin");
});
});
const showCount = await GleanTest.webNotification.showOrigin.nested_first_party.testGetValue();
is(showCount, 1, "Notification nested first party show attempt counter should increment once.");
SimpleTest.finish();
})();
</script>
</pre>
</body>
</html>