gecko-dev/browser/components/taskbartabs/test/browser/head.js
Nicholas Rishel 21c6063d56 Bug 1966829 - Add a Taskbar Tabs window manager. r=mossop,cdupuis,frontend-codestyle-reviewers
This class manages the creation and removal of Taskbar Tabs windows. This maintains state necessary to determine what window a tab should return to if ejected from Taskbar Tabs.

Differential Revision: https://phabricator.services.mozilla.com/D249717
2025-06-16 04:55:11 +00:00

40 lines
1.2 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
ChromeUtils.defineESModuleGetters(this, {
TaskbarTabsRegistry:
"resource:///modules/taskbartabs/TaskbarTabsRegistry.sys.mjs",
TaskbarTabsWindowManager:
"resource:///modules/taskbartabs/TaskbarTabsWindowManager.sys.mjs",
});
/**
* Creates a web app window with the given tab,
* then returns the window object for testing.
*
* @param {Tab} aTab
* The tab that the web app should open with
* @returns {Promise}
* The web app window object.
*/
async function openTaskbarTabWindow(aTab = null) {
const url = Services.io.newURI("https://example.com");
const userContextId = 0;
const registry = new TaskbarTabsRegistry();
const taskbarTab = registry.findOrCreateTaskbarTab(url, userContextId);
const windowManager = new TaskbarTabsWindowManager();
const windowPromise = BrowserTestUtils.waitForNewWindow();
if (aTab) {
windowManager.replaceTabWithWindow(taskbarTab, aTab);
} else {
windowManager.openWindow(taskbarTab);
}
return await windowPromise;
}