Bug 1466817 - The "Edit Pop-up Blocker Options/Preferences" command should open the in-content preferences. r=jaws

Instead of opening the pop-up permissions dialog with the origin already populated, this command now highlights the pop-up permission row in the preferences. This doesn't remove any functionality because the only action that would be available for the origin in the permissions dialog is "Allow", which is equivalent to the "Allow pop-ups for" command in the notification bar menu.

Differential Revision: https://phabricator.services.mozilla.com/D15066

--HG--
extra : rebase_source : 064b3d39dc2a8c4d6a3c0949a51ab361ed6e71dd
This commit is contained in:
Paolo Amadini 2018-12-23 20:52:15 +00:00
Родитель 1a3007051c
Коммит 24c49f1473
6 изменённых файлов: 35 добавлений и 101 удалений

Просмотреть файл

@ -800,38 +800,7 @@ var gPopupBlockerObserver = {
}, },
editPopupSettings() { editPopupSettings() {
let prefillValue = ""; openPreferences("privacy-permissions-block-popups");
try {
// We use contentPrincipal rather than currentURI to get the right
// value in case this is a data: URI that's inherited off something else.
// Some principals don't have URIs, so fall back in case URI is not present.
let principalURI = gBrowser.contentPrincipal.URI || gBrowser.currentURI;
if (principalURI) {
// asciiHost conveniently doesn't throw.
if (principalURI.asciiHost) {
prefillValue = principalURI.prePath;
} else {
// For host-less URIs like file://, prePath would effectively allow
// popups everywhere on file://. Use the full spec:
prefillValue = principalURI.spec;
}
}
} catch (e) { }
var params = { blockVisible: false,
sessionVisible: false,
allowVisible: true,
prefilledHost: prefillValue,
permissionType: "popup",
};
var existingWindow = Services.wm.getMostRecentWindow("Browser:Permissions");
if (existingWindow) {
existingWindow.initWithParams(params);
existingWindow.focus();
} else
window.openDialog("chrome://browser/content/preferences/permissions.xul",
"_blank", "resizable,dialog=no,centerscreen", params);
}, },
dontShowMessage() { dontShowMessage() {

Просмотреть файл

@ -8,7 +8,6 @@
<?xml-stylesheet href="chrome://browser/skin/preferences/containers.css" type="text/css"?> <?xml-stylesheet href="chrome://browser/skin/preferences/containers.css" type="text/css"?>
<window id="ContainersDialog" <window id="ContainersDialog"
windowtype="Browser:Permissions"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
data-l10n-attrs="title, style" data-l10n-attrs="title, style"
onload="gContainersManager.onLoad();" onload="gContainersManager.onLoad();"

Просмотреть файл

@ -576,7 +576,7 @@
</hbox> </hbox>
</hbox> </hbox>
<hbox> <hbox data-subcategory="permissions-block-popups">
<checkbox id="popupPolicy" preference="dom.disable_open_during_load" <checkbox id="popupPolicy" preference="dom.disable_open_during_load"
data-l10n-id="permissions-block-popups" data-l10n-id="permissions-block-popups"
onsyncfrompreference="return gPrivacyPane.updateButtons('popupPolicyButton', onsyncfrompreference="return gPrivacyPane.updateButtons('popupPolicyButton',

Просмотреть файл

@ -1,67 +1,38 @@
add_task(async function test_openPreferences_spotlight() {
for (let [arg, expectedPane, expectedHash, expectedSubcategory] of [
["privacy-reports",
"panePrivacy", "#privacy", "reports"],
["privacy-address-autofill",
"panePrivacy", "#privacy", "address-autofill"],
["privacy-credit-card-autofill",
"panePrivacy", "#privacy", "credit-card-autofill"],
["privacy-form-autofill",
"panePrivacy", "#privacy", "form-autofill"],
["privacy-trackingprotection",
"panePrivacy", "#privacy", "trackingprotection"],
["privacy-permissions-block-popups",
"panePrivacy", "#privacy", "permissions-block-popups"],
]) {
if (arg == "privacy-credit-card-autofill" &&
!Services.prefs.getBoolPref("extensions.formautofill.creditCards.available")) {
continue;
}
add_task(async function test_reports_section() { let prefs =
let prefs = await openPreferencesViaOpenPreferencesAPI("privacy-reports", {leaveOpen: true}); await openPreferencesViaOpenPreferencesAPI(arg, { leaveOpen: true });
is(prefs.selectedPane, "panePrivacy", "Privacy pane is selected by default"); is(prefs.selectedPane, expectedPane, "The right pane is selected");
let doc = gBrowser.contentDocument; let doc = gBrowser.contentDocument;
is(doc.location.hash, "#privacy", "The subcategory should be removed from the URI"); is(doc.location.hash, expectedHash,
await TestUtils.waitForCondition(() => doc.querySelector(".spotlight"), "The subcategory should be removed from the URI");
"Wait for the reports section is spotlighted."); await TestUtils.waitForCondition(() => doc.querySelector(".spotlight"),
is(doc.querySelector(".spotlight").getAttribute("data-subcategory"), "reports", "Wait for the spotlight");
"The reports section is spotlighted."); is(doc.querySelector(".spotlight").getAttribute("data-subcategory"),
BrowserTestUtils.removeTab(gBrowser.selectedTab); expectedSubcategory, "The right subcategory is spotlighted");
});
add_task(async function test_address_autofill_section() { doc.defaultView.spotlight(null);
let prefs = await openPreferencesViaOpenPreferencesAPI("privacy-address-autofill", {leaveOpen: true}); is(doc.querySelector(".spotlight"), null,
is(prefs.selectedPane, "panePrivacy", "Privacy pane is selected by default"); "The spotlighted section is cleared");
let doc = gBrowser.contentDocument;
is(doc.location.hash, "#privacy", "The subcategory should be removed from the URI");
await TestUtils.waitForCondition(() => doc.querySelector(".spotlight"),
"Wait for the address-autofill section is spotlighted.");
is(doc.querySelector(".spotlight").getAttribute("data-subcategory"), "address-autofill",
"The address-autofill section is spotlighted.");
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
add_task(async function test_credit_card_autofill_section() { BrowserTestUtils.removeTab(gBrowser.selectedTab);
if (!Services.prefs.getBoolPref("extensions.formautofill.creditCards.available")) {
return;
} }
let prefs = await openPreferencesViaOpenPreferencesAPI("privacy-credit-card-autofill", {leaveOpen: true});
is(prefs.selectedPane, "panePrivacy", "Privacy pane is selected by default");
let doc = gBrowser.contentDocument;
is(doc.location.hash, "#privacy", "The subcategory should be removed from the URI");
await TestUtils.waitForCondition(() => doc.querySelector(".spotlight"),
"Wait for the credit-card-autofill section is spotlighted.");
is(doc.querySelector(".spotlight").getAttribute("data-subcategory"), "credit-card-autofill",
"The credit-card-autofill section is spotlighted.");
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
add_task(async function test_form_autofill_section() {
let prefs = await openPreferencesViaOpenPreferencesAPI("privacy-form-autofill", {leaveOpen: true});
is(prefs.selectedPane, "panePrivacy", "Privacy pane is selected by default");
let doc = gBrowser.contentDocument;
is(doc.location.hash, "#privacy", "The subcategory should be removed from the URI");
await TestUtils.waitForCondition(() => doc.querySelector(".spotlight"),
"Wait for the form-autofill section is spotlighted.");
is(doc.querySelector(".spotlight").getAttribute("data-subcategory"), "form-autofill",
"The form-autofill section is spotlighted.");
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
add_task(async function test_change_cookie_settings() {
let prefs = await openPreferencesViaOpenPreferencesAPI("privacy-trackingprotection", {leaveOpen: true});
is(prefs.selectedPane, "panePrivacy", "Privacy pane is selected by default");
let doc = gBrowser.contentDocument;
is(doc.location.hash, "#privacy", "The subcategory should be removed from the URI");
await TestUtils.waitForCondition(() => doc.querySelector(".spotlight"),
"Wait for the content-blocking section to be spotlighted.");
is(doc.querySelector(".spotlight").getAttribute("data-subcategory"), "trackingprotection",
"The tracking-protection section is spotlighted.");
doc.defaultView.spotlight(null);
is(doc.querySelector(".spotlight"), null,
"The spotlighted section is cleared.");
BrowserTestUtils.removeTab(gBrowser.selectedTab);
}); });

Просмотреть файл

@ -440,7 +440,3 @@ var gPermissionManager = {
column.setAttribute("data-last-sortDirection", sortDirection); column.setAttribute("data-last-sortDirection", sortDirection);
}, },
}; };
function initWithParams(params) {
gPermissionManager.init(params);
}

Просмотреть файл

@ -9,7 +9,6 @@
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?> <?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?>
<window id="PermissionsDialog" <window id="PermissionsDialog"
windowtype="Browser:Permissions"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
data-l10n-id="permissions-window" data-l10n-id="permissions-window"
data-l10n-attrs="title, style" data-l10n-attrs="title, style"