From 24c49f147328cf53f92a5266e7fce98fe914dba2 Mon Sep 17 00:00:00 2001 From: Paolo Amadini Date: Sun, 23 Dec 2018 20:52:15 +0000 Subject: [PATCH] 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 --- browser/base/content/browser.js | 33 +------ browser/components/preferences/containers.xul | 1 - .../preferences/in-content/privacy.xul | 2 +- .../in-content/tests/browser_spotlight.js | 95 +++++++------------ browser/components/preferences/permissions.js | 4 - .../components/preferences/permissions.xul | 1 - 6 files changed, 35 insertions(+), 101 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 27d29a127444..1b96ca26d9ac 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -800,38 +800,7 @@ var gPopupBlockerObserver = { }, editPopupSettings() { - let prefillValue = ""; - 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); + openPreferences("privacy-permissions-block-popups"); }, dontShowMessage() { diff --git a/browser/components/preferences/containers.xul b/browser/components/preferences/containers.xul index 2918ce2e1081..24bd97b611bb 100644 --- a/browser/components/preferences/containers.xul +++ b/browser/components/preferences/containers.xul @@ -8,7 +8,6 @@ - + doc.querySelector(".spotlight"), - "Wait for the reports section is spotlighted."); - is(doc.querySelector(".spotlight").getAttribute("data-subcategory"), "reports", - "The reports section is spotlighted."); - BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); + let prefs = + await openPreferencesViaOpenPreferencesAPI(arg, { leaveOpen: true }); + is(prefs.selectedPane, expectedPane, "The right pane is selected"); + let doc = gBrowser.contentDocument; + is(doc.location.hash, expectedHash, + "The subcategory should be removed from the URI"); + await TestUtils.waitForCondition(() => doc.querySelector(".spotlight"), + "Wait for the spotlight"); + is(doc.querySelector(".spotlight").getAttribute("data-subcategory"), + expectedSubcategory, "The right subcategory is spotlighted"); -add_task(async function test_address_autofill_section() { - let prefs = await openPreferencesViaOpenPreferencesAPI("privacy-address-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 address-autofill section is spotlighted."); - is(doc.querySelector(".spotlight").getAttribute("data-subcategory"), "address-autofill", - "The address-autofill section is spotlighted."); - BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); + doc.defaultView.spotlight(null); + is(doc.querySelector(".spotlight"), null, + "The spotlighted section is cleared"); -add_task(async function test_credit_card_autofill_section() { - if (!Services.prefs.getBoolPref("extensions.formautofill.creditCards.available")) { - return; + BrowserTestUtils.removeTab(gBrowser.selectedTab); } - 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); }); diff --git a/browser/components/preferences/permissions.js b/browser/components/preferences/permissions.js index 01a3cf96d079..ba6413dac694 100644 --- a/browser/components/preferences/permissions.js +++ b/browser/components/preferences/permissions.js @@ -440,7 +440,3 @@ var gPermissionManager = { column.setAttribute("data-last-sortDirection", sortDirection); }, }; - -function initWithParams(params) { - gPermissionManager.init(params); -} diff --git a/browser/components/preferences/permissions.xul b/browser/components/preferences/permissions.xul index a00befaa583d..ed0bcc4d2e4e 100644 --- a/browser/components/preferences/permissions.xul +++ b/browser/components/preferences/permissions.xul @@ -9,7 +9,6 @@