summaryrefslogtreecommitdiffstats
path: root/caps/tests/mochitest/test_bug995943.xhtml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /caps/tests/mochitest/test_bug995943.xhtml
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'caps/tests/mochitest/test_bug995943.xhtml')
-rw-r--r--caps/tests/mochitest/test_bug995943.xhtml111
1 files changed, 111 insertions, 0 deletions
diff --git a/caps/tests/mochitest/test_bug995943.xhtml b/caps/tests/mochitest/test_bug995943.xhtml
new file mode 100644
index 0000000000..0ba95f548d
--- /dev/null
+++ b/caps/tests/mochitest/test_bug995943.xhtml
@@ -0,0 +1,111 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=995943
+-->
+<window title="Mozilla Bug 995943"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=995943"
+ target="_blank">Mozilla Bug 995943</a>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+ function debug(msg) { info(msg); }
+
+ /** Test for CAPS file:// URI prefs. */
+ SimpleTest.waitForExplicitFinish();
+ SimpleTest.requestCompleteLog();
+ if (navigator.userAgent.includes("Mac OS X 10.10"))
+ SimpleTest.expectAssertions(5, 11); // See bug 1067022, 1307988
+ else if (Services.appinfo.OS == "WINNT")
+ SimpleTest.expectAssertions(0, 1); // See bug 1067022
+ else
+ SimpleTest.expectAssertions(0, 9); // See bug 1305241, 1145314
+
+ var rootdir = Services.appinfo.OS == "WINNT" ? "file:///C:" : "file:///";
+
+ function checkLoadFileURI(domain, shouldLoad) {
+ debug("Invoking checkLoadFileURI with domain: " + domain + ", shouldLoad: " + shouldLoad);
+ return new Promise(function(resolve, reject) {
+ $('ifr').addEventListener('load', function l1() {
+ debug("Invoked l1 for " + domain);
+ $('ifr').removeEventListener('load', l1);
+ function l2() {
+ debug("Invoked l2 for " + domain);
+ $('ifr').removeEventListener('load', l2);
+ ok(shouldLoad, "Successfully loaded file:// URI for domain: " + domain);
+ resolve();
+ }
+ $('ifr').addEventListener('load', l2);
+ try {
+ window[0].wrappedJSObject.location = rootdir;
+ debug("Successfully navigated for " + domain);
+ } catch (e) {
+ ok(!shouldLoad && /denied|insecure/.test(e),
+ "Prevented loading of file:// URI for domain: " + domain + " - " + e);
+ $('ifr').removeEventListener('load', l2);
+ resolve();
+ }
+ });
+ let targetURI = domain + '/tests/js/xpconnect/tests/mochitest/file_empty.html';
+ debug("Navigating iframe to " + targetURI);
+ $('ifr').contentWindow.location = targetURI;
+ });
+ }
+
+ function pushPrefs(prefs) {
+ return SpecialPowers.pushPrefEnv({ set: prefs });
+ }
+
+ function popPrefs() {
+ return new Promise(function(resolve) { SpecialPowers.popPrefEnv(resolve); });
+ }
+
+ var gGoCount = 0;
+ function go() {
+ debug("Invoking go for window with id: " + window.windowGlobalChild.innerWindowId);
+ is(++gGoCount, 1, "Should only call go once!");
+ checkLoadFileURI('http://example.com', false).then(
+ pushPrefs.bind(null, [['capability.policy.policynames', ' somepolicy '],
+ ['capability.policy.somepolicy.checkloaduri.enabled', 'AlLAcCeSs'],
+ ['capability.policy.somepolicy.sites', 'http://example.com']]))
+ .then(checkLoadFileURI.bind(null, 'http://example.com', true))
+ .then(popPrefs)
+ .then(checkLoadFileURI.bind(null, 'http://example.com', false))
+ .then(
+ pushPrefs.bind(null, [['capability.policy.policynames', ',somepolicy, someotherpolicy, '],
+ ['capability.policy.somepolicy.checkloaduri.enabled', 'allaccess'],
+ ['capability.policy.someotherpolicy.checkloaduri.enabled', 'nope'],
+ ['capability.policy.somepolicy.sites', ' http://example.org test1.example.com https://test2.example.com '],
+ ['capability.policy.someotherpolicy.sites', 'http://example.net ']]))
+ .then(checkLoadFileURI.bind(null, 'http://example.org', true))
+ .then(checkLoadFileURI.bind(null, 'http://test2.example.com', false))
+ .then(checkLoadFileURI.bind(null, 'https://test2.example.com', true))
+ .then(checkLoadFileURI.bind(null, 'http://sub1.test2.example.com', false))
+ .then(checkLoadFileURI.bind(null, 'https://sub1.test2.example.com', true))
+ .then(checkLoadFileURI.bind(null, 'http://example.net', false))
+ .then(checkLoadFileURI.bind(null, 'http://test1.example.com', true))
+ .then(checkLoadFileURI.bind(null, 'https://test1.example.com', true))
+ .then(checkLoadFileURI.bind(null, 'http://sub1.test1.example.com', true))
+ .then(checkLoadFileURI.bind(null, 'https://sub1.test1.example.com', true))
+ .then(pushPrefs.bind(null, [['capability.policy.someotherpolicy.checkloaduri.enabled', 'allAccess']]))
+ .then(checkLoadFileURI.bind(null, 'http://example.net', true))
+ .then(popPrefs)
+ .then(popPrefs)
+ .then(checkLoadFileURI.bind(null, 'http://example.net', false))
+ .then(SimpleTest.finish.bind(SimpleTest));
+
+ }
+ addLoadEvent(go);
+
+ ]]>
+ </script>
+ <iframe id="ifr" type="content" />
+</window>