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
61
62
63
64
65
66
67
|
/**
* This test is used to ensure site which has granted 'camera' or 'microphone'
* or 'screen' permission could be allowed to autoplay.
*/
"use strict";
const { PermissionTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/PermissionTestUtils.sys.mjs"
);
const VIDEO_PAGE = GetTestWebBasedURL("file_empty.html");
add_task(() => {
return SpecialPowers.pushPrefEnv({
set: [
["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
["media.autoplay.blocking_policy", 0],
["media.autoplay.block-event.enabled", true],
],
});
});
async function testAutoplayWebRTCPermission(args) {
info(`- Starting ${args.name} -`);
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: VIDEO_PAGE,
},
async browser => {
PermissionTestUtils.add(
browser.currentURI,
args.permission,
Services.perms.ALLOW_ACTION
);
await loadAutoplayVideo(browser, args);
await checkVideoDidPlay(browser, args);
// Reset permission.
PermissionTestUtils.remove(browser.currentURI, args.permission);
info(`- Finished ${args.name} -`);
}
);
}
add_task(async function start_test() {
await testAutoplayWebRTCPermission({
name: "Site with camera permission",
permission: "camera",
shouldPlay: true,
mode: "call play",
});
await testAutoplayWebRTCPermission({
name: "Site with microphone permission",
permission: "microphone",
shouldPlay: true,
mode: "call play",
});
await testAutoplayWebRTCPermission({
name: "Site with screen permission",
permission: "screen",
shouldPlay: true,
mode: "call play",
});
});
|