From 80149d9771d1cb480b889e08130f2f6ffb9a3556 Mon Sep 17 00:00:00 2001 From: Daniel Varga Date: Wed, 5 Jun 2019 02:48:37 +0300 Subject: [PATCH] Backed out 4 changesets (bug 1551902) for browser-chrome failure at browser/base/content/test/trackingUI/browser_trackingUI_cryptominers.js. On a CLOSED TREE Backed out changeset 762ba28bc409 (bug 1551902) Backed out changeset 4c8afa61cbec (bug 1551902) Backed out changeset 212cfe3c1893 (bug 1551902) Backed out changeset 29cbb321a610 (bug 1551902) --- .../base/content/browser-contentblocking.js | 27 ++----- .../base/content/browser-siteProtections.js | 70 ------------------ .../content/test/siteProtections/.eslintrc.js | 7 -- .../content/test/siteProtections/browser.ini | 5 -- .../siteProtections/browser_protections_UI.js | 19 ----- .../base/content/test/siteProtections/head.js | 11 --- browser/base/moz.build | 1 - .../content/protectionsPanel.inc.xul | 19 ++--- .../themes/shared/controlcenter/panel.inc.css | 71 +------------------ 9 files changed, 11 insertions(+), 219 deletions(-) delete mode 100644 browser/base/content/test/siteProtections/.eslintrc.js delete mode 100644 browser/base/content/test/siteProtections/browser.ini delete mode 100644 browser/base/content/test/siteProtections/browser_protections_UI.js delete mode 100644 browser/base/content/test/siteProtections/head.js diff --git a/browser/base/content/browser-contentblocking.js b/browser/base/content/browser-contentblocking.js index 30bfb3adf777..353d0a9ac6c5 100644 --- a/browser/base/content/browser-contentblocking.js +++ b/browser/base/content/browser-contentblocking.js @@ -816,11 +816,6 @@ var ContentBlocking = { return this.identityPopup = document.getElementById("identity-popup"); }, - get protectionsPopup() { - delete this.protectionsPopup; - return this.protectionsPopup = document.getElementById("protections-popup"); - }, - strings: { get appMenuTitle() { delete this.appMenuTitle; @@ -1093,18 +1088,6 @@ var ContentBlocking = { if (!baseURI) { return; } - - let isBrowserPrivate = PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser); - - // Check whether the user has added an exception for this site. - let type = isBrowserPrivate ? "trackingprotection-pb" : "trackingprotection"; - let hasException = Services.perms.testExactPermission(baseURI, type) == - Services.perms.ALLOW_ACTION; - - this.content.toggleAttribute("hasException", hasException); - this.protectionsPopup.toggleAttribute("hasException", hasException); - this.iconBox.toggleAttribute("hasException", hasException); - // Add to telemetry per page load as a baseline measurement. this.fingerprintersHistogramAdd("pageLoad"); this.cryptominersHistogramAdd("pageLoad"); @@ -1142,7 +1125,7 @@ var ContentBlocking = { let isBrowserPrivate = PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser); // Check whether the user has added an exception for this site. - let type = isBrowserPrivate ? "trackingprotection-pb" : "trackingprotection"; + let type = isBrowserPrivate ? "trackingprotection-pb" : "trackingprotection"; let hasException = Services.perms.testExactPermission(baseURI, type) == Services.perms.ALLOW_ACTION; @@ -1174,11 +1157,9 @@ var ContentBlocking = { // occurs on the page. Note that merely allowing the loading of content that // we could have blocked does not trigger the appearance of the shield. // This state will be overriden later if there's an exception set for this site. - for (let elt of [this.content, this.protectionsPopup]) { - elt.toggleAttribute("detected", anyDetected); - elt.toggleAttribute("blocking", anyBlocking); - elt.toggleAttribute("hasException", hasException); - } + this.content.toggleAttribute("detected", anyDetected); + this.content.toggleAttribute("blocking", anyBlocking); + this.content.toggleAttribute("hasException", hasException); this.iconBox.toggleAttribute("active", anyBlocking); this.iconBox.toggleAttribute("hasException", hasException); diff --git a/browser/base/content/browser-siteProtections.js b/browser/base/content/browser-siteProtections.js index 8b3839f24360..1a949169511c 100644 --- a/browser/base/content/browser-siteProtections.js +++ b/browser/base/content/browser-siteProtections.js @@ -22,11 +22,6 @@ var gProtectionsHandler = { return this._protectionsPopupMainViewHeaderLabel = document.getElementById("protections-popup-mainView-panel-header-span"); }, - get _protectionsPopupTPSwitch() { - delete this._protectionsPopupTPSwitch; - return this._protectionsPopupTPSwitch = - document.getElementById("protections-popup-tp-switch"); - }, handleProtectionsButtonEvent(event) { event.stopPropagation(); @@ -50,77 +45,12 @@ var gProtectionsHandler = { }).catch(Cu.reportError); }, - onPopupShown(event) { - if (event.target == this._protectionsPopup) { - window.addEventListener("focus", this, true); - } - }, - - onPopupHidden(event) { - if (event.target == this._protectionsPopup) { - window.removeEventListener("focus", this, true); - this._protectionsPopup.removeAttribute("open"); - } - }, - - handleEvent(event) { - let elem = document.activeElement; - let position = elem.compareDocumentPosition(this._protectionsPopup); - - if (!(position & (Node.DOCUMENT_POSITION_CONTAINS | - Node.DOCUMENT_POSITION_CONTAINED_BY)) && - !this._protectionsPopup.hasAttribute("noautohide")) { - // Hide the panel when focusing an element that is - // neither an ancestor nor descendant unless the panel has - // @noautohide (e.g. for a tour). - PanelMultiView.hidePopup(this._protectionsPopup); - } - }, - refreshProtectionsPopup() { - // Refresh the state of the TP toggle switch. - this._protectionsPopupTPSwitch.toggleAttribute("enabled", - !this._protectionsPopup.hasAttribute("hasException")); - let host = gIdentityHandler.getHostForDisplay(); // Push the appropriate strings out to the UI. this._protectionsPopupMainViewHeaderLabel.textContent = // gNavigatorBundle.getFormattedString("protections.header", [host]); `Tracking Protections for ${host}`; - - let currentlyEnabled = - !this._protectionsPopup.hasAttribute("hasException"); - - this._protectionsPopupTPSwitch.toggleAttribute("enabled", currentlyEnabled); - }, - - async onTPSwitchCommand(event) { - // When the switch is clicked, we wait 500ms and then disable/enable - // protections, causing the page to refresh, and close the popup. - // We need to ensure we don't handle more clicks during the 500ms delay, - // so we keep track of state and return early if needed. - if (this._TPSwitchCommanding) { - return; - } - - this._TPSwitchCommanding = true; - - let currentlyEnabled = - !this._protectionsPopup.hasAttribute("hasException"); - - this._protectionsPopupTPSwitch.toggleAttribute("enabled", !currentlyEnabled); - await new Promise((resolve) => setTimeout(resolve, 500)); - - if (currentlyEnabled) { - ContentBlocking.disableForCurrentPage(); - gIdentityHandler.recordClick("unblock"); - } else { - ContentBlocking.enableForCurrentPage(); - gIdentityHandler.recordClick("block"); - } - - PanelMultiView.hidePopup(this._protectionsPopup); - delete this._TPSwitchCommanding; }, }; diff --git a/browser/base/content/test/siteProtections/.eslintrc.js b/browser/base/content/test/siteProtections/.eslintrc.js deleted file mode 100644 index b1c842d8a6db..000000000000 --- a/browser/base/content/test/siteProtections/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -"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 deleted file mode 100644 index 8a6f5b37586e..000000000000 --- a/browser/base/content/test/siteProtections/browser.ini +++ /dev/null @@ -1,5 +0,0 @@ -[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 deleted file mode 100644 index 2b809e7ec78e..000000000000 --- a/browser/base/content/test/siteProtections/browser_protections_UI.js +++ /dev/null @@ -1,19 +0,0 @@ -/* 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 tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "https://example.com"); - 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"); - Services.perms.remove(ContentBlocking._baseURIForChannelClassifier, "trackingprotection"); - BrowserTestUtils.removeTab(tab); -}); diff --git a/browser/base/content/test/siteProtections/head.js b/browser/base/content/test/siteProtections/head.js deleted file mode 100644 index 0346fc15a9af..000000000000 --- a/browser/base/content/test/siteProtections/head.js +++ /dev/null @@ -1,11 +0,0 @@ -/* 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 10132f6c73a9..9dc2c7b7181a 100644 --- a/browser/base/moz.build +++ b/browser/base/moz.build @@ -46,7 +46,6 @@ 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', diff --git a/browser/components/controlcenter/content/protectionsPanel.inc.xul b/browser/components/controlcenter/content/protectionsPanel.inc.xul index 427a6186219c..af4db05c1678 100644 --- a/browser/components/controlcenter/content/protectionsPanel.inc.xul +++ b/browser/components/controlcenter/content/protectionsPanel.inc.xul @@ -7,8 +7,6 @@ hidden="true" photon="true" role="alertdialog" - onpopupshown="gProtectionsHandler.onPopupShown(event);" - onpopuphidden="gProtectionsHandler.onPopupHidden(event);" orient="vertical"> - - - - - - - - - - + + + diff --git a/browser/themes/shared/controlcenter/panel.inc.css b/browser/themes/shared/controlcenter/panel.inc.css index 89371cb76d70..186c4f4510d1 100644 --- a/browser/themes/shared/controlcenter/panel.inc.css +++ b/browser/themes/shared/controlcenter/panel.inc.css @@ -64,7 +64,8 @@ /* Make sure hidden elements don't accidentally become visible from one of the above selectors (see Bug 1194258) */ -#identity-popup [hidden] { +#identity-popup [hidden], +#protections-popup [hidden] { display: none !important; } @@ -781,71 +782,3 @@ description#identity-popup-content-verifier, .identity-popup-permission-remove-button:not(:-moz-focusring):hover:active { opacity: 0.8; } - -#protections-popup-tp-switch-label-box > label { - display: none; -} - -#protections-popup:not([hasException]) #protections-popup-tp-switch-on-header, -#protections-popup:not([hasException]) #protections-popup-tp-switch-breakage-link, -#protections-popup[hasException] #protections-popup-tp-switch-off-header { - display: unset; -} - -#protections-popup-tp-switch-section { - padding: 4px; -} - -#protections-popup-tp-switch-label-box, -#protections-popup-tp-switch-box { - padding: 4px 1em; - min-height: 40px; - -moz-box-pack: center; -} - -#protections-popup-tp-switch-on-header, -#protections-popup-tp-switch-off-header { - font-weight: 600; -} - -#protections-popup-tp-switch { - -moz-appearance: none; - box-sizing: border-box; - min-width: 26px; - border-radius: 10px; - background-color: var(--arrowpanel-dimmed-even-further); - border: 1px solid transparent; - margin-top: 4px; - margin-bottom: 4px; - margin-inline-start: 1px; - margin-inline-end: 7px; - padding: 2px; - transition: padding .2s ease; -} - -#protections-popup-tp-switch::before { - position: relative; - display: block; - content: ""; - width: 10px; - height: 10px; - border-radius: 10px; - background: white; -} - -#protections-popup-tp-switch[enabled] { - background-color: #0a84ff; - border: 1px solid #0a84ff; - /* Push the toggle to the right. */ - padding-inline-start: 12px; -} - -#protections-popup-tp-switch:hover, -#protections-popup-tp-switch:-moz-focusring { - border: 1px solid var(--panel-separator-color); -} - -#protections-popup-tp-switch[enabled=true]:hover, -#protections-popup-tp-switch[enabled=true]:-moz-focusring { - background-color: #45a1ff; -}