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 @@