Bug 1354117 - fix telemetry and a number of tests that flip photon prefs, r=johannh

MozReview-Commit-ID: 7ynaIQm22eS

--HG--
extra : rebase_source : 703ceae16cbf521de2fa1689668c68f1f06f682a
This commit is contained in:
Gijs Kruitbosch 2017-08-01 20:15:48 +01:00
Родитель c4fb9878e0
Коммит 03a486b23d
11 изменённых файлов: 18 добавлений и 107 удалений

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

@ -807,7 +807,6 @@ exports['test button click'] = function*(assert) {
exports['test button icon set'] = function(assert) {
Cu.import("resource://gre/modules/Services.jsm");
Services.prefs.setBoolPref("browser.photon.structure.enabled", false);
const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
let loader = Loader(module);
@ -860,13 +859,11 @@ exports['test button icon set'] = function(assert) {
CustomizableUI.addWidgetToArea(widgetId, CustomizableUI.AREA_NAVBAR);
Cu.import("resource://gre/modules/Services.jsm");
Services.prefs.clearUserPref("browser.photon.structure.enabled");
loader.unload();
}
exports['test button icon set with only one option'] = function(assert) {
Cu.import("resource://gre/modules/Services.jsm");
Services.prefs.setBoolPref("browser.photon.structure.enabled", false);
const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
let loader = Loader(module);
@ -911,7 +908,6 @@ exports['test button icon set with only one option'] = function(assert) {
CustomizableUI.addWidgetToArea(widgetId, CustomizableUI.AREA_NAVBAR);
Cu.import("resource://gre/modules/Services.jsm");
Services.prefs.clearUserPref("browser.photon.structure.enabled");
loader.unload();
}

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

@ -65,15 +65,14 @@ var gSync = {
.sort((a, b) => a.name.localeCompare(b.name));
},
_generateNodeGetters(usePhoton) {
let prefix = usePhoton ? "appMenu-" : "PanelUI-";
_generateNodeGetters() {
for (let k of ["Status", "Avatar", "Label", "Container"]) {
let prop = "appMenu" + k;
let suffix = k.toLowerCase();
delete this[prop];
this.__defineGetter__(prop, function() {
delete this[prop];
return this[prop] = document.getElementById(prefix + "fxa-" + suffix);
return this[prop] = document.getElementById("appMenu-fxa-" + suffix);
});
}
},
@ -88,8 +87,6 @@ var gSync = {
this.updateAllUI(state);
}
}
this.maybeMoveSyncedTabsButton();
},
init() {
@ -102,14 +99,7 @@ var gSync = {
Services.obs.addObserver(this, topic, true);
}
// Use this getter not because 'lazy' but because of the observer,
// which lets us easily update our UI according to the pref flip
XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure",
"browser.photon.structure.enabled", (pref, old, newValue) => {
this._generateNodeGetters(newValue);
this._maybeUpdateUIState();
});
this._generateNodeGetters(this.gPhotonStructure);
this._generateNodeGetters();
// initial label for the sync buttons.
let broadcaster = document.getElementById("sync-status");
@ -548,28 +538,6 @@ var gSync = {
}
},
/* After we are initialized we perform a once-only check for the sync
button being in "customize purgatory" and if so, move it to the panel.
This is done primarily for profiles created before SyncedTabs landed,
where the button defaulted to being in that purgatory.
We use a preference to ensure we only do it once, so people can still
customize it away and have it stick.
*/
maybeMoveSyncedTabsButton() {
if (gPhotonStructure) {
return;
}
const prefName = "browser.migrated-sync-button";
let migrated = Services.prefs.getBoolPref(prefName, false);
if (migrated) {
return;
}
if (!CustomizableUI.getPlacementOfWidget("sync-button")) {
CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_PANEL);
}
Services.prefs.setBoolPref(prefName, true);
},
/* Update the tooltip for the sync-status broadcaster (which will update the
Sync Toolbar button and the Sync spinner in the FxA hamburger area.)
If Sync is configured, the tooltip is when the last sync occurred,

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

@ -82,10 +82,6 @@ const EXPECTED_APPMENU_SUBVIEW_REFLOWS = [
add_task(async function() {
await ensureNoPreloadedBrowser();
await SpecialPowers.pushPrefEnv({
set: [["browser.photon.structure.enabled", true]],
});
// First, open the appmenu.
await withReflowObserver(async function() {
let popupPositioned =

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

@ -52,8 +52,7 @@ add_task(async function test_ui_state_syncing() {
gSync.updateAllUI(state);
let prefix = gPhotonStructure ? "appMenu" : "PanelUI";
checkSyncNowButton(`${prefix}-fxa-icon`, true);
checkSyncNowButton("appMenu-fxa-icon", true);
checkSyncNowButton("PanelUI-remotetabs-syncnow", true);
// Be good citizens and remove the "syncing" state.
@ -146,11 +145,10 @@ add_task(async function test_FormatLastSyncDateMonthAgo() {
});
function checkPanelUIStatusBar({label, tooltip, fxastatus, avatarURL, syncing, syncNowTooltip}) {
let prefix = gPhotonStructure ? "appMenu" : "PanelUI"
let labelNode = document.getElementById(`${prefix}-fxa-label`);
let tooltipNode = document.getElementById(`${prefix}-fxa-status`);
let statusNode = document.getElementById(`${prefix}-fxa-container`);
let avatar = document.getElementById(`${prefix}-fxa-avatar`);
let labelNode = document.getElementById("appMenu-fxa-label");
let tooltipNode = document.getElementById("appMenu-fxa-status");
let statusNode = document.getElementById("appMenu-fxa-container");
let avatar = document.getElementById("appMenu-fxa-avatar");
is(labelNode.getAttribute("label"), label, "fxa label has the right value");
is(tooltipNode.getAttribute("tooltiptext"), tooltip, "fxa tooltip has the right value");
@ -166,7 +164,7 @@ function checkPanelUIStatusBar({label, tooltip, fxastatus, avatarURL, syncing, s
}
if (syncing != undefined && syncNowTooltip != undefined) {
checkSyncNowButton(`${prefix}-fxa-icon`, syncing, syncNowTooltip);
checkSyncNowButton("appMenu-fxa-icon", syncing, syncNowTooltip);
}
}

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

@ -63,11 +63,6 @@ async function openAndCheckCustomizationUIMenu(target) {
// Test main ("hamburger") menu.
add_task(async function test_main_menu_touch() {
if (!gPhotonStructure) {
ok(true, "Skipping test because we're not in Photon mode");
return;
}
let mainMenu = document.getElementById("appMenu-popup");
let target = document.getElementById("PanelUI-menu-button");
await openAndCheckMenu(mainMenu, target);
@ -75,11 +70,6 @@ add_task(async function test_main_menu_touch() {
// Test the page action menu.
add_task(async function test_page_action_panel_touch() {
if (!gPhotonStructure) {
ok(true, "Skipping test because we're not in Photon mode");
return;
}
let pageActionPanel = document.getElementById("page-action-panel");
let target = document.getElementById("urlbar-page-action-button");
await openAndCheckMenu(pageActionPanel, target);
@ -88,11 +78,6 @@ add_task(async function test_page_action_panel_touch() {
// Test the customizationUI panel, which is used for various menus
// such as library, history, sync, developer and encoding.
add_task(async function test_customizationui_panel_touch() {
if (!gPhotonStructure) {
ok(true, "Skipping test because we're not in Photon mode");
return;
}
CustomizableUI.addWidgetToArea("library-button", CustomizableUI.AREA_NAVBAR);
CustomizableUI.addWidgetToArea("history-panelmenu", CustomizableUI.AREA_NAVBAR);

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

@ -16,7 +16,6 @@ async function waitForSearchBarFocus() {
// Ctrl+K should open the menu panel and focus the search bar if the search bar is in the panel.
add_task(async function() {
await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", true]]});
let searchbar = document.getElementById("searchbar");
gCustomizeMode.addToPanel(searchbar);
let placement = CustomizableUI.getPlacementOfWidget("search-container");

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

@ -14,7 +14,6 @@ const overflowPanel = document.getElementById("widget-overflow");
// Right-click on the home button should
// show a context menu with options to move it.
add_task(async function home_button_context() {
await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", true]]});
let contextMenu = document.getElementById("toolbar-context-menu");
let shownPromise = popupShown(contextMenu);
let homeButton = document.getElementById("home-button");

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

@ -9,7 +9,6 @@ const kHelpButtonId = "appMenu-help-button";
let gHelperInstance;
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", true]]});
gHelperInstance = new PanelMultiView(PanelUI.panel, true);
});

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

@ -5,10 +5,7 @@ var gContentAPI;
var gContentWindow;
var hasPocket = Services.prefs.getBoolPref("extensions.pocket.enabled");
var isPhoton = Services.prefs.getBoolPref("browser.photon.structure.enabled");
var hasQuit = !isPhoton ||
AppConstants.platform != "macosx";
var hasLibrary = isPhoton || false;
var hasQuit = AppConstants.platform != "macosx";
requestLongerTimeout(2);
add_task(setup_UITourTest);
@ -25,7 +22,7 @@ add_UITour_task(async function test_availableTargets() {
"devtools",
"help",
"home",
...(hasLibrary ? ["library"] : []),
"library",
...(hasPocket ? ["pocket"] : []),
"privateWindow",
...(hasQuit ? ["quit"] : []),
@ -54,7 +51,7 @@ add_UITour_task(async function test_availableTargets_changeWidgets() {
"help",
"devtools",
"home",
...(hasLibrary ? ["library"] : []),
"library",
...(hasPocket ? ["pocket"] : []),
"privateWindow",
...(hasQuit ? ["quit"] : []),
@ -88,7 +85,7 @@ add_UITour_task(async function test_availableTargets_exceptionFromGetTarget() {
"devtools",
"help",
"home",
...(hasLibrary ? ["library"] : []),
"library",
...(hasPocket ? ["pocket"] : []),
"privateWindow",
...(hasQuit ? ["quit"] : []),

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

@ -42,8 +42,7 @@ var tests = [
await showMenuPromise("appMenu");
await showHighlightPromise("accountStatus");
let highlight = document.getElementById("UITourHighlightContainer");
let photon = Services.prefs.getBoolPref("browser.photon.structure.enabled");
let expectedTarget = photon ? "appMenu-fxa-avatar" : "PanelUI-fxa-avatar";
let expectedTarget = "appMenu-fxa-avatar";
is(highlight.popupBoxObject.anchorNode.id, expectedTarget, "Anchored on avatar");
is(highlight.getAttribute("targetName"), "accountStatus", "Correct highlight target");
}),

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

@ -27,8 +27,6 @@ XPCOMUtils.defineLazyGetter(this, "Timer", function() {
return timer;
});
XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure", "browser.photon.structure.enabled");
const MS_SECOND = 1000;
const MS_MINUTE = MS_SECOND * 60;
const MS_HOUR = MS_MINUTE * 60;
@ -76,27 +74,10 @@ XPCOMUtils.defineLazyGetter(this, "DEFAULT_AREA_PLACEMENTS", function() {
"PersonalToolbar": [
"personal-bookmarks",
],
"widget-overflow-fixed-list": [
],
};
if (gPhotonStructure) {
result["widget-overflow-fixed-list"] = [];
} else {
result["PanelUI-contents"] = LEGACY_PANEL_PLACEMENTS;
let showCharacterEncoding = Services.prefs.getComplexValue(
"browser.menu.showCharacterEncoding",
Ci.nsIPrefLocalizedString
).data;
if (showCharacterEncoding == "true") {
result["PanelUI-contents"].push("characterencoding-button");
}
if (AppConstants.MOZ_DEV_EDITION || AppConstants.NIGHTLY_BUILD) {
if (Services.prefs.getBoolPref("extensions.webcompat-reporter.enabled")) {
result["PanelUI-contents"].push("webcompat-reporter-button");
}
}
}
return result;
});
@ -111,16 +92,10 @@ XPCOMUtils.defineLazyGetter(this, "PALETTE_ITEMS", function() {
"feed-button",
"email-link-button",
"containers-panelmenu",
...LEGACY_PANEL_PLACEMENTS,
"characterencoding-button",
];
let panelPlacements = DEFAULT_AREA_PLACEMENTS["PanelUI-contents"];
if (!panelPlacements) {
result.push(...LEGACY_PANEL_PLACEMENTS);
}
if (!panelPlacements || !panelPlacements.includes("characterencoding-button")) {
result.push("characterencoding-button");
}
if (Services.prefs.getBoolPref("privacy.panicButton.enabled")) {
result.push("panic-button");
}