Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android' OR (verify && debug && (os == 'mac'))
- Manifest: caps/tests/mochitest/chrome.toml
<?xml version="1.0"?>
<!--
-->
<!-- test results are displayed in the html:body -->
</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"))
else if (Services.appinfo.OS == "WINNT")
else
function checkLoadFileURI(domain, shouldLoad) {
debug("Invoking checkLoadFileURI with domain: " + domain + ", shouldLoad: " + shouldLoad);
return new Promise(function(resolve) {
$('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!");
pushPrefs.bind(null, [['capability.policy.policynames', ' somepolicy '],
['capability.policy.somepolicy.checkloaduri.enabled', 'AlLAcCeSs'],
.then(popPrefs)
.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 '],
.then(pushPrefs.bind(null, [['capability.policy.someotherpolicy.checkloaduri.enabled', 'allAccess']]))
.then(popPrefs)
.then(popPrefs)
.then(SimpleTest.finish.bind(SimpleTest));
}
addLoadEvent(go);
]]>
</script>
<iframe id="ifr" type="content" />
</window>