blob: be40f6e146823d3f992e994ebc96b2166a1809f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/**
* This test is used to ensure the 'sound-playing' icon would not disappear after
* sites call AudioContext.resume().
*/
"use strict";
function setup_test_preference() {
return SpecialPowers.pushPrefEnv({
set: [
["media.useAudioChannelService.testing", true],
["browser.tabs.delayHidingAudioPlayingIconMS", 0],
],
});
}
async function resumeAudioContext() {
const ac = content.ac;
await ac.resume();
ok(true, "AudioContext is resumed.");
}
async function testResumeRunningAudioContext() {
info(`- create new tab -`);
const tab = await BrowserTestUtils.openNewForegroundTab(
window.gBrowser,
"about:blank"
);
const browser = tab.linkedBrowser;
info(`- create audio context -`);
// We want the same audio context to be used across different content tasks.
await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
content.ac = new content.AudioContext();
const ac = content.ac;
const dest = ac.destination;
const osc = ac.createOscillator();
osc.connect(dest);
osc.start();
});
info(`- wait for 'sound-playing' icon showing -`);
await waitForTabSoundIndicatorAppears(tab);
info(`- resume AudioContext -`);
await SpecialPowers.spawn(browser, [], resumeAudioContext);
info(`- 'sound-playing' icon should still exist -`);
await waitForTabSoundIndicatorAppears(tab);
info(`- remove tab -`);
await BrowserTestUtils.removeTab(tab);
}
add_task(async function start_test() {
info("- setup test preference -");
await setup_test_preference();
info("- start testing -");
await testResumeRunningAudioContext();
});
|