diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /dom/notification/test/mochitest/test_notification_crossorigin_iframe.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/notification/test/mochitest/test_notification_crossorigin_iframe.html')
-rw-r--r-- | dom/notification/test/mochitest/test_notification_crossorigin_iframe.html | 68 |
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> |