mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-04 10:18:41 +02:00
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
40 lines
1.2 KiB
JavaScript
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;
|
|
}
|