mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1577820 Disable fxa button badge changes r=florian
This technique is used in browser_tabopen.js but is also needed in other tests that observe repaints in the tab strip. There's a lot of copy&paste here but for now that's more expedient than some bigger refactoring of these tests... Differential Revision: https://phabricator.services.mozilla.com/D70530 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
be606b9953
commit
542aefb7e8
@ -44,6 +44,7 @@ const EXPECTED_APPMENU_OPEN_REFLOWS = [
|
||||
|
||||
add_task(async function() {
|
||||
await ensureNoPreloadedBrowser();
|
||||
await disableFxaBadge();
|
||||
|
||||
let textBoxRect = gURLBar
|
||||
.querySelector("moz-input-box")
|
||||
@ -51,9 +52,6 @@ add_task(async function() {
|
||||
let menuButtonRect = document
|
||||
.getElementById("PanelUI-menu-button")
|
||||
.getBoundingClientRect();
|
||||
let fxaToolbarButtonRect = document
|
||||
.getElementById("fxa-toolbar-menu-button")
|
||||
.getBoundingClientRect();
|
||||
let firstTabRect = gBrowser.selectedTab.getBoundingClientRect();
|
||||
let frameExpectations = {
|
||||
filter: rects =>
|
||||
@ -88,14 +86,6 @@ add_task(async function() {
|
||||
r.y1 >= firstTabRect.top &&
|
||||
r.y2 <= firstTabRect.bottom,
|
||||
},
|
||||
{
|
||||
name: "the fxa toolbar changes icon when first clicked",
|
||||
condition: r =>
|
||||
r.x1 >= fxaToolbarButtonRect.left &&
|
||||
r.x2 <= fxaToolbarButtonRect.right &&
|
||||
r.y1 >= fxaToolbarButtonRect.top &&
|
||||
r.y2 <= fxaToolbarButtonRect.bottom,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -21,6 +21,7 @@ const EXPECTED_REFLOWS = [
|
||||
*/
|
||||
add_task(async function() {
|
||||
await ensureNoPreloadedBrowser();
|
||||
await disableFxaBadge();
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
await TestUtils.waitForCondition(() => tab._fullyOpen);
|
||||
|
@ -22,6 +22,7 @@ const EXPECTED_REFLOWS = [
|
||||
*/
|
||||
add_task(async function() {
|
||||
await ensureNoPreloadedBrowser();
|
||||
await disableFxaBadge();
|
||||
|
||||
// At the time of writing, there are no reflows on tab closing with
|
||||
// tab growth. Mochitest will fail if we have no assertions, so we
|
||||
|
@ -24,6 +24,7 @@ const EXPECTED_REFLOWS = [
|
||||
*/
|
||||
add_task(async function() {
|
||||
await ensureNoPreloadedBrowser();
|
||||
await disableFxaBadge();
|
||||
|
||||
// Prepare the window to avoid flicker and reflow that's unrelated to our
|
||||
// tab opening operation.
|
||||
@ -35,9 +36,6 @@ add_task(async function() {
|
||||
let textBoxRect = gURLBar
|
||||
.querySelector("moz-input-box")
|
||||
.getBoundingClientRect();
|
||||
let fxaAccountsButton = document
|
||||
.getElementById("fxa-toolbar-menu-button")
|
||||
.getBoundingClientRect();
|
||||
|
||||
let inRange = (val, min, max) => min <= val && val <= max;
|
||||
|
||||
@ -124,15 +122,6 @@ add_task(async function() {
|
||||
r.y1 >= firstTabLabelRect.y &&
|
||||
r.y2 <= firstTabLabelRect.bottom,
|
||||
},
|
||||
{
|
||||
name:
|
||||
"FxA accounts button is intentionally badged 10s after startup",
|
||||
condition: r =>
|
||||
r.x1 >= fxaAccountsButton.left &&
|
||||
r.x2 <= fxaAccountsButton.right &&
|
||||
r.y1 >= fxaAccountsButton.top &&
|
||||
r.y2 <= fxaAccountsButton.bottom,
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ const EXPECTED_REFLOWS = [
|
||||
*/
|
||||
add_task(async function() {
|
||||
await ensureNoPreloadedBrowser();
|
||||
await disableFxaBadge();
|
||||
|
||||
// Compute the number of tabs we can put into the strip without
|
||||
// overflowing, and remove one, so that we can create
|
||||
|
@ -36,6 +36,7 @@ add_task(async function() {
|
||||
await createTabs(TAB_COUNT_FOR_OVERFLOW);
|
||||
|
||||
gURLBar.focus();
|
||||
await disableFxaBadge();
|
||||
|
||||
let tabStripRect = gBrowser.tabContainer.arrowScrollbox.getBoundingClientRect();
|
||||
let textBoxRect = gURLBar
|
||||
|
@ -25,6 +25,7 @@ const EXPECTED_REFLOWS = [
|
||||
*/
|
||||
add_task(async function() {
|
||||
await ensureNoPreloadedBrowser();
|
||||
await disableFxaBadge();
|
||||
|
||||
// At the time of writing, there are no reflows on simple tab switching.
|
||||
// Mochitest will fail if we have no assertions, so we add one here
|
||||
|
@ -53,11 +53,10 @@ add_task(async function() {
|
||||
"about:home"
|
||||
);
|
||||
|
||||
await disableFxaBadge();
|
||||
|
||||
let alreadyFocused = false;
|
||||
let inRange = (val, min, max) => min <= val && val <= max;
|
||||
let fxaAccountsButton = document
|
||||
.getElementById("fxa-toolbar-menu-button")
|
||||
.getBoundingClientRect();
|
||||
let expectations = {
|
||||
expectedReflows: EXPECTED_REFLOWS,
|
||||
frames: {
|
||||
@ -100,14 +99,6 @@ add_task(async function() {
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "FxA accounts button is intentionally badged 10s after startup",
|
||||
condition: r =>
|
||||
r.x1 >= fxaAccountsButton.left &&
|
||||
r.x2 <= fxaAccountsButton.right &&
|
||||
r.y1 >= fxaAccountsButton.top &&
|
||||
r.y2 <= fxaAccountsButton.bottom,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
@ -254,6 +254,21 @@ async function ensureNoPreloadedBrowser(win = window) {
|
||||
});
|
||||
}
|
||||
|
||||
// Onboarding puts a badge on the fxa toolbar button a while after startup
|
||||
// which confuses tests that look at repaints in the toolbar. Use this
|
||||
// function to cancel the badge update.
|
||||
function disableFxaBadge() {
|
||||
let { ToolbarBadgeHub } = ChromeUtils.import(
|
||||
"resource://activity-stream/lib/ToolbarBadgeHub.jsm"
|
||||
);
|
||||
ToolbarBadgeHub._clearBadgeTimeout();
|
||||
|
||||
// Also prevent a new timer from being set
|
||||
return SpecialPowers.pushPrefEnv({
|
||||
set: [["identity.fxaccounts.toolbar.accessed", true]],
|
||||
});
|
||||
}
|
||||
|
||||
async function prepareSettledWindow() {
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
await ensureNoPreloadedBrowser(win);
|
||||
|
Loading…
Reference in New Issue
Block a user