mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1170200 - Part 2: Update JavaScript consumers of nsIPermissionManager::Remove; r=ehsan (aa1cbab01)
This commit is contained in:
@@ -857,7 +857,7 @@ function onBlockImage()
|
||||
if (checkbox.checked)
|
||||
permissionManager.add(uri, "image", nsIPermissionManager.DENY_ACTION);
|
||||
else
|
||||
permissionManager.remove(uri.host, "image");
|
||||
permissionManager.remove(uri, "image");
|
||||
}
|
||||
|
||||
function onImageSelect()
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
let gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
|
||||
let gPageInfo = null;
|
||||
let gNextTest = null;
|
||||
let gTestBrowser = null;
|
||||
let gPluginHost = Components.classes["@mozilla.org/plugin/host;1"]
|
||||
.getService(Components.interfaces.nsIPluginHost);
|
||||
let gPermissionManager = Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Components.interfaces.nsIPermissionManager);
|
||||
let gTestPermissionString = gPluginHost.getPermissionStringForType("application/x-test");
|
||||
let gSecondTestPermissionString = gPluginHost.getPermissionStringForType("application/x-second-test");
|
||||
|
||||
function doOnPageLoad(url, continuation) {
|
||||
gNextTest = continuation;
|
||||
gTestBrowser.addEventListener("load", pageLoad, true);
|
||||
gTestBrowser.contentWindow.location = url;
|
||||
}
|
||||
|
||||
function pageLoad() {
|
||||
gTestBrowser.removeEventListener("load", pageLoad);
|
||||
// The plugin events are async dispatched and can come after the load event
|
||||
// This just allows the events to fire before we then go on to test the states
|
||||
executeSoon(gNextTest);
|
||||
}
|
||||
|
||||
function doOnOpenPageInfo(continuation) {
|
||||
Services.obs.addObserver(pageInfoObserve, "page-info-dialog-loaded", false);
|
||||
gNextTest = continuation;
|
||||
// An explanation: it looks like the test harness complains about leaked
|
||||
// windows if we don't keep a reference to every window we've opened.
|
||||
// So, don't reuse pointers to opened Page Info windows - simply append
|
||||
// to this list.
|
||||
gPageInfo = BrowserPageInfo(null, "permTab");
|
||||
}
|
||||
|
||||
function pageInfoObserve(win, topic, data) {
|
||||
Services.obs.removeObserver(pageInfoObserve, "page-info-dialog-loaded");
|
||||
executeSoon(gNextTest);
|
||||
}
|
||||
|
||||
function finishTest() {
|
||||
gPermissionManager.remove(makeURI("http://127.0.0.1:8888/"), gTestPermissionString);
|
||||
gPermissionManager.remove(makeURI("http://127.0.0.1:8888/"), gSecondTestPermissionString);
|
||||
Services.prefs.clearUserPref("plugins.click_to_play");
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
gPageInfo = null;
|
||||
gNextTest = null;
|
||||
gTestBrowser = null;
|
||||
gPluginHost = null;
|
||||
gPermissionManager = null;
|
||||
|
||||
executeSoon(finish);
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
Services.prefs.setBoolPref("plugins.click_to_play", true);
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gTestBrowser = gBrowser.selectedBrowser;
|
||||
gPermissionManager.remove(makeURI("http://127.0.0.1:8888/"), gTestPermissionString);
|
||||
gPermissionManager.remove(makeURI("http://127.0.0.1:8888/"), gSecondTestPermissionString);
|
||||
doOnPageLoad(gHttpTestRoot + "plugin_two_types.html", testPart1a);
|
||||
}
|
||||
|
||||
// The first test plugin is CtP and the second test plugin is enabled.
|
||||
function testPart1a() {
|
||||
let test = gTestBrowser.contentDocument.getElementById("test");
|
||||
let objLoadingContent = test.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
ok(!objLoadingContent.activated, "part 1a: Test plugin should not be activated");
|
||||
let secondtest = gTestBrowser.contentDocument.getElementById("secondtestA");
|
||||
objLoadingContent = secondtest.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
ok(objLoadingContent.activated, "part 1a: Second Test plugin should be activated");
|
||||
|
||||
doOnOpenPageInfo(testPart1b);
|
||||
}
|
||||
|
||||
function testPart1b() {
|
||||
let testRadioGroup = gPageInfo.document.getElementById(gTestPermissionString + "RadioGroup");
|
||||
let testRadioDefault = gPageInfo.document.getElementById(gTestPermissionString + "#0");
|
||||
|
||||
var qString = "#" + gTestPermissionString.replace(':', '\\:') + "\\#0";
|
||||
is(testRadioGroup.selectedItem, testRadioDefault, "part 1b: Test radio group should be set to 'Default'");
|
||||
let testRadioAllow = gPageInfo.document.getElementById(gTestPermissionString + "#1");
|
||||
testRadioGroup.selectedItem = testRadioAllow;
|
||||
testRadioAllow.doCommand();
|
||||
|
||||
let secondtestRadioGroup = gPageInfo.document.getElementById(gSecondTestPermissionString + "RadioGroup");
|
||||
let secondtestRadioDefault = gPageInfo.document.getElementById(gSecondTestPermissionString + "#0");
|
||||
is(secondtestRadioGroup.selectedItem, secondtestRadioDefault, "part 1b: Second Test radio group should be set to 'Default'");
|
||||
let secondtestRadioAsk = gPageInfo.document.getElementById(gSecondTestPermissionString + "#3");
|
||||
secondtestRadioGroup.selectedItem = secondtestRadioAsk;
|
||||
secondtestRadioAsk.doCommand();
|
||||
|
||||
doOnPageLoad(gHttpTestRoot + "plugin_two_types.html", testPart2);
|
||||
}
|
||||
|
||||
// Now, the Test plugin should be allowed, and the Test2 plugin should be CtP
|
||||
function testPart2() {
|
||||
let test = gTestBrowser.contentDocument.getElementById("test").
|
||||
QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
ok(test.activated, "part 2: Test plugin should be activated");
|
||||
|
||||
let secondtest = gTestBrowser.contentDocument.getElementById("secondtestA").
|
||||
QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
ok(!secondtest.activated, "part 2: Second Test plugin should not be activated");
|
||||
is(secondtest.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
|
||||
"part 2: Second test plugin should be click-to-play.");
|
||||
|
||||
let testRadioGroup = gPageInfo.document.getElementById(gTestPermissionString + "RadioGroup");
|
||||
let testRadioAllow = gPageInfo.document.getElementById(gTestPermissionString + "#1");
|
||||
is(testRadioGroup.selectedItem, testRadioAllow, "part 2: Test radio group should be set to 'Allow'");
|
||||
let testRadioBlock = gPageInfo.document.getElementById(gTestPermissionString + "#2");
|
||||
testRadioGroup.selectedItem = testRadioBlock;
|
||||
testRadioBlock.doCommand();
|
||||
|
||||
let secondtestRadioGroup = gPageInfo.document.getElementById(gSecondTestPermissionString + "RadioGroup");
|
||||
let secondtestRadioAsk = gPageInfo.document.getElementById(gSecondTestPermissionString + "#3");
|
||||
is(secondtestRadioGroup.selectedItem, secondtestRadioAsk, "part 2: Second Test radio group should be set to 'Always Ask'");
|
||||
let secondtestRadioBlock = gPageInfo.document.getElementById(gSecondTestPermissionString + "#2");
|
||||
secondtestRadioGroup.selectedItem = secondtestRadioBlock;
|
||||
secondtestRadioBlock.doCommand();
|
||||
|
||||
doOnPageLoad(gHttpTestRoot + "plugin_two_types.html", testPart3);
|
||||
}
|
||||
|
||||
// Now, all the things should be blocked
|
||||
function testPart3() {
|
||||
let test = gTestBrowser.contentDocument.getElementById("test").
|
||||
QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
ok(!test.activated, "part 3: Test plugin should not be activated");
|
||||
is(test.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_DISABLED,
|
||||
"part 3: Test plugin should be marked as PLUGIN_DISABLED");
|
||||
|
||||
let secondtest = gTestBrowser.contentDocument.getElementById("secondtestA").
|
||||
QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
|
||||
ok(!secondtest.activated, "part 3: Second Test plugin should not be activated");
|
||||
is(secondtest.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_DISABLED,
|
||||
"part 3: Second test plugin should be marked as PLUGIN_DISABLED");
|
||||
|
||||
// reset permissions
|
||||
gPermissionManager.remove(makeURI("http://127.0.0.1:8888/"), gTestPermissionString);
|
||||
gPermissionManager.remove(makeURI("http://127.0.0.1:8888/"), gSecondTestPermissionString);
|
||||
// check that changing the permissions affects the radio state in the
|
||||
// open Page Info window
|
||||
let testRadioGroup = gPageInfo.document.getElementById(gTestPermissionString + "RadioGroup");
|
||||
let testRadioDefault = gPageInfo.document.getElementById(gTestPermissionString + "#0");
|
||||
is(testRadioGroup.selectedItem, testRadioDefault, "part 3: Test radio group should be set to 'Default'");
|
||||
let secondtestRadioGroup = gPageInfo.document.getElementById(gSecondTestPermissionString + "RadioGroup");
|
||||
let secondtestRadioDefault = gPageInfo.document.getElementById(gSecondTestPermissionString + "#0");
|
||||
is(secondtestRadioGroup.selectedItem, secondtestRadioDefault, "part 3: Second Test radio group should be set to 'Default'");
|
||||
|
||||
doOnPageLoad(gHttpTestRoot + "plugin_two_types.html", testPart4a);
|
||||
}
|
||||
|
||||
// Now test that setting permission directly (as from the popup notification)
|
||||
// immediately influences Page Info.
|
||||
function testPart4a() {
|
||||
// simulate "allow" from the doorhanger
|
||||
gPermissionManager.add(gTestBrowser.currentURI, gTestPermissionString, Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
gPermissionManager.add(gTestBrowser.currentURI, gSecondTestPermissionString, Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
|
||||
// check (again) that changing the permissions affects the radio state in the
|
||||
// open Page Info window
|
||||
let testRadioGroup = gPageInfo.document.getElementById(gTestPermissionString + "RadioGroup");
|
||||
let testRadioAllow = gPageInfo.document.getElementById(gTestPermissionString + "#1");
|
||||
is(testRadioGroup.selectedItem, testRadioAllow, "part 4a: Test radio group should be set to 'Allow'");
|
||||
let secondtestRadioGroup = gPageInfo.document.getElementById(gSecondTestPermissionString + "RadioGroup");
|
||||
let secondtestRadioAllow = gPageInfo.document.getElementById(gSecondTestPermissionString + "#1");
|
||||
is(secondtestRadioGroup.selectedItem, secondtestRadioAllow, "part 4a: Second Test radio group should be set to 'Always Allow'");
|
||||
|
||||
// now close Page Info and see that it opens with the right settings
|
||||
gPageInfo.close();
|
||||
doOnOpenPageInfo(testPart4b);
|
||||
}
|
||||
|
||||
// check that "always allow" resulted in the radio buttons getting set to allow
|
||||
function testPart4b() {
|
||||
let testRadioGroup = gPageInfo.document.getElementById(gTestPermissionString + "RadioGroup");
|
||||
let testRadioAllow = gPageInfo.document.getElementById(gTestPermissionString + "#1");
|
||||
is(testRadioGroup.selectedItem, testRadioAllow, "part 4b: Test radio group should be set to 'Allow'");
|
||||
|
||||
let secondtestRadioGroup = gPageInfo.document.getElementById(gSecondTestPermissionString + "RadioGroup");
|
||||
let secondtestRadioAllow = gPageInfo.document.getElementById(gSecondTestPermissionString + "#1");
|
||||
is(secondtestRadioGroup.selectedItem, secondtestRadioAllow, "part 4b: Second Test radio group should be set to 'Allow'");
|
||||
|
||||
Services.prefs.setBoolPref("plugins.click_to_play", false);
|
||||
gPageInfo.close();
|
||||
finishTest();
|
||||
}
|
||||
@@ -200,7 +200,7 @@ Site.prototype = {
|
||||
* e.g. "cookie", "geo", "indexedDB", "popup", "image"
|
||||
*/
|
||||
clearPermission: function Site_clearPermission(aType) {
|
||||
Services.perms.remove(this.host, aType);
|
||||
Services.perms.remove(this.httpURI, aType);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -377,7 +377,7 @@ var gAdvancedPane = {
|
||||
},
|
||||
|
||||
// XXX: duplicated in browser.js
|
||||
_getOfflineAppUsage: function (host, groups)
|
||||
_getOfflineAppUsage: function (perm, groups)
|
||||
{
|
||||
var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
|
||||
getService(Components.interfaces.nsIApplicationCacheService);
|
||||
@@ -390,7 +390,7 @@ var gAdvancedPane = {
|
||||
var usage = 0;
|
||||
for (var i = 0; i < groups.length; i++) {
|
||||
var uri = ios.newURI(groups[i], null, null);
|
||||
if (uri.asciiHost == host) {
|
||||
if (uri.asciiHost == perm.host) {
|
||||
var cache = cacheService.getActiveCache(groups[i]);
|
||||
usage += cache.usage;
|
||||
}
|
||||
@@ -429,7 +429,7 @@ var gAdvancedPane = {
|
||||
row.className = "offlineapp";
|
||||
row.setAttribute("host", perm.host);
|
||||
var converted = DownloadUtils.
|
||||
convertByteUnits(this._getOfflineAppUsage(perm.host, groups));
|
||||
convertByteUnits(this._getOfflineAppUsage(perm, groups));
|
||||
row.setAttribute("usage",
|
||||
bundle.getFormattedString("offlineAppUsage",
|
||||
converted));
|
||||
@@ -476,7 +476,7 @@ var gAdvancedPane = {
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
var groups = cacheService.getGroups();
|
||||
for (var i = 0; i < groups.length; i++) {
|
||||
var uri = ios.newURI(groups[i], null, null);
|
||||
let uri = ios.newURI(groups[i], null, null);
|
||||
if (uri.asciiHost == host) {
|
||||
var cache = cacheService.getActiveCache(groups[i]);
|
||||
cache.discard();
|
||||
@@ -486,10 +486,15 @@ var gAdvancedPane = {
|
||||
// remove the permission
|
||||
var pm = Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Components.interfaces.nsIPermissionManager);
|
||||
pm.remove(host, "offline-app",
|
||||
Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
|
||||
pm.remove(host, "offline-app",
|
||||
Components.interfaces.nsIOfflineCacheUpdateService.ALLOW_NO_WARN);
|
||||
let uri;
|
||||
try {
|
||||
// file:// URIs are stored with their scheme. We try to parse them first, as
|
||||
// URIs like http://file:///foo/bar/baz.html will parse as HTTP URIs.
|
||||
uri = ios.newURI(host, null, null);
|
||||
} catch (e) {
|
||||
uri = ios.newURI("http://" + host, null, null);
|
||||
}
|
||||
pm.remove(uri, "offline-app");
|
||||
|
||||
list.removeChild(item);
|
||||
gAdvancedPane.offlineAppSelected();
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
|
||||
const nsICookiePermission = Components.interfaces.nsICookiePermission;
|
||||
|
||||
@@ -83,9 +85,7 @@ var gPermissionManager = {
|
||||
var textbox = document.getElementById("url");
|
||||
var host = textbox.value.replace(/^\s*([-\w]*:\/+)?/, ""); // trim any leading space and scheme
|
||||
try {
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var uri = ioService.newURI("http://"+host, null, null);
|
||||
var uri = NetUtil.newURI("http://" + host);
|
||||
host = uri.host;
|
||||
} catch(ex) {
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
@@ -112,7 +112,7 @@ var gPermissionManager = {
|
||||
|
||||
if (!exists) {
|
||||
host = (host.charAt(0) == ".") ? host.substring(1,host.length) : host;
|
||||
var uri = ioService.newURI("http://" + host, null, null);
|
||||
var uri = NetUtil.newURI("http://" + host);
|
||||
this._pm.add(uri, this._type, aCapability);
|
||||
}
|
||||
textbox.value = "";
|
||||
@@ -257,7 +257,8 @@ var gPermissionManager = {
|
||||
gTreeUtils.deleteSelectedItems(this._tree, this._view, this._permissions, removedPermissions);
|
||||
for (var i = 0; i < removedPermissions.length; ++i) {
|
||||
var p = removedPermissions[i];
|
||||
this._pm.remove(p.host, p.type);
|
||||
let uri = NetUtil.newURI("http://" + p.host);
|
||||
this._pm.remove(uri, p.type);
|
||||
}
|
||||
document.getElementById("removePermission").disabled = !this._permissions.length;
|
||||
document.getElementById("removeAllPermissions").disabled = !this._permissions.length;
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||
Components.utils.import("resource://gre/modules/ForgetAboutSite.jsm");
|
||||
|
||||
const ABOUT_PERMISSIONS_SPEC = "about:permissions";
|
||||
|
||||
const TEST_URI_1 = NetUtil.newURI("http://mozilla.com/");
|
||||
const TEST_URI_2 = NetUtil.newURI("http://mozilla.org/");
|
||||
const TEST_URI_3 = NetUtil.newURI("http://wikipedia.org/");
|
||||
|
||||
// values from DefaultPermissions object
|
||||
const PERM_UNKNOWN = 0;
|
||||
const PERM_ALLOW = 1;
|
||||
const PERM_DENY = 2;
|
||||
|
||||
// used to set permissions on test sites
|
||||
const TEST_PERMS = {
|
||||
"password": PERM_ALLOW,
|
||||
"cookie": PERM_ALLOW,
|
||||
"geo": PERM_UNKNOWN,
|
||||
"indexedDB": PERM_UNKNOWN,
|
||||
"popup": PERM_DENY
|
||||
};
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
registerCleanupFunction(cleanUp);
|
||||
setup(function() {
|
||||
runNextTest();
|
||||
});
|
||||
}
|
||||
|
||||
function setup(aCallback) {
|
||||
// add test history visit
|
||||
PlacesTestUtils.addVisits(TEST_URI_1).then(() => {
|
||||
// set permissions ourselves to avoid problems with different defaults
|
||||
// from test harness configuration
|
||||
for (let type in TEST_PERMS) {
|
||||
if (type == "password") {
|
||||
Services.logins.setLoginSavingEnabled(TEST_URI_2.prePath, true);
|
||||
} else {
|
||||
// set permissions on a site without history visits to test enumerateServices
|
||||
Services.perms.add(TEST_URI_2, type, TEST_PERMS[type]);
|
||||
}
|
||||
}
|
||||
|
||||
Services.perms.add(TEST_URI_3, "popup", TEST_PERMS["popup"]);
|
||||
aCallback();
|
||||
});
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
for (let type in TEST_PERMS) {
|
||||
if (type != "password") {
|
||||
Services.perms.remove(TEST_URI_1, type);
|
||||
Services.perms.remove(TEST_URI_2, type);
|
||||
Services.perms.remove(TEST_URI_3, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function runNextTest() {
|
||||
if (gTestIndex == tests.length) {
|
||||
PlacesTestUtils.clearHistory().then(finish);
|
||||
return;
|
||||
}
|
||||
|
||||
let nextTest = tests[gTestIndex++];
|
||||
info(nextTest.desc);
|
||||
|
||||
function preinit_observer() {
|
||||
Services.obs.removeObserver(preinit_observer, "browser-permissions-preinit");
|
||||
nextTest.preInit();
|
||||
}
|
||||
Services.obs.addObserver(preinit_observer, "browser-permissions-preinit", false);
|
||||
|
||||
function init_observer() {
|
||||
Services.obs.removeObserver(init_observer, "browser-permissions-initialized");
|
||||
nextTest.run();
|
||||
}
|
||||
Services.obs.addObserver(init_observer, "browser-permissions-initialized", false);
|
||||
|
||||
// open about:permissions
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab("about:permissions");
|
||||
registerCleanupFunction(function() {
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
}
|
||||
|
||||
var gSitesList;
|
||||
|
||||
var gTestIndex = 0;
|
||||
var tests = [
|
||||
// 'preInit' occurs after opening about:permissions, before sites-list is populated
|
||||
// 'run' occurs after sites-list is populated
|
||||
{
|
||||
desc: "test filtering before sites-list is fully constructed.",
|
||||
preInit: function() {
|
||||
let sitesFilter = gBrowser.contentDocument.getElementById("sites-filter");
|
||||
sitesFilter.value = TEST_URI_2.host;
|
||||
sitesFilter.doCommand();
|
||||
},
|
||||
run: function() {
|
||||
let testSite1 = getSiteItem(TEST_URI_1.host);
|
||||
ok(testSite1.collapsed, "test site 1 is collapsed after early filtering");
|
||||
let testSite2 = getSiteItem(TEST_URI_2.host);
|
||||
ok(!testSite2.collapsed, "test site 2 is not collapsed after early filtering");
|
||||
let testSite3 = getSiteItem(TEST_URI_3.host);
|
||||
ok(testSite3.collapsed, "test site 3 is collapsed after early filtering");
|
||||
|
||||
runNextTest();
|
||||
}
|
||||
},
|
||||
{
|
||||
desc: "test removing from sites-list before it is fully constructed.",
|
||||
preInit: function() {
|
||||
ForgetAboutSite.removeDataFromDomain(TEST_URI_2.host);
|
||||
},
|
||||
run: function() {
|
||||
let testSite1 = getSiteItem(TEST_URI_1.host);
|
||||
ok(testSite1, "test site 1 was not removed from sites list");
|
||||
let testSite2 = getSiteItem(TEST_URI_2.host);
|
||||
ok(!testSite2, "test site 2 was pre-removed from sites list");
|
||||
let testSite3 = getSiteItem(TEST_URI_3.host);
|
||||
ok(testSite3, "test site 3 was not removed from sites list");
|
||||
|
||||
runNextTest();
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
function getSiteItem(aHost) {
|
||||
return gBrowser.contentDocument.
|
||||
querySelector(".site[value='" + aHost + "']");
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
testRunner.runTests();
|
||||
}
|
||||
|
||||
var testRunner = {
|
||||
|
||||
tests:
|
||||
[
|
||||
{
|
||||
test: function(params) {
|
||||
params.url.value = "test.com";
|
||||
params.btnAllow.doCommand();
|
||||
is(params.tree.view.rowCount, 1, "added exception shows up in treeview");
|
||||
is(params.tree.view.getCellText(0, params.statusCol), params.allowText,
|
||||
"permission text should be set correctly");
|
||||
params.btnApplyChanges.doCommand();
|
||||
},
|
||||
observances: [{ type: "cookie", host: "test.com", data: "added",
|
||||
capability: Ci.nsIPermissionManager.ALLOW_ACTION }],
|
||||
},
|
||||
{
|
||||
test: function(params) {
|
||||
params.url.value = "test.com";
|
||||
params.btnBlock.doCommand();
|
||||
is(params.tree.view.getCellText(0, params.statusCol), params.denyText,
|
||||
"permission should change to deny in UI");
|
||||
params.btnApplyChanges.doCommand();
|
||||
},
|
||||
observances: [{ type: "cookie", host: "test.com", data: "changed",
|
||||
capability: Ci.nsIPermissionManager.DENY_ACTION }],
|
||||
},
|
||||
{
|
||||
test: function(params) {
|
||||
params.url.value = "test.com";
|
||||
params.btnAllow.doCommand();
|
||||
is(params.tree.view.getCellText(0, params.statusCol), params.allowText,
|
||||
"permission should revert back to allow");
|
||||
params.btnApplyChanges.doCommand();
|
||||
},
|
||||
observances: [{ type: "cookie", host: "test.com", data: "changed",
|
||||
capability: Ci.nsIPermissionManager.ALLOW_ACTION }],
|
||||
},
|
||||
{
|
||||
test: function(params) {
|
||||
params.url.value = "test.com";
|
||||
params.btnRemove.doCommand();
|
||||
is(params.tree.view.rowCount, 0, "exception should be removed");
|
||||
params.btnApplyChanges.doCommand();
|
||||
},
|
||||
observances: [{ type: "cookie", host: "test.com", data: "deleted" }],
|
||||
},
|
||||
{
|
||||
test: function(params) {
|
||||
let uri = params.ioService.newURI("http://test.com", null, null);
|
||||
params.pm.add(uri, "popup", Ci.nsIPermissionManager.DENY_ACTION);
|
||||
is(params.tree.view.rowCount, 0, "adding unrelated permission should not change display");
|
||||
params.btnApplyChanges.doCommand();
|
||||
},
|
||||
observances: [{ type: "popup", host: "test.com", data: "added",
|
||||
capability: Ci.nsIPermissionManager.DENY_ACTION }],
|
||||
cleanUp: function(params) {
|
||||
let uri = params.ioService.newURI("http://test.com", null, null);
|
||||
params.pm.remove(uri, "popup");
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
_currentTest: -1,
|
||||
|
||||
runTests: function() {
|
||||
this._currentTest++;
|
||||
|
||||
info("Running test #" + (this._currentTest + 1) + "\n");
|
||||
let that = this;
|
||||
let p = this.runCurrentTest();
|
||||
p.then(function() {
|
||||
if (that._currentTest == that.tests.length - 1) {
|
||||
finish();
|
||||
}
|
||||
else {
|
||||
that.runTests();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
runCurrentTest: function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
||||
let helperFunctions = {
|
||||
|
||||
prefWindowObserver: function(subject, topic, data) {
|
||||
if (topic != "domwindowopened")
|
||||
return;
|
||||
|
||||
Services.ww.unregisterNotification(helperFunctions.prefWindowObserver);
|
||||
|
||||
let win = subject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
|
||||
win.addEventListener("load", function(event) {
|
||||
let historyMode = event.target.getElementById("historyMode");
|
||||
historyMode.value = "custom";
|
||||
historyMode.doCommand();
|
||||
Services.ww.registerNotification(helperFunctions.cookiesWindowObserver);
|
||||
event.target.getElementById("cookieExceptions").doCommand();
|
||||
}, false);
|
||||
},
|
||||
|
||||
cookiesWindowObserver: function(subject, topic, data) {
|
||||
if (topic != "domwindowopened")
|
||||
return;
|
||||
|
||||
Services.ww.unregisterNotification(helperFunctions.cookiesWindowObserver);
|
||||
|
||||
let win = subject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
|
||||
win.addEventListener("load", function(event) {
|
||||
SimpleTest.executeSoon(function() helperFunctions.windowLoad(event, win));
|
||||
}, false);
|
||||
},
|
||||
|
||||
windowLoad: function(event, win) {
|
||||
let params = {
|
||||
doc: event.target,
|
||||
tree: event.target.getElementById("permissionsTree"),
|
||||
statusCol: event.target.getElementById("permissionsTree").treeBoxObject.columns.getColumnAt(1),
|
||||
url: event.target.getElementById("url"),
|
||||
btnAllow: event.target.getElementById("btnAllow"),
|
||||
btnBlock: event.target.getElementById("btnBlock"),
|
||||
btnApplyChanges: event.target.getElementById("btnApplyChanges"),
|
||||
btnRemove: event.target.getElementById("removePermission"),
|
||||
pm: Cc["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Ci.nsIPermissionManager),
|
||||
ioService: Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService),
|
||||
allowText: win.gPermissionManager._getCapabilityString(
|
||||
Ci.nsIPermissionManager.ALLOW_ACTION),
|
||||
denyText: win.gPermissionManager._getCapabilityString(
|
||||
Ci.nsIPermissionManager.DENY_ACTION),
|
||||
allow: Ci.nsIPermissionManager.ALLOW_ACTION,
|
||||
deny: Ci.nsIPermissionManager.DENY_ACTION,
|
||||
};
|
||||
|
||||
let permObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic != "perm-changed")
|
||||
return;
|
||||
|
||||
if (testRunner.tests[testRunner._currentTest].observances.length == 0) {
|
||||
// Should fail here as we are not expecting a notification, but we don't.
|
||||
// See bug 1063410.
|
||||
return;
|
||||
}
|
||||
|
||||
let permission = aSubject.QueryInterface(Ci.nsIPermission);
|
||||
let expected = testRunner.tests[testRunner._currentTest].observances.shift();
|
||||
|
||||
is(aData, expected.data, "type of message should be the same");
|
||||
for each (let prop in ["type", "host", "capability"]) {
|
||||
if (expected[prop])
|
||||
is(permission[prop], expected[prop],
|
||||
"property: \"" + prop + "\" should be equal");
|
||||
}
|
||||
|
||||
os.removeObserver(permObserver, "perm-changed");
|
||||
|
||||
if (testRunner.tests[testRunner._currentTest].cleanup) {
|
||||
testRunner.tests[testRunner._currentTest].cleanup();
|
||||
}
|
||||
|
||||
testRunner.dialog.close(params);
|
||||
win.close();
|
||||
resolve();
|
||||
},
|
||||
};
|
||||
|
||||
let os = Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService);
|
||||
|
||||
os.addObserver(permObserver, "perm-changed", false);
|
||||
|
||||
if (testRunner._currentTest == 0) {
|
||||
is(params.tree.view.rowCount, 0, "no cookie exceptions");
|
||||
}
|
||||
|
||||
testRunner.tests[testRunner._currentTest].test(params);
|
||||
},
|
||||
};
|
||||
|
||||
Services.ww.registerNotification(helperFunctions.prefWindowObserver);
|
||||
|
||||
testRunner.dialog = openDialog("chrome://browser/content/preferences/preferences.xul",
|
||||
"Preferences", "chrome,titlebar,toolbar,centerscreen,dialog=no",
|
||||
"panePrivacy");
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,313 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// tests the translation infobar, using a fake 'Translation' implementation.
|
||||
|
||||
let tmp = {};
|
||||
Cu.import("resource:///modules/translation/Translation.jsm", tmp);
|
||||
Cu.import("resource://gre/modules/Promise.jsm", tmp);
|
||||
let {Translation, Promise} = tmp;
|
||||
|
||||
const kLanguagesPref = "browser.translation.neverForLanguages";
|
||||
const kShowUIPref = "browser.translation.ui.show";
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
Services.prefs.setBoolPref(kShowUIPref, true);
|
||||
let tab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = tab;
|
||||
registerCleanupFunction(function () {
|
||||
gBrowser.removeTab(tab);
|
||||
Services.prefs.clearUserPref(kShowUIPref);
|
||||
});
|
||||
tab.linkedBrowser.addEventListener("load", function onload() {
|
||||
tab.linkedBrowser.removeEventListener("load", onload, true);
|
||||
Task.spawn(function* () {
|
||||
for (let test of gTests) {
|
||||
info(test.desc);
|
||||
yield test.run();
|
||||
}
|
||||
}).then(finish, ex => {
|
||||
ok(false, "Unexpected Exception: " + ex);
|
||||
finish();
|
||||
});
|
||||
}, true);
|
||||
|
||||
content.location = "http://example.com/";
|
||||
}
|
||||
|
||||
function getLanguageExceptions() {
|
||||
let langs = Services.prefs.getCharPref(kLanguagesPref);
|
||||
return langs ? langs.split(",") : [];
|
||||
}
|
||||
|
||||
function getDomainExceptions() {
|
||||
let results = [];
|
||||
let enumerator = Services.perms.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let perm = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
|
||||
if (perm.type == "translate" &&
|
||||
perm.capability == Services.perms.DENY_ACTION)
|
||||
results.push(perm.host);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function getInfoBar() {
|
||||
return gBrowser.getNotificationBox().getNotificationWithValue("translation");
|
||||
}
|
||||
|
||||
function openPopup(aPopup) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
aPopup.addEventListener("popupshown", function popupShown() {
|
||||
aPopup.removeEventListener("popupshown", popupShown);
|
||||
deferred.resolve();
|
||||
});
|
||||
|
||||
aPopup.focus();
|
||||
// One down event to open the popup.
|
||||
EventUtils.synthesizeKey("VK_DOWN",
|
||||
{ altKey: !navigator.platform.includes("Mac") });
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function waitForWindowLoad(aWin) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
aWin.addEventListener("load", function onload() {
|
||||
aWin.removeEventListener("load", onload, true);
|
||||
deferred.resolve();
|
||||
}, true);
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
let gTests = [
|
||||
|
||||
{
|
||||
desc: "clean exception lists at startup",
|
||||
run: function checkNeverForLanguage() {
|
||||
is(getLanguageExceptions().length, 0,
|
||||
"we start with an empty list of languages to never translate");
|
||||
is(getDomainExceptions().length, 0,
|
||||
"we start with an empty list of sites to never translate");
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
desc: "never for language",
|
||||
run: function* checkNeverForLanguage() {
|
||||
// Show the infobar for example.com and fr.
|
||||
Translation.documentStateReceived(gBrowser.selectedBrowser,
|
||||
{state: Translation.STATE_OFFER,
|
||||
originalShown: true,
|
||||
detectedLanguage: "fr"});
|
||||
let notif = getInfoBar();
|
||||
ok(notif, "the infobar is visible");
|
||||
let ui = gBrowser.selectedBrowser.translationUI;
|
||||
let uri = gBrowser.selectedBrowser.currentURI;
|
||||
ok(ui.shouldShowInfoBar(uri, "fr"),
|
||||
"check shouldShowInfoBar initially returns true");
|
||||
|
||||
// Open the "options" drop down.
|
||||
yield openPopup(notif._getAnonElt("options"));
|
||||
ok(notif._getAnonElt("options").getAttribute("open"),
|
||||
"the options menu is open");
|
||||
|
||||
// Check that the item is not disabled.
|
||||
ok(!notif._getAnonElt("neverForLanguage").disabled,
|
||||
"The 'Never translate <language>' item isn't disabled");
|
||||
|
||||
// Click the 'Never for French' item.
|
||||
notif._getAnonElt("neverForLanguage").click();
|
||||
ok(!getInfoBar(), "infobar hidden");
|
||||
|
||||
// Check this has been saved to the exceptions list.
|
||||
let langs = getLanguageExceptions();
|
||||
is(langs.length, 1, "one language in the exception list");
|
||||
is(langs[0], "fr", "correct language in the exception list");
|
||||
ok(!ui.shouldShowInfoBar(uri, "fr"),
|
||||
"the infobar wouldn't be shown anymore");
|
||||
|
||||
// Reopen the infobar.
|
||||
PopupNotifications.getNotification("translate").anchorElement.click();
|
||||
notif = getInfoBar();
|
||||
// Open the "options" drop down.
|
||||
yield openPopup(notif._getAnonElt("options"));
|
||||
ok(notif._getAnonElt("neverForLanguage").disabled,
|
||||
"The 'Never translate French' item is disabled");
|
||||
|
||||
// Cleanup.
|
||||
Services.prefs.setCharPref(kLanguagesPref, "");
|
||||
notif.close();
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
desc: "never for site",
|
||||
run: function* checkNeverForSite() {
|
||||
// Show the infobar for example.com and fr.
|
||||
Translation.documentStateReceived(gBrowser.selectedBrowser,
|
||||
{state: Translation.STATE_OFFER,
|
||||
originalShown: true,
|
||||
detectedLanguage: "fr"});
|
||||
let notif = getInfoBar();
|
||||
ok(notif, "the infobar is visible");
|
||||
let ui = gBrowser.selectedBrowser.translationUI;
|
||||
let uri = gBrowser.selectedBrowser.currentURI;
|
||||
ok(ui.shouldShowInfoBar(uri, "fr"),
|
||||
"check shouldShowInfoBar initially returns true");
|
||||
|
||||
// Open the "options" drop down.
|
||||
yield openPopup(notif._getAnonElt("options"));
|
||||
ok(notif._getAnonElt("options").getAttribute("open"),
|
||||
"the options menu is open");
|
||||
|
||||
// Check that the item is not disabled.
|
||||
ok(!notif._getAnonElt("neverForSite").disabled,
|
||||
"The 'Never translate site' item isn't disabled");
|
||||
|
||||
// Click the 'Never for French' item.
|
||||
notif._getAnonElt("neverForSite").click();
|
||||
ok(!getInfoBar(), "infobar hidden");
|
||||
|
||||
// Check this has been saved to the exceptions list.
|
||||
let sites = getDomainExceptions();
|
||||
is(sites.length, 1, "one site in the exception list");
|
||||
is(sites[0], "example.com", "correct site in the exception list");
|
||||
ok(!ui.shouldShowInfoBar(uri, "fr"),
|
||||
"the infobar wouldn't be shown anymore");
|
||||
|
||||
// Reopen the infobar.
|
||||
PopupNotifications.getNotification("translate").anchorElement.click();
|
||||
notif = getInfoBar();
|
||||
// Open the "options" drop down.
|
||||
yield openPopup(notif._getAnonElt("options"));
|
||||
ok(notif._getAnonElt("neverForSite").disabled,
|
||||
"The 'Never translate French' item is disabled");
|
||||
|
||||
// Cleanup.
|
||||
Services.perms.remove(makeURI("http://example.com"), "translate");
|
||||
notif.close();
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
desc: "language exception list",
|
||||
run: function* checkLanguageExceptions() {
|
||||
// Put 2 languages in the pref before opening the window to check
|
||||
// the list is displayed on load.
|
||||
Services.prefs.setCharPref(kLanguagesPref, "fr,de");
|
||||
|
||||
// Open the translation exceptions dialog.
|
||||
let win = openDialog("chrome://browser/content/preferences/translation.xul",
|
||||
"Browser:TranslationExceptions",
|
||||
"", null);
|
||||
yield waitForWindowLoad(win);
|
||||
|
||||
// Check that the list of language exceptions is loaded.
|
||||
let getById = win.document.getElementById.bind(win.document);
|
||||
let tree = getById("languagesTree");
|
||||
let remove = getById("removeLanguage");
|
||||
let removeAll = getById("removeAllLanguages");
|
||||
is(tree.view.rowCount, 2, "The language exceptions list has 2 items");
|
||||
ok(remove.disabled, "The 'Remove Language' button is disabled");
|
||||
ok(!removeAll.disabled, "The 'Remove All Languages' button is enabled");
|
||||
|
||||
// Select the first item.
|
||||
tree.view.selection.select(0);
|
||||
ok(!remove.disabled, "The 'Remove Language' button is enabled");
|
||||
|
||||
// Click the 'Remove' button.
|
||||
remove.click();
|
||||
is(tree.view.rowCount, 1, "The language exceptions now contains 1 item");
|
||||
is(getLanguageExceptions().length, 1, "One exception in the pref");
|
||||
|
||||
// Clear the pref, and check the last item is removed from the display.
|
||||
Services.prefs.setCharPref(kLanguagesPref, "");
|
||||
is(tree.view.rowCount, 0, "The language exceptions list is empty");
|
||||
ok(remove.disabled, "The 'Remove Language' button is disabled");
|
||||
ok(removeAll.disabled, "The 'Remove All Languages' button is disabled");
|
||||
|
||||
// Add an item and check it appears.
|
||||
Services.prefs.setCharPref(kLanguagesPref, "fr");
|
||||
is(tree.view.rowCount, 1, "The language exceptions list has 1 item");
|
||||
ok(remove.disabled, "The 'Remove Language' button is disabled");
|
||||
ok(!removeAll.disabled, "The 'Remove All Languages' button is enabled");
|
||||
|
||||
// Click the 'Remove All' button.
|
||||
removeAll.click();
|
||||
is(tree.view.rowCount, 0, "The language exceptions list is empty");
|
||||
ok(remove.disabled, "The 'Remove Language' button is disabled");
|
||||
ok(removeAll.disabled, "The 'Remove All Languages' button is disabled");
|
||||
is(Services.prefs.getCharPref(kLanguagesPref), "", "The pref is empty");
|
||||
|
||||
win.close();
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
desc: "domains exception list",
|
||||
run: function* checkDomainExceptions() {
|
||||
// Put 2 exceptions before opening the window to check the list is
|
||||
// displayed on load.
|
||||
let perms = Services.perms;
|
||||
perms.add(makeURI("http://example.org"), "translate", perms.DENY_ACTION);
|
||||
perms.add(makeURI("http://example.com"), "translate", perms.DENY_ACTION);
|
||||
|
||||
// Open the translation exceptions dialog.
|
||||
let win = openDialog("chrome://browser/content/preferences/translation.xul",
|
||||
"Browser:TranslationExceptions",
|
||||
"", null);
|
||||
yield waitForWindowLoad(win);
|
||||
|
||||
// Check that the list of language exceptions is loaded.
|
||||
let getById = win.document.getElementById.bind(win.document);
|
||||
let tree = getById("sitesTree");
|
||||
let remove = getById("removeSite");
|
||||
let removeAll = getById("removeAllSites");
|
||||
is(tree.view.rowCount, 2, "The sites exceptions list has 2 items");
|
||||
ok(remove.disabled, "The 'Remove Site' button is disabled");
|
||||
ok(!removeAll.disabled, "The 'Remove All Sites' button is enabled");
|
||||
|
||||
// Select the first item.
|
||||
tree.view.selection.select(0);
|
||||
ok(!remove.disabled, "The 'Remove Site' button is enabled");
|
||||
|
||||
// Click the 'Remove' button.
|
||||
remove.click();
|
||||
is(tree.view.rowCount, 1, "The site exceptions now contains 1 item");
|
||||
is(getDomainExceptions().length, 1, "One exception in the permissions");
|
||||
|
||||
// Clear the permissions, and check the last item is removed from the display.
|
||||
perms.remove(makeURI("http://example.org"), "translate");
|
||||
perms.remove(makeURI("http://example.com"), "translate");
|
||||
is(tree.view.rowCount, 0, "The site exceptions list is empty");
|
||||
ok(remove.disabled, "The 'Remove Site' button is disabled");
|
||||
ok(removeAll.disabled, "The 'Remove All Site' button is disabled");
|
||||
|
||||
// Add an item and check it appears.
|
||||
perms.add(makeURI("http://example.com"), "translate", perms.DENY_ACTION);
|
||||
is(tree.view.rowCount, 1, "The site exceptions list has 1 item");
|
||||
ok(remove.disabled, "The 'Remove Site' button is disabled");
|
||||
ok(!removeAll.disabled, "The 'Remove All Sites' button is enabled");
|
||||
|
||||
// Click the 'Remove All' button.
|
||||
removeAll.click();
|
||||
is(tree.view.rowCount, 0, "The site exceptions list is empty");
|
||||
ok(remove.disabled, "The 'Remove Site' button is disabled");
|
||||
ok(removeAll.disabled, "The 'Remove All Sites' button is disabled");
|
||||
is(getDomainExceptions().length, 0, "No exceptions in the permissions");
|
||||
|
||||
win.close();
|
||||
}
|
||||
}
|
||||
|
||||
];
|
||||
@@ -93,7 +93,7 @@ this.SitePermissions = {
|
||||
if (!this.isSupportedURI(aURI))
|
||||
return;
|
||||
|
||||
Services.perms.remove(aURI.host, aPermissionID);
|
||||
Services.perms.remove(aURI, aPermissionID);
|
||||
|
||||
if (aPermissionID in gPermissionObject &&
|
||||
gPermissionObject[aPermissionID].onChange)
|
||||
@@ -216,7 +216,7 @@ let gPermissionObject = {
|
||||
},
|
||||
onChange: function (aURI, aState) {
|
||||
if (aState == SitePermissions.ALLOW || aState == SitePermissions.BLOCK)
|
||||
Services.perms.remove(aURI.host, "indexedDB-unlimited");
|
||||
Services.perms.remove(aURI, "indexedDB-unlimited");
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -16,14 +16,14 @@ function run_test() {
|
||||
do_check_true(permission_exists(kTestAddr, kType, kCapability));
|
||||
|
||||
// remove the permission, and make sure it was removed
|
||||
Services.perms.remove(kTestAddr, kType);
|
||||
Services.perms.remove(uri, kType);
|
||||
do_check_false(permission_exists(kTestAddr, kType, kCapability));
|
||||
|
||||
uri = Services.io.newURI("mailto:" + kTestAddr, null, null);
|
||||
Services.perms.add(uri, kType, kCapability);
|
||||
do_check_true(permission_exists(kTestAddr, kType, kCapability));
|
||||
|
||||
Services.perms.remove(kTestAddr, kType);
|
||||
Services.perms.remove(uri, kType);
|
||||
do_check_false(permission_exists(kTestAddr, kType, kCapability));
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ add_task(function test_web_channel_listen_permission() {
|
||||
return new Promise((resolve, reject) => {
|
||||
// add a new permission
|
||||
Services.perms.add(VALID_WEB_CHANNEL_ORIGIN, TEST_PERMISSION_NAME, Services.perms.ALLOW_ACTION);
|
||||
do_register_cleanup(() => Services.perms.remove(VALID_WEB_CHANNEL_ORIGIN.spec, TEST_PERMISSION_NAME));
|
||||
do_register_cleanup(() => Services.perms.remove(VALID_WEB_CHANNEL_ORIGIN, TEST_PERMISSION_NAME));
|
||||
let channel = new WebChannel(VALID_WEB_CHANNEL_ID, TEST_PERMISSION_NAME, {
|
||||
broker: MockWebChannelBroker
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ function finish_test(count) {
|
||||
.getService(Components.interfaces.nsIHttpAuthManager);
|
||||
authMgr.clearAll();
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -39,7 +39,7 @@ function finish_test(count) {
|
||||
.getService(Components.interfaces.nsIHttpAuthManager);
|
||||
authMgr.clearAll();
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -47,7 +47,7 @@ function finish_test(count) {
|
||||
.getService(Components.interfaces.nsIHttpAuthManager);
|
||||
authMgr.clearAll();
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -46,7 +46,7 @@ function finish_test(count) {
|
||||
.getService(Components.interfaces.nsIHttpAuthManager);
|
||||
authMgr.clearAll();
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeTab(gNewTab);
|
||||
Harness.finish();
|
||||
|
||||
@@ -26,7 +26,7 @@ function download_failed(install) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 0, "No add-ons should have been installed");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com/"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -26,7 +26,7 @@ function download_failed(install) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 0, "No add-ons should have been installed");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com/"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -18,7 +18,7 @@ function check_xpi_install(install, addon) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -28,7 +28,7 @@ function confirm_install(window) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 0, "0 Add-ons should have been successfully installed");
|
||||
Services.perms.remove("addons.mozilla.org", "install");
|
||||
Services.perms.remove(makeURI("http://addons.mozilla.org"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -46,7 +46,7 @@ function finish_test(count) {
|
||||
|
||||
Services.ww = gWindowWatcher;
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
Harness.finish();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 0, "No add-ons should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -81,8 +81,8 @@ function test() {
|
||||
Services.prefs.clearUserPref(PREF_LOGGING_ENABLED);
|
||||
Services.prefs.clearUserPref(PREF_INSTALL_REQUIRESECUREORIGIN);
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove("example.org", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
Services.perms.remove(makeURI("http://example.org"), "install");
|
||||
|
||||
while (gConcurrentTabs.length) {
|
||||
gBrowser.removeTab(gConcurrentTabs.shift());
|
||||
|
||||
@@ -23,7 +23,7 @@ function download_failed(install) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 0, "No add-ons should have been installed");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -33,7 +33,7 @@ function finish_test(count) {
|
||||
.getService(Components.interfaces.nsICookieManager2);
|
||||
cm.remove("example.com", "xpinstall", "/browser/" + RELATIVE_DIR, false);
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -37,7 +37,7 @@ function finish_test(count) {
|
||||
|
||||
Services.prefs.clearUserPref("network.cookie.cookieBehavior");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -36,7 +36,7 @@ function finish_test(count) {
|
||||
cm.remove("example.org", "xpinstall", "/browser/" + RELATIVE_DIR, false);
|
||||
|
||||
Services.prefs.clearUserPref("network.cookie.cookieBehavior");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -22,7 +22,7 @@ function download_failed(install) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 0, "No add-ons should have been installed");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
var doc = gBrowser.contentDocument;
|
||||
is(doc.getElementById("status").textContent, "-207", "Callback should have seen the failure");
|
||||
|
||||
@@ -21,7 +21,7 @@ function download_failed(install) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 0, "No add-ons should have been installed");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -27,7 +27,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -27,7 +27,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -31,7 +31,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS);
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
@@ -31,7 +31,7 @@ function download_failed(install) {
|
||||
function finish_test(count) {
|
||||
is(count, 0, "0 Add-ons should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS);
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
@@ -31,7 +31,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS);
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
@@ -29,7 +29,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -32,7 +32,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS);
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
@@ -75,7 +75,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS);
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
@@ -18,7 +18,7 @@ function install_ended(install, addon) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -29,7 +29,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -28,7 +28,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 0, "No add-ons should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
Harness.finish();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ function finish_test(count) {
|
||||
} catch (ex) {
|
||||
}
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
wait_for_online();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
var doc = gBrowser.contentDocument;
|
||||
is(doc.getElementById("return").textContent, "true", "installTrigger should have claimed success");
|
||||
|
||||
@@ -65,7 +65,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 5, "5 Add-ons should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -60,7 +60,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 3, "3 Add-ons should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -26,7 +26,7 @@ function download_failed(install) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 0, "No add-ons should have been installed");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -34,7 +34,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -33,7 +33,7 @@ function install_ended(install, addon) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -18,7 +18,7 @@ function install_ended(install, addon) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -42,7 +42,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeTab(expectedTab);
|
||||
Harness.finish();
|
||||
|
||||
@@ -31,7 +31,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
var doc = gBrowser.contentDocument;
|
||||
is(gBrowser.currentURI.spec, TESTROOT + "triggerredirect.html#foo", "Should have redirected");
|
||||
|
||||
@@ -39,7 +39,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
var doc = gBrowser.contentDocument;
|
||||
is(doc.getElementById("return").textContent, "true", "installTrigger should have claimed success");
|
||||
|
||||
@@ -40,7 +40,7 @@ function install_ended(install, addon) {
|
||||
function finish_test(count) {
|
||||
is(count, 1, "1 Add-on should have been successfully installed");
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
var doc = gBrowser.contentWindow.frames[0].document; // Document of iframe
|
||||
is(doc.getElementById("return").textContent, "true", "installTrigger in iframe should have claimed success");
|
||||
|
||||
@@ -24,7 +24,7 @@ function allow_blocked(installInfo) {
|
||||
}
|
||||
|
||||
function finish_test() {
|
||||
Services.perms.remove("example.org", "install");
|
||||
Services.perms.remove(makeURI("http://example.org"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -21,7 +21,7 @@ function confirm_install(window) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 0, "No add-ons should have been installed");
|
||||
Services.perms.remove("example.org", "install");
|
||||
Services.perms.remove(makeURI("http://example.org"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -23,7 +23,7 @@ function allow_blocked(installInfo) {
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 0, "No add-ons should have been installed");
|
||||
Services.perms.remove("example.com", "install");
|
||||
Services.perms.remove(makeURI("http://example.com"), "install");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Harness.finish();
|
||||
|
||||
@@ -24,7 +24,7 @@ function allow_blocked(installInfo) {
|
||||
function finish_test(count) {
|
||||
is(count, 0, "No add-ons should have been installed");
|
||||
|
||||
Services.perms.remove("example.org", "install");
|
||||
Services.perms.remove(makeURI("http://example.org"), "install");
|
||||
Services.prefs.clearUserPref("xpinstall.whitelist.directRequest");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
Reference in New Issue
Block a user