Backed out changeset 5455671d51b2 (bug 1646860) for failures on browser_pioneer_ui.js. CLOSED TREE

This commit is contained in:
Csoregi Natalia 2020-07-07 10:07:34 +03:00
Родитель 0d0251640f
Коммит 9f0cf20b98
3 изменённых файлов: 6 добавлений и 134 удалений

Просмотреть файл

@ -2152,52 +2152,6 @@ BrowserGlue.prototype = {
_checkPioneerPref();
},
_monitorPioneerStudies() {
const STUDY_ADDON_COLLECTION_KEY = "pioneer-study-addons";
const PREF_PIONEER_NEW_STUDIES_AVAILABLE =
"toolkit.telemetry.pioneer-new-studies-available";
const _badgeIcon = async () => {
for (let win of Services.wm.getEnumerator("navigator:browser")) {
win.document
.getElementById("pioneer-button")
.querySelector(".toolbarbutton-badge")
.classList.add("feature-callout");
}
};
const windowListener = {
onOpenWindow(xulWindow) {
const win = xulWindow.docShell.domWindow;
win.addEventListener("load", () => {
const pioneerButton = win.document.getElementById("pioneer-button");
if (pioneerButton) {
const badge = pioneerButton.querySelector(".toolbarbutton-badge");
if (
Services.prefs.getBoolPref(
PREF_PIONEER_NEW_STUDIES_AVAILABLE,
false
)
) {
badge.classList.add("feature-callout");
} else {
badge.classList.remove("feature-callout");
}
}
});
},
onCloseWindow() {},
};
Services.prefs.addObserver(PREF_PIONEER_NEW_STUDIES_AVAILABLE, _badgeIcon);
RemoteSettings(STUDY_ADDON_COLLECTION_KEY).on("sync", async event => {
Services.prefs.setBoolPref(PREF_PIONEER_NEW_STUDIES_AVAILABLE, true);
});
Services.wm.addListener(windowListener);
},
_showNewInstallModal() {
// Allow other observers of the same topic to run while we open the dialog.
Services.tm.dispatchToMainThread(() => {
@ -2289,7 +2243,6 @@ BrowserGlue.prototype = {
this._monitorWebcompatReporterPref();
this._monitorHTTPSOnlyPref();
this._monitorPioneerPref();
this._monitorPioneerStudies();
let pService = Cc["@mozilla.org/toolkit/profile-service;1"].getService(
Ci.nsIToolkitProfileService

Просмотреть файл

@ -33,8 +33,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
});
const PREF_PIONEER_ID = "toolkit.telemetry.pioneerId";
const PREF_PIONEER_NEW_STUDIES_AVAILABLE =
"toolkit.telemetry.pioneer-new-studies-available";
/**
* This is the Remote Settings key that we use to get the list of available studies.
@ -262,23 +260,9 @@ async function setup(cachedAddons) {
});
}
function removeBadge() {
Services.prefs.setBoolPref(PREF_PIONEER_NEW_STUDIES_AVAILABLE, false);
for (let win of Services.wm.getEnumerator("navigator:browser")) {
const badge = win.document
.getElementById("pioneer-button")
.querySelector(".toolbarbutton-badge");
badge.classList.remove("feature-callout");
}
}
document.addEventListener("DOMContentLoaded", async domEvent => {
showEnrollmentStatus();
document.addEventListener("focus", removeBadge);
removeBadge();
let cachedAddons;
if (Cu.isInAutomation) {
let testCachedAddons = Services.prefs.getStringPref(

Просмотреть файл

@ -9,8 +9,6 @@
"use strict";
const PREF_PIONEER_ID = "toolkit.telemetry.pioneerId";
const PREF_PIONEER_NEW_STUDIES_AVAILABLE =
"toolkit.telemetry.pioneer-new-studies-available";
const PREF_CACHED_ADDONS = "toolkit.pioneer.testCachedAddons";
const PREF_TEST_ADDON_INSTALLED = "toolkit.pioneer.testAddonInstalled";
@ -54,12 +52,7 @@ const CACHED_ADDONS = [
},
];
const waitForAnimationFrame = () =>
new Promise(resolve => {
content.window.requestAnimationFrame(resolve);
});
add_task(async function testAboutPage() {
add_task(async function() {
const cachedAddons = JSON.stringify(CACHED_ADDONS);
await SpecialPowers.pushPrefEnv({
set: [
@ -74,6 +67,11 @@ add_task(async function testAboutPage() {
gBrowser,
});
const waitForAnimationFrame = () =>
new Promise(resolve => {
content.window.requestAnimationFrame(resolve);
});
const beforePref = Services.prefs.getStringPref(PREF_PIONEER_ID, null);
ok(beforePref === null, "before enrollment, Pioneer pref is null.");
@ -139,66 +137,3 @@ add_task(async function testAboutPage() {
await BrowserTestUtils.removeTab(tab);
});
add_task(async function testPioneerBadge() {
await SpecialPowers.pushPrefEnv({
set: [[PREF_PIONEER_NEW_STUDIES_AVAILABLE, true]],
clear: [
[PREF_PIONEER_NEW_STUDIES_AVAILABLE, false],
[PREF_PIONEER_ID, ""],
],
});
let pioneerTab = await BrowserTestUtils.openNewForegroundTab({
url: "about:pioneer",
gBrowser,
});
const enrollmentButton = content.document.getElementById("enrollment-button");
enrollmentButton.click();
let blankTab = await BrowserTestUtils.openNewForegroundTab({
url: "about:home",
gBrowser,
});
Services.prefs.setBoolPref(PREF_PIONEER_NEW_STUDIES_AVAILABLE, true);
const toolbarButton = document.getElementById("pioneer-button");
const toolbarBadge = toolbarButton.querySelector(".toolbarbutton-badge");
ok(
toolbarBadge.classList.contains("feature-callout"),
"When pref is true, Pioneer toolbar button is called out in the current window."
);
toolbarButton.click();
ok(
!toolbarBadge.classList.contains("feature-callout"),
"When about:pioneer toolbar button is pressed, call-out is removed."
);
Services.prefs.setBoolPref(PREF_PIONEER_NEW_STUDIES_AVAILABLE, true);
const newWin = await BrowserTestUtils.openNewBrowserWindow();
const newToolbarButton = document.getElementById("pioneer-button");
const newToolbarBadge = toolbarButton.querySelector(".toolbarbutton-badge");
ok(
newToolbarBadge.classList.contains("feature-callout"),
"When pref is true, Pioneer toolbar button is called out in a new window."
);
newToolbarButton.click();
ok(
!newToolbarBadge.classList.contains("feature-callout"),
"When about:pioneer toolbar button is pressed, call-out is removed."
);
await BrowserTestUtils.closeWindow(newWin);
await BrowserTestUtils.removeTab(pioneerTab);
await BrowserTestUtils.removeTab(blankTab);
});