diff --git a/browser/base/content/test/siteProtections/.eslintrc.js b/browser/base/content/test/siteProtections/.eslintrc.js new file mode 100644 index 000000000000..b1c842d8a6db --- /dev/null +++ b/browser/base/content/test/siteProtections/.eslintrc.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = { + "extends": [ + "plugin:mozilla/browser-test" + ] +}; diff --git a/browser/base/content/test/siteProtections/browser.ini b/browser/base/content/test/siteProtections/browser.ini new file mode 100644 index 000000000000..8a6f5b37586e --- /dev/null +++ b/browser/base/content/test/siteProtections/browser.ini @@ -0,0 +1,5 @@ +[DEFAULT] +support-files = + head.js + +[browser_protections_UI.js] diff --git a/browser/base/content/test/siteProtections/browser_protections_UI.js b/browser/base/content/test/siteProtections/browser_protections_UI.js new file mode 100644 index 000000000000..dcc60ad937a5 --- /dev/null +++ b/browser/base/content/test/siteProtections/browser_protections_UI.js @@ -0,0 +1,20 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* Basic UI tests for the protections panel */ + +add_task(async function testToggleSwitch() { + let uri = "http://example.com"; + let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, uri); + await openProtectionsPanel(); + ok(gProtectionsHandler._protectionsPopupTPSwitch.hasAttribute("enabled"), "TP Switch should be enabled"); + let popuphiddenPromise = BrowserTestUtils.waitForEvent(protectionsPopup, "popuphidden"); + let browserLoadedPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser); + gProtectionsHandler._protectionsPopupTPSwitch.click(); + await popuphiddenPromise; + await browserLoadedPromise; + await openProtectionsPanel(); + ok(!gProtectionsHandler._protectionsPopupTPSwitch.hasAttribute("enabled"), "TP Switch should be disabled"); + BrowserTestUtils.removeTab(tab); + Services.perms.remove(uri, "trackingprotection"); +}); diff --git a/browser/base/content/test/siteProtections/head.js b/browser/base/content/test/siteProtections/head.js new file mode 100644 index 000000000000..0346fc15a9af --- /dev/null +++ b/browser/base/content/test/siteProtections/head.js @@ -0,0 +1,11 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +var protectionsPopup = document.getElementById("protections-popup"); + +async function openProtectionsPanel() { + let popupShownPromise = BrowserTestUtils.waitForEvent(protectionsPopup, "popupshown"); + let identityBox = document.getElementById("identity-box"); + EventUtils.synthesizeMouseAtCenter(identityBox, { metaKey: true }); + await popupShownPromise; +} diff --git a/browser/base/moz.build b/browser/base/moz.build index 9dc2c7b7181a..10132f6c73a9 100644 --- a/browser/base/moz.build +++ b/browser/base/moz.build @@ -46,6 +46,7 @@ BROWSER_CHROME_MANIFESTS += [ 'content/test/sanitize/browser.ini', 'content/test/sidebar/browser.ini', 'content/test/siteIdentity/browser.ini', + 'content/test/siteProtections/browser.ini', 'content/test/static/browser.ini', 'content/test/statuspanel/browser.ini', 'content/test/sync/browser.ini',