Backed out changeset 9b1e2e6ceb70 (bug 1785853) for causing mochitest failures on browser_setup_state.js CLOSED TREE
This commit is contained in:
@@ -39,8 +39,6 @@ ChromeUtils.defineESModuleGetters(this, {
|
||||
ShortcutUtils: "resource://gre/modules/ShortcutUtils.sys.mjs",
|
||||
SubDialog: "resource://gre/modules/SubDialog.sys.mjs",
|
||||
SubDialogManager: "resource://gre/modules/SubDialog.sys.mjs",
|
||||
TabsSetupFlowManager:
|
||||
"resource:///modules/firefox-view-tabs-setup-manager.sys.mjs",
|
||||
UpdateUtils: "resource://gre/modules/UpdateUtils.sys.mjs",
|
||||
UrlbarInput: "resource:///modules/UrlbarInput.sys.mjs",
|
||||
UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs",
|
||||
@@ -10015,9 +10013,6 @@ var FirefoxViewHandler = {
|
||||
gBrowser.hideTab(this.tab);
|
||||
this.button.setAttribute("aria-controls", this.tab.linkedPanel);
|
||||
}
|
||||
// we put this here to avoid a race condition that would occur
|
||||
// if this was called in response to "TabSelect"
|
||||
this._closeDeviceConnectedTab();
|
||||
gBrowser.selectedTab = this.tab;
|
||||
},
|
||||
handleEvent(e) {
|
||||
@@ -10046,33 +10041,6 @@ var FirefoxViewHandler = {
|
||||
break;
|
||||
}
|
||||
},
|
||||
_closeDeviceConnectedTab() {
|
||||
if (!TabsSetupFlowManager.didFxaTabOpen) {
|
||||
return;
|
||||
}
|
||||
// close the tab left behind after a user pairs a device and
|
||||
// is redirected back to the Firefox View tab
|
||||
const fxaRoot = Services.prefs.getCharPref(
|
||||
"identity.fxaccounts.remote.root"
|
||||
);
|
||||
const fxDeviceConnectedTab = gBrowser.tabs.find(tab =>
|
||||
tab.linkedBrowser.currentURI.displaySpec.startsWith(
|
||||
`${fxaRoot}pair/auth/complete`
|
||||
)
|
||||
);
|
||||
|
||||
if (!fxDeviceConnectedTab) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gBrowser.tabs.length <= 2) {
|
||||
// if its the only tab besides the Firefox View tab,
|
||||
// open a new tab first so the browser doesn't close
|
||||
gBrowser.addTrustedTab("about:newtab");
|
||||
}
|
||||
gBrowser.removeTab(fxDeviceConnectedTab);
|
||||
TabsSetupFlowManager.didFxaTabOpen = false;
|
||||
},
|
||||
_onTabForegrounded() {
|
||||
if (this.tab?.selected) {
|
||||
this.SyncedTabs.syncTabs();
|
||||
|
||||
@@ -74,7 +74,6 @@ export const TabsSetupFlowManager = new (class {
|
||||
lazy.gNetworkLinkService.isLinkUp;
|
||||
this.syncIsWorking = true;
|
||||
this.syncIsConnected = lazy.UIState.get().syncEnabled;
|
||||
this.didFxaTabOpen = false;
|
||||
|
||||
this.registerSetupState({
|
||||
uiStateIndex: 0,
|
||||
@@ -535,7 +534,6 @@ export const TabsSetupFlowManager = new (class {
|
||||
const url = await lazy.fxAccounts.constructor.config.promiseConnectAccountURI(
|
||||
"firefoxview"
|
||||
);
|
||||
this.didFxaTabOpen = true;
|
||||
openTabInWindow(window, url, true);
|
||||
Services.telemetry.recordEvent("firefoxview", "fxa_continue", "sync", null);
|
||||
}
|
||||
@@ -544,7 +542,6 @@ export const TabsSetupFlowManager = new (class {
|
||||
const url = await lazy.fxAccounts.constructor.config.promisePairingURI({
|
||||
entrypoint: "fx-view",
|
||||
});
|
||||
this.didFxaTabOpen = true;
|
||||
openTabInWindow(window, url, true);
|
||||
Services.telemetry.recordEvent("firefoxview", "fxa_mobile", "sync", null, {
|
||||
has_devices: this.secondaryDeviceConnected.toString(),
|
||||
|
||||
@@ -711,154 +711,3 @@ add_task(async function test_keyboard_focus_after_tab_pickup_opened() {
|
||||
await tearDown(sandbox);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
async function mockFxaDeviceConnected(win) {
|
||||
// We use an existing tab to navigate to the final "device connected" url
|
||||
// in order to fake the fxa device sync process
|
||||
const url = "https://example.org/pair/auth/complete";
|
||||
is(win.gBrowser.tabs.length, 3, "Tabs strip should contain three tabs");
|
||||
|
||||
BrowserTestUtils.loadURI(win.gBrowser.selectedTab.linkedBrowser, url);
|
||||
|
||||
await BrowserTestUtils.browserLoaded(
|
||||
win.gBrowser.selectedTab.linkedBrowser,
|
||||
null,
|
||||
url
|
||||
);
|
||||
|
||||
is(
|
||||
win.gBrowser.selectedTab.linkedBrowser.currentURI.filePath,
|
||||
"/pair/auth/complete",
|
||||
"/pair/auth/complete is the selected tab"
|
||||
);
|
||||
}
|
||||
|
||||
add_task(async function test_close_device_connected_tab() {
|
||||
// test that when a device has been connected to sync we close
|
||||
// that tab after the user is directed back to firefox view
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["identity.fxaccounts.remote.root", "https://example.org/"]],
|
||||
});
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
let fxViewTab = await openFirefoxViewTab(win);
|
||||
|
||||
await waitForVisibleSetupStep(win.gBrowser, {
|
||||
expectedVisible: "#tabpickup-steps-view1",
|
||||
});
|
||||
|
||||
let actionButton = win.gBrowser.contentWindow.document.querySelector(
|
||||
"#tabpickup-steps-view1 button.primary"
|
||||
);
|
||||
// initiate the sign in flow from Firefox View, to check that didFxaTabOpen is set
|
||||
let tabSwitched = BrowserTestUtils.waitForEvent(
|
||||
win.gBrowser,
|
||||
"TabSwitchDone"
|
||||
);
|
||||
actionButton.click();
|
||||
await tabSwitched;
|
||||
|
||||
is(
|
||||
win.gBrowser.selectedTab.linkedBrowser.currentURI.spec,
|
||||
"https://example.org/?context=fx_desktop_v3&entrypoint=firefoxview&action=email&service=sync",
|
||||
"fxa entrypoint is the selected tab"
|
||||
);
|
||||
|
||||
// fake the end point of the device syncing flow
|
||||
await mockFxaDeviceConnected(win);
|
||||
let deviceConnectedTab = win.gBrowser.tabs[2];
|
||||
|
||||
// remove the blank tab opened with the browser to check that we don't
|
||||
// close the window when the "Device connected" tab is closed
|
||||
const newTab = win.gBrowser.tabs.find(
|
||||
tab => tab != deviceConnectedTab && tab != fxViewTab
|
||||
);
|
||||
let removedTab = BrowserTestUtils.waitForTabClosing(newTab);
|
||||
BrowserTestUtils.removeTab(newTab);
|
||||
await removedTab;
|
||||
|
||||
is(win.gBrowser.tabs.length, 2, "Tabs strip should only contain two tabs");
|
||||
|
||||
is(
|
||||
win.gBrowser.selectedTab.linkedBrowser.currentURI.filePath,
|
||||
"/pair/auth/complete",
|
||||
"/pair/auth/complete is the selected tab"
|
||||
);
|
||||
|
||||
// we use this instead of BrowserTestUtils.switchTab to get back to the firefox view tab
|
||||
// because this more accurately reflects how this tab is selected - via a custom onmousedown
|
||||
// and command that calls FirefoxViewHandler.openTab (both when the user manually clicks the tab
|
||||
// and when navigating from the fxa Device Connected tab, which also calls FirefoxViewHandler.openTab)
|
||||
await EventUtils.synthesizeMouseAtCenter(
|
||||
win.document.getElementById("firefox-view-button"),
|
||||
{ type: "mousedown" },
|
||||
win
|
||||
);
|
||||
|
||||
is(win.gBrowser.tabs.length, 2, "Tabs strip should only contain two tabs");
|
||||
|
||||
is(
|
||||
win.gBrowser.tabs[0].linkedBrowser.currentURI.filePath,
|
||||
"firefoxview",
|
||||
"First tab is Firefox view"
|
||||
);
|
||||
|
||||
is(
|
||||
win.gBrowser.tabs[1].linkedBrowser.currentURI.filePath,
|
||||
"newtab",
|
||||
"Second tab is about:newtab"
|
||||
);
|
||||
|
||||
// now simulate the signed-in state with the prompt to download
|
||||
// and sync mobile
|
||||
const sandbox = setupMocks({
|
||||
state: UIState.STATUS_SIGNED_IN,
|
||||
fxaDevices: [
|
||||
{
|
||||
id: 1,
|
||||
name: "This Device",
|
||||
isCurrentDevice: true,
|
||||
type: "desktop",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Services.obs.notifyObservers(null, UIState.ON_UPDATE);
|
||||
|
||||
await waitForVisibleSetupStep(win.gBrowser, {
|
||||
expectedVisible: "#tabpickup-steps-view2",
|
||||
});
|
||||
|
||||
actionButton = win.gBrowser.contentWindow.document.querySelector(
|
||||
"#tabpickup-steps-view2 button.primary"
|
||||
);
|
||||
// initiate the connect device (mobile) flow from Firefox View, to check that didFxaTabOpen is set
|
||||
tabSwitched = BrowserTestUtils.waitForEvent(win.gBrowser, "TabSwitchDone");
|
||||
actionButton.click();
|
||||
await tabSwitched;
|
||||
// fake the end point of the device syncing flow
|
||||
await mockFxaDeviceConnected(win);
|
||||
|
||||
await EventUtils.synthesizeMouseAtCenter(
|
||||
win.document.getElementById("firefox-view-button"),
|
||||
{ type: "mousedown" },
|
||||
win
|
||||
);
|
||||
is(win.gBrowser.tabs.length, 2, "Tabs strip should only contain two tabs");
|
||||
|
||||
is(
|
||||
win.gBrowser.tabs[0].linkedBrowser.currentURI.filePath,
|
||||
"firefoxview",
|
||||
"First tab is Firefox view"
|
||||
);
|
||||
|
||||
is(
|
||||
win.gBrowser.tabs[1].linkedBrowser.currentURI.filePath,
|
||||
"newtab",
|
||||
"Second tab is about:newtab"
|
||||
);
|
||||
|
||||
// cleanup time
|
||||
await tearDown(sandbox);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user