Backed out changeset f03d4b22573f (bug 1962683) for causing mochitest failures on browser_ext_tabs_group_ungroup.js CLOSED TREE
This commit is contained in:
@@ -19,10 +19,13 @@ add_task(async function group_ungroup_and_index() {
|
||||
"tab3.htm": "<title>tab3.html</title>",
|
||||
},
|
||||
async background() {
|
||||
const { id: tabId1 } = await browser.tabs.create({ url: "tab1.htm" });
|
||||
const { id: tabId2 } = await browser.tabs.create({ url: "tab2.htm" });
|
||||
const { id: tabId3 } = await browser.tabs.create({ url: "tab3.htm" });
|
||||
|
||||
let eventIds = [];
|
||||
let expected = [];
|
||||
let allEvents = Promise.withResolvers();
|
||||
const EXPECTED_EVENT_COUNT = 16;
|
||||
|
||||
browser.tabGroups.onCreated.addListener(group => {
|
||||
eventIds.push(group.id);
|
||||
@@ -31,22 +34,13 @@ add_task(async function group_ungroup_and_index() {
|
||||
browser.tabGroups.onRemoved.addListener(group => {
|
||||
eventIds.push(-group.id);
|
||||
browser.test.log(`Events so far (${eventIds.length}): ${eventIds}`);
|
||||
if (eventIds.length === EXPECTED_EVENT_COUNT) {
|
||||
if (eventIds.length === 16) {
|
||||
allEvents.resolve();
|
||||
}
|
||||
if (eventIds.length > EXPECTED_EVENT_COUNT) {
|
||||
if (eventIds.length > 16) {
|
||||
browser.fail("Extra event received: " + group.id);
|
||||
}
|
||||
});
|
||||
browser.tabGroups.onMoved.addListener(group => {
|
||||
// We do not expect any tabGroups.onMoved. Logging for visibility.
|
||||
eventIds.push(`moved${group.id}`);
|
||||
browser.test.log(`Events so far (${eventIds.length}): ${eventIds}`);
|
||||
});
|
||||
|
||||
const { id: tabId1 } = await browser.tabs.create({ url: "tab1.htm" });
|
||||
const { id: tabId2 } = await browser.tabs.create({ url: "tab2.htm" });
|
||||
const { id: tabId3 } = await browser.tabs.create({ url: "tab3.htm" });
|
||||
|
||||
async function assertAllTabExpectations(expectations, desc) {
|
||||
const tabs = await Promise.all([
|
||||
@@ -199,18 +193,16 @@ add_task(async function group_ungroup_and_index() {
|
||||
|
||||
expected.push(-groupId8, -groupId9);
|
||||
|
||||
// If the test gets stuck here, see bug 1962683.
|
||||
// If we miss the first tabGroups.onCreated event, a work-around could be
|
||||
// to call and await a tabGroups method before the first tabs.group()
|
||||
// call above, like other work-arounds for bug 1300234.
|
||||
info(`Waiting for events ${expected.length}/${EXPECTED_EVENT_COUNT}`);
|
||||
await allEvents.promise;
|
||||
|
||||
browser.test.assertEq(
|
||||
eventIds.join(),
|
||||
expected.join(),
|
||||
"Received expected onCreated events"
|
||||
);
|
||||
// TODO bug 1962683: Re-enable when events are no longer missing
|
||||
// await allEvents.promise;
|
||||
//
|
||||
// browser.test.assertEq(
|
||||
// eventIds.join(),
|
||||
// expected.join(),
|
||||
// "Received expected onCreated events"
|
||||
// );
|
||||
browser.test.log(`Expect: ${eventIds.join()}`);
|
||||
browser.test.log(`Actual: ${expected.join()}`);
|
||||
|
||||
browser.test.sendMessage("done");
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user