mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
102 lines
3.5 KiB
HTML
102 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id={770731}
|
|
-->
|
|
<head>
|
|
<title>Test for Bug {770731} Permissions</title>
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id={770731}">Mozilla Bug {674720}</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
"use strict";
|
|
|
|
var testPrivApp = {
|
|
'manifestURL' : 'https://aprivileged.com/manifest.webapp'
|
|
};
|
|
|
|
var testCertApp = {
|
|
'manifestURL' : 'https://acertified.com/manifest.webapp'
|
|
};
|
|
|
|
SpecialPowers.addPermission("permissions", true, document);
|
|
var comp = SpecialPowers.wrap(Components);
|
|
SpecialPowers.pushPrefEnv({ "set": [["dom.mozPermissionSettings.enabled", true]] },
|
|
function() {
|
|
SpecialPowers.removePermission("permissions", document);
|
|
});
|
|
|
|
comp.utils.import("resource://gre/modules/PermissionSettings.jsm");
|
|
var mozPermissions = window.navigator.mozPermissionSettings;
|
|
|
|
function permissionTest() {
|
|
// Any permission explicit for privileged and implicit for certified serves
|
|
var testPerm = "contacts-read";
|
|
|
|
// Simulate than the app request the permissions
|
|
SpecialPowers.addPermission(testPerm, true, testPrivApp);
|
|
SpecialPowers.addPermission(testPerm, true, testCertApp);
|
|
|
|
if (gPermissionssEnabled) {
|
|
var certAppManifest = testCertApp.manifestURL;
|
|
var privAppManifest = testPrivApp.manifestURL;
|
|
var originPriv = "https://aprivileged.com";
|
|
var originCert = "https://acertified.com";
|
|
|
|
// Trying to make any change to implicit permissions should fail
|
|
try {
|
|
mozPermissions.set(testPerm, "allow", certAppManifest, originCert, false);
|
|
ok(false, "Change implicit permission");
|
|
} catch (e) {
|
|
ok(true, "Change implicit permission");
|
|
}
|
|
|
|
var result=mozPermissions.get(testPerm, certAppManifest, originCert, false);
|
|
is(result, "allow", "same result");
|
|
|
|
// Erasing a permission, even an explicit one, is not allowed
|
|
try {
|
|
mozPermissions.set(testPerm, "unknown", privAppManifest, originPriv, false);
|
|
ok(false, "Erase explicit permission");
|
|
} catch (e) {
|
|
ok(true, "Erase explicit permission");
|
|
}
|
|
|
|
mozPermissions.set(testPerm, "allow", privAppManifest, originPriv, false);
|
|
result = mozPermissions.get(testPerm, privAppManifest, originPriv, false);
|
|
is(result, "allow", "Set to allow");
|
|
mozPermissions.set(testPerm, "deny", privAppManifest, originPriv, false);
|
|
result = mozPermissions.get(testPerm, privAppManifest, originPriv, false);
|
|
is(result, "deny", "Set to deny");
|
|
mozPermissions.set(testPerm, "prompt", privAppManifest, originPriv, false);
|
|
result = mozPermissions.get(testPerm, privAppManifest, originPriv, false);
|
|
is(result, "prompt", "Set to prompt");
|
|
SimpleTest.finish();
|
|
} else {
|
|
is(mozPermissions, null, "mozPermissionSettings is null when not enabled.");
|
|
SimpleTest.finish();
|
|
}
|
|
SpecialPowers.removePermission(testPerm, testPrivApp);
|
|
SpecialPowers.removePermission(testPerm, testCertApp);
|
|
}
|
|
|
|
var gPermissionssEnabled = SpecialPowers.getBoolPref("dom.mozPermissionSettings.enabled");
|
|
SimpleTest.waitForExplicitFinish();
|
|
addLoadEvent(permissionTest);
|
|
|
|
ok(true, "test passed");
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|