summaryrefslogtreecommitdiffstats
path: root/dom/notification/test/mochitest/test_notification_crossorigin_iframe.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/notification/test/mochitest/test_notification_crossorigin_iframe.html')
-rw-r--r--dom/notification/test/mochitest/test_notification_crossorigin_iframe.html68
1 files changed, 68 insertions, 0 deletions
diff --git a/dom/notification/test/mochitest/test_notification_crossorigin_iframe.html b/dom/notification/test/mochitest/test_notification_crossorigin_iframe.html
new file mode 100644
index 0000000000..dfdec3b1bd
--- /dev/null
+++ b/dom/notification/test/mochitest/test_notification_crossorigin_iframe.html
@@ -0,0 +1,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>