Skip to content

Commit 7e9243a

Browse files
committed
Add test for inheritance of "muted" status
1 parent 9d215ac commit 7e9243a

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

webextensions/tests/test-tree.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,44 @@ export async function testAutoFixupForHiddenTabs() {
132132
}
133133
}
134134

135+
export async function testInheritMutedState() {
136+
let tabs = await Utils.createTabs({
137+
A: { index: 1 },
138+
B: { index: 2, openerTabId: 'A' },
139+
C: { index: 3, openerTabId: 'B' },
140+
D: { index: 4, openerTabId: 'C' }
141+
}, { windowId: win.id });
142+
143+
tabs = await Utils.refreshTabs(tabs);
144+
{
145+
const { A, B, C, D } = tabs;
146+
is([
147+
`${A.id}`,
148+
`${A.id} => ${B.id}`,
149+
`${A.id} => ${B.id} => ${C.id}`,
150+
`${A.id} => ${B.id} => ${C.id} => ${D.id}`,
151+
], Utils.treeStructure(Object.values(tabs)),
152+
'tabs must be initialized with specified structure');
153+
is([false, false, false, false],
154+
[A, B, C, D].map(tab => tab.$TST.muted),
155+
'initially all tab must be unmuted');
156+
is([false, false, false, false],
157+
[A, B, C, D].map(tab => tab.$TST.maybeMuted),
158+
'initially all tab must not inherit muted status');
159+
}
160+
161+
await browser.tabs.update(tabs.C.id, { muted: true });
162+
await wait(1000);
163+
164+
tabs = await Utils.refreshTabs(tabs);
165+
{
166+
const { A, B, C, D } = tabs;
167+
is([false, false, true, false],
168+
[A, B, C, D].map(tab => tab.$TST.muted),
169+
'only muted tab must have muted status');
170+
is([true, true, true, false],
171+
[A, B, C, D].map(tab => tab.$TST.maybeMuted),
172+
'ancestors must inherit "muted" state from descendant');
173+
}
174+
}
175+

0 commit comments

Comments
 (0)