Bug 1857264 - Remove unnecessary openTabInUserContext function definitions in tests. r=mseibert

Differential Revision: https://phabricator.services.mozilla.com/D197809
This commit is contained in:
Stephanie Cunnane 2024-01-17 16:09:10 +00:00
Родитель 716884d412
Коммит 79b29f89f4
12 изменённых файлов: 11 добавлений и 131 удалений

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

@ -3,21 +3,6 @@ const URI =
BASE_ORIGIN +
"/browser/browser/components/contextualidentity/test/browser/empty_file.html";
// Opens `uri' in a new tab with the provided userContextId and focuses it.
// Returns the newly opened tab and browser.
async function openTabInUserContext(uri, userContextId) {
// open the tab in the correct userContextId
let tab = BrowserTestUtils.addTab(gBrowser, uri, { userContextId });
// select tab and make sure its browser is focused
gBrowser.selectedTab = tab;
tab.ownerGlobal.focus();
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return { tab, browser };
}
async function runTestForReceiver(receiver) {
let channelName = "contextualidentity-broadcastchannel";

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

@ -20,19 +20,6 @@ const TESTKEY = {
const USER_ID_DEFAULT = 0;
const USER_ID_PERSONAL = 1;
async function openTabInUserContext(uri, userContextId) {
// Open the tab in the correct userContextId.
let tab = BrowserTestUtils.addTab(gBrowser, uri, { userContextId });
// Select tab and make sure its browser is focused.
gBrowser.selectedTab = tab;
tab.ownerGlobal.focus();
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return { tab, browser };
}
function HexToBase64(hex) {
var bin = "";
for (var i = 0; i < hex.length; i += 2) {

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

@ -29,19 +29,6 @@ function getIconFile() {
});
}
async function openTabInUserContext(uri, userContextId) {
// open the tab in the correct userContextId
let tab = BrowserTestUtils.addTab(gBrowser, uri, { userContextId });
// select tab and make sure its browser is focused
gBrowser.selectedTab = tab;
tab.ownerGlobal.focus();
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return { tab, browser };
}
function loadIndexHandler(metadata, response) {
response.setStatusLine(metadata.httpVersion, 200, "Ok");
response.setHeader("Content-Type", "text/html", false);

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

@ -24,19 +24,6 @@ const TEST_EME_KEY = {
// Support functions.
//
async function openTabInUserContext(uri, userContextId) {
// Open the tab in the correct userContextId.
let tab = BrowserTestUtils.addTab(gBrowser, uri, { userContextId });
// Select tab and make sure its browser is focused.
gBrowser.selectedTab = tab;
tab.ownerGlobal.focus();
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return { tab, browser };
}
function HexToBase64(hex) {
var bin = "";
for (var i = 0; i < hex.length; i += 2) {

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

@ -16,19 +16,6 @@ const USER_CONTEXTS = ["default", "personal"];
// Support functions.
//
async function openTabInUserContext(uri, userContextId) {
// Open the tab in the correct userContextId.
let tab = BrowserTestUtils.addTab(gBrowser, uri, { userContextId });
// Select tab and make sure its browser is focused.
gBrowser.selectedTab = tab;
tab.ownerGlobal.focus();
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return { tab, browser };
}
function getCookiesForOA(host, userContextId) {
return Services.cookies.getCookiesFromHost(host, { userContextId });
}

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

@ -16,19 +16,6 @@ const USER_CONTEXTS = ["default", "personal"];
// Support functions.
//
async function openTabInUserContext(uri, userContextId) {
// Open the tab in the correct userContextId.
let tab = BrowserTestUtils.addTab(gBrowser, uri, { userContextId });
// Select tab and make sure its browser is focused.
gBrowser.selectedTab = tab;
tab.ownerGlobal.focus();
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return { tab, browser };
}
// Setup an entry for the indexedDB.
async function setupIndexedDB(browser) {
await SpecialPowers.spawn(

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

@ -56,19 +56,6 @@ function loadImagePageHandler(metadata, response) {
response.bodyOutputStream.write(body, body.length);
}
async function openTabInUserContext(uri, userContextId) {
// Open the tab in the correct userContextId.
let tab = BrowserTestUtils.addTab(gBrowser, uri, { userContextId });
// Select tab and make sure its browser is focused.
gBrowser.selectedTab = tab;
tab.ownerGlobal.focus();
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return { tab, browser };
}
function getCookiesForOA(host, userContextId) {
return Services.cookies.getCookiesFromHost(host, { userContextId });
}

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

@ -40,28 +40,13 @@ add_setup(async function () {
});
});
// opens `uri' in a new tab with the provided userContextId and focuses it.
// returns the newly opened tab
async function openTabInUserContext(uri, userContextId) {
// open the tab in the correct userContextId
let tab = BrowserTestUtils.addTab(gBrowser, uri, { userContextId });
// select tab and make sure its browser is focused
gBrowser.selectedTab = tab;
tab.ownerGlobal.focus();
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return tab;
}
add_task(async function test() {
for (
let userContextId = 0;
userContextId < NUM_USER_CONTEXTS;
userContextId++
) {
let tab = await openTabInUserContext(FILE_URI, userContextId);
let { tab } = await openTabInUserContext(FILE_URI, userContextId);
gBrowser.removeTab(tab);
}
is(

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

@ -19,19 +19,6 @@ const COOKIE_NAME = "userContextId";
// Support functions.
//
async function openTabInUserContext(uri, userContextId) {
// Open the tab in the correct userContextId.
let tab = BrowserTestUtils.addTab(gBrowser, uri, { userContextId });
// Select tab and make sure its browser is focused.
gBrowser.selectedTab = tab;
tab.ownerGlobal.focus();
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return { tab, browser };
}
function getCookiesForOA(host, userContextId) {
return Services.cookies.getCookiesFromHost(host, { userContextId });
}

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

@ -32,9 +32,9 @@ add_task(async function test_switch_tab() {
let contextIdTabB = 2;
let contextIdTabC = 3;
let tabA = await openTabInUserContext(urlA, contextIdTabA);
let tabB = await openTabInUserContext(urlA, contextIdTabB);
let tabC = await openTabInUserContext(urlB, contextIdTabC);
let { tab: tabA } = await openTabInUserContext(urlA, contextIdTabA);
let { tab: tabB } = await openTabInUserContext(urlA, contextIdTabB);
let { tab: tabC } = await openTabInUserContext(urlB, contextIdTabC);
let searchContext = await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
@ -111,8 +111,8 @@ add_task(async function test_chiclet_disabled_on_update() {
let contextIdTabB = 3;
let initialTab = gBrowser.selectedTab;
let tabA = await openTabInUserContext(urlA, contextIdTabA);
let tabB = await openTabInUserContext(urlA, contextIdTabB);
let { tab: tabA } = await openTabInUserContext(urlA, contextIdTabA);
let { tab: tabB } = await openTabInUserContext(urlA, contextIdTabB);
await BrowserTestUtils.switchTab(gBrowser, initialTab);
await UrlbarTestUtils.promiseAutocompleteResultPopup({

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

@ -9,7 +9,7 @@ async function openTabInUserContext(uri, userContextId) {
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser, false, uri);
return { tab };
return tab;
}
/**
@ -17,7 +17,7 @@ async function openTabInUserContext(uri, userContextId) {
*/
add_task(async function test_tab_color_updates() {
const kId = 2;
let { tab } = await openTabInUserContext("https://example.com/", kId);
let tab = await openTabInUserContext("https://example.com/", kId);
let contextIdInfo = ContextualIdentityService.getPublicIdentityFromId(kId);
ok(
tab.classList.contains("identity-color-" + contextIdInfo.color),

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

@ -53,7 +53,8 @@ function loadTestSubscript(filePath) {
* @param {string} uri The uri which should be opened in the new tab.
* @param {number} userContextId The id of the user context in which the tab
* should be opened.
* @returns {MozTabbrowserTab} The newly opened tab
* @returns {object} Keys are `tab` (the newly-opened tab) and `browser` (the
* browser associated with the tab).
*/
async function openTabInUserContext(uri, userContextId) {
let tab = BrowserTestUtils.addTab(gBrowser, uri, { userContextId });
@ -63,5 +64,5 @@ async function openTabInUserContext(uri, userContextId) {
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return tab;
return { tab, browser };
}