From a024104573bed856568b19dc0960d2d299a33f1a Mon Sep 17 00:00:00 2001 From: Narcis Beleuzu Date: Fri, 17 Jan 2020 19:18:49 +0200 Subject: [PATCH] Backed out 2 changesets (bug 1609037, bug 1608320) for bc failures on browser_cleanFlow.js . CLOSED TREE Backed out changeset 44539f8e0cea (bug 1609037) Backed out changeset 3dddea4c5d73 (bug 1608320) --- browser/app/profile/firefox.js | 6 -- browser/extensions/doh-rollout/background.js | 42 +++---------- .../doh-rollout/experiments/doorhanger/api.js | 62 +------------------ .../doh-rollout/test/browser/browser.ini | 1 - .../test/browser/browser_cleanFlow.js | 3 - .../browser/browser_doorhangerUserReject.js | 3 - .../browser/browser_doorhanger_newProfile.js | 34 ---------- .../test/browser/browser_userInterference.js | 3 - .../doh-rollout/test/browser/head.js | 12 ---- 9 files changed, 9 insertions(+), 157 deletions(-) delete mode 100644 browser/extensions/doh-rollout/test/browser/browser_doorhanger_newProfile.js diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index f038f1fc797b..97e31f4b9d67 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1825,12 +1825,6 @@ pref("extensions.screenshots.disabled", false); // disable uploading to the server. pref("extensions.screenshots.upload-disabled", false); -// DoH Rollout: the earliest date of profile creation for which we don't need -// to show the doorhanger. This is when the version of the privacy statement -// that includes DoH went live - Oct 31, 2019. This has to be a string because -// the number is outside the signed 32-bit integer range. -pref("doh-rollout.profileCreationThreshold", "1572476400000"); - // URL for Learn More link for browser error logging in preferences pref("browser.chrome.errorReporter.infoURL", "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/nightly-error-collection"); diff --git a/browser/extensions/doh-rollout/background.js b/browser/extensions/doh-rollout/background.js index eb0659299e26..f034b7281688 100644 --- a/browser/extensions/doh-rollout/background.js +++ b/browser/extensions/doh-rollout/background.js @@ -190,9 +190,15 @@ const stateManager = { }, async showDoorhanger() { - rollout.addDoorhangerListeners(); + browser.experiments.doorhanger.onDoorhangerAccept.addListener( + rollout.doorhangerAcceptListener + ); - let doorhangerShown = await browser.experiments.doorhanger.show({ + browser.experiments.doorhanger.onDoorhangerDecline.addListener( + rollout.doorhangerDeclineListener + ); + + await browser.experiments.doorhanger.show({ name: browser.i18n.getMessage("doorhangerName"), text: "<> " + browser.i18n.getMessage("doorhangerBody"), okLabel: browser.i18n.getMessage("doorhangerButtonOk"), @@ -202,16 +208,6 @@ const stateManager = { "doorhangerButtonCancelAccessKey" ), }); - - if (!doorhangerShown) { - // The profile was created after the go-live date of the privacy statement - // that included DoH. Treat it as accepted. - log("Profile is new, doorhanger not shown."); - await stateManager.setState("UIOk"); - await stateManager.rememberDoorhangerDecision("NewProfile"); - await stateManager.rememberDoorhangerShown(); - rollout.removeDoorhangerListeners(); - } }, }; @@ -227,32 +223,11 @@ const rollout = { return this._isTesting; }, - addDoorhangerListeners() { - browser.experiments.doorhanger.onDoorhangerAccept.addListener( - rollout.doorhangerAcceptListener - ); - - browser.experiments.doorhanger.onDoorhangerDecline.addListener( - rollout.doorhangerDeclineListener - ); - }, - - removeDoorhangerListeners() { - browser.experiments.doorhanger.onDoorhangerAccept.removeListener( - rollout.doorhangerAcceptListener - ); - - browser.experiments.doorhanger.onDoorhangerDecline.removeListener( - rollout.doorhangerDeclineListener - ); - }, - async doorhangerAcceptListener(tabId) { log("Doorhanger accepted on tab", tabId); await stateManager.setState("UIOk"); await stateManager.rememberDoorhangerDecision("UIOk"); await stateManager.rememberDoorhangerShown(); - rollout.removeDoorhangerListeners(); }, async doorhangerDeclineListener(tabId) { @@ -264,7 +239,6 @@ const rollout = { browser.experiments.heuristics.sendHeuristicsPing("disable_doh", results); await stateManager.rememberDisableHeuristics(); await stateManager.rememberDoorhangerShown(); - rollout.removeDoorhangerListeners(); }, async heuristics(evaluateReason) { diff --git a/browser/extensions/doh-rollout/experiments/doorhanger/api.js b/browser/extensions/doh-rollout/experiments/doorhanger/api.js index d792e38c1f36..efdcb05a9b28 100644 --- a/browser/extensions/doh-rollout/experiments/doorhanger/api.js +++ b/browser/extensions/doh-rollout/experiments/doorhanger/api.js @@ -7,8 +7,6 @@ /* global BrowserWindowTracker, ExtensionCommon, ExtensionAPI */ ChromeUtils.import("resource://gre/modules/Services.jsm", this); -ChromeUtils.import("resource://gre/modules/Preferences.jsm", this); -ChromeUtils.import("resource:///modules/EveryWindow.jsm", this); var { EventManager, EventEmitter } = ExtensionCommon; const { @@ -99,65 +97,7 @@ this.doorhanger = class doorhanger extends ExtensionAPI { experiments: { doorhanger: { async show(properties) { - let profileAge = await ChromeUtils.import( - "resource://gre/modules/ProfileAge.jsm", - {} - ).ProfileAge(); - - let creationDate = await profileAge.created; - let firstUse = await profileAge.firstUse; - let resetDate = await profileAge.reset; - let profileDate = resetDate || firstUse || creationDate; - - // We only need to show the doorhanger to users who have not been - // shown a version of the privacy statement that includes DoH at - // first-run. - let profileCreationThreshold = parseInt( - Preferences.get("doh-rollout.profileCreationThreshold") - ); - if ( - !isNaN(profileCreationThreshold) && - profileDate > profileCreationThreshold - ) { - return false; - } - - // Show the doorhanger next time there's a top-level location change. - let tabsProgressListener = { - onLocationChange( - aBrowser, - aWebProgress, - aRequest, - aLocationURI, - aFlags - ) { - let topWindow = getMostRecentBrowserWindow(); - // Filter out history.push/pop and subframes. - if ( - aBrowser != topWindow.gBrowser.selectedBrowser || - aFlags & - Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT || - !aWebProgress.isTopLevel - ) { - return; - } - doorhangerEventEmitter.emitShow(properties); - EveryWindow.unregisterCallback("doh-rollout"); - }, - }; - EveryWindow.registerCallback( - "doh-rollout", - win => { - win.gBrowser.addTabsProgressListener(tabsProgressListener); - }, - (win, closing) => { - if (closing) { - return; - } - win.gBrowser.removeTabsProgressListener(tabsProgressListener); - } - ); - return true; + await doorhangerEventEmitter.emitShow(properties); }, onDoorhangerAccept: new EventManager({ context, diff --git a/browser/extensions/doh-rollout/test/browser/browser.ini b/browser/extensions/doh-rollout/test/browser/browser.ini index 4a407a991922..35af1889d00c 100644 --- a/browser/extensions/doh-rollout/test/browser/browser.ini +++ b/browser/extensions/doh-rollout/test/browser/browser.ini @@ -5,7 +5,6 @@ skip-if = debug # Bug 1548006 - reloading an addon upsets the leak checker. [browser_cleanFlow.js] [browser_dirtyEnable.js] [browser_doorhangerUserReject.js] -[browser_doorhanger_newProfile.js] [browser_policyOverride.js] skip-if = (!debug && bits == 64) #Bug 1605297 [browser_userInterference.js] diff --git a/browser/extensions/doh-rollout/test/browser/browser_cleanFlow.js b/browser/extensions/doh-rollout/test/browser/browser_cleanFlow.js index 162f550bb65f..3bdd9d9cb47a 100644 --- a/browser/extensions/doh-rollout/test/browser/browser_cleanFlow.js +++ b/browser/extensions/doh-rollout/test/browser/browser_cleanFlow.js @@ -13,7 +13,6 @@ add_task(async function testCleanFlow() { }); is(Preferences.get(prefs.DOH_SELF_ENABLED_PREF), true, "Breadcrumb saved."); - let tab = BrowserTestUtils.addTab(gBrowser, EXAMPLE_URL); let panel = await promise; is( Preferences.get(prefs.DOH_DOORHANGER_SHOWN_PREF), @@ -49,8 +48,6 @@ add_task(async function testCleanFlow() { "Breadcrumb not cleared." ); - BrowserTestUtils.removeTab(tab); - // Change the environment to failing and simulate a network change. setFailingHeuristics(); simulateNetworkChange(); diff --git a/browser/extensions/doh-rollout/test/browser/browser_doorhangerUserReject.js b/browser/extensions/doh-rollout/test/browser/browser_doorhangerUserReject.js index f847c0f47321..cec34a2ef1a0 100644 --- a/browser/extensions/doh-rollout/test/browser/browser_doorhangerUserReject.js +++ b/browser/extensions/doh-rollout/test/browser/browser_doorhangerUserReject.js @@ -13,7 +13,6 @@ add_task(async function testDoorhangerUserReject() { }); is(Preferences.get(prefs.DOH_SELF_ENABLED_PREF), true, "Breadcrumb saved."); - let tab = BrowserTestUtils.addTab(gBrowser, EXAMPLE_URL); let panel = await promise; is( Preferences.get(prefs.DOH_DOORHANGER_SHOWN_PREF), @@ -50,8 +49,6 @@ add_task(async function testDoorhangerUserReject() { "Breadcrumb cleared." ); - BrowserTestUtils.removeTab(tab); - await ensureTRRMode(5); checkHeuristicsTelemetry("disable_doh", "doorhangerDecline"); diff --git a/browser/extensions/doh-rollout/test/browser/browser_doorhanger_newProfile.js b/browser/extensions/doh-rollout/test/browser/browser_doorhanger_newProfile.js deleted file mode 100644 index a2b3ba29b49c..000000000000 --- a/browser/extensions/doh-rollout/test/browser/browser_doorhanger_newProfile.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; - -add_task(setup); - -add_task(async function testDoorhanger() { - Preferences.reset(prefs.PROFILE_CREATION_THRESHOLD_PREF); - // Set up a passing environment and enable DoH. - setPassingHeuristics(); - Preferences.set(prefs.DOH_ENABLED_PREF, true); - - await BrowserTestUtils.waitForCondition(() => { - return Preferences.get(prefs.DOH_SELF_ENABLED_PREF); - }); - is(Preferences.get(prefs.DOH_SELF_ENABLED_PREF), true, "Breadcrumb saved."); - - await BrowserTestUtils.waitForCondition(() => { - return Preferences.get(prefs.DOH_DOORHANGER_SHOWN_PREF); - }); - is( - Preferences.get(prefs.DOH_DOORHANGER_SHOWN_PREF), - true, - "Doorhanger shown pref saved." - ); - is( - Preferences.get(prefs.DOH_DOORHANGER_USER_DECISION_PREF), - "NewProfile", - "Doorhanger decision saved." - ); - is( - Preferences.get(prefs.DOH_SELF_ENABLED_PREF), - true, - "Breadcrumb not cleared." - ); -}); diff --git a/browser/extensions/doh-rollout/test/browser/browser_userInterference.js b/browser/extensions/doh-rollout/test/browser/browser_userInterference.js index bf485e3ea64c..ee1103ddda48 100644 --- a/browser/extensions/doh-rollout/test/browser/browser_userInterference.js +++ b/browser/extensions/doh-rollout/test/browser/browser_userInterference.js @@ -13,7 +13,6 @@ add_task(async function testUserInterference() { }); is(Preferences.get(prefs.DOH_SELF_ENABLED_PREF), true, "Breadcrumb saved."); - let tab = BrowserTestUtils.addTab(gBrowser, EXAMPLE_URL); let panel = await promise; is( Preferences.get(prefs.DOH_DOORHANGER_SHOWN_PREF), @@ -42,8 +41,6 @@ add_task(async function testUserInterference() { "Doorhanger decision saved." ); - BrowserTestUtils.removeTab(tab); - await ensureTRRMode(2); checkHeuristicsTelemetry("enable_doh", "startup"); diff --git a/browser/extensions/doh-rollout/test/browser/head.js b/browser/extensions/doh-rollout/test/browser/head.js index a128690be0e7..cf3089d427b6 100644 --- a/browser/extensions/doh-rollout/test/browser/head.js +++ b/browser/extensions/doh-rollout/test/browser/head.js @@ -12,14 +12,8 @@ ChromeUtils.defineModuleGetter( "resource://gre/modules/Preferences.jsm" ); -const { CommonUtils } = ChromeUtils.import( - "resource://services-common/utils.js" -); - const ADDON_ID = "doh-rollout@mozilla.org"; -const EXAMPLE_URL = "https://example.com/"; - const prefs = { DOH_ENABLED_PREF: "doh-rollout.enabled", TRR_MODE_PREF: "network.trr.mode", @@ -33,7 +27,6 @@ const prefs = { DOH_BALROG_MIGRATION_PREF: "doh-rollout.balrog-migration-done", DOH_DEBUG_PREF: "doh-rollout.debug", MOCK_HEURISTICS_PREF: "doh-rollout.heuristics.mockValues", - PROFILE_CREATION_THRESHOLD_PREF: "doh-rollout.profileCreationThreshold", }; const fakePassingHeuristics = JSON.stringify({ @@ -66,11 +59,6 @@ async function setup() { Services.telemetry.canRecordExtended = true; Services.telemetry.clearEvents(); - // Set the profile creation threshold to very far in the future by defualt, - // so that we can test the doorhanger. browser_doorhanger_newProfile.js - // overrides this. - Preferences.set(prefs.PROFILE_CREATION_THRESHOLD_PREF, "99999999999999"); - registerCleanupFunction(async () => { Services.telemetry.canRecordExtended = oldCanRecord; Services.telemetry.clearEvents();