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
|
/**
* This test is used to ensure that media would still be able to play even if
* the page has been navigated to a cross-origin url.
*/
"use strict";
add_task(async function setupTestEnvironment() {
await SpecialPowers.pushPrefEnv({
set: [
["media.autoplay.default", 0],
["media.block-autoplay-until-in-foreground", true],
],
});
});
add_task(async function testCrossOriginNavigation() {
info("Create a new foreground tab");
const tab = await BrowserTestUtils.openNewForegroundTab(
window.gBrowser,
"about:blank"
);
info("As tab has been visited, media should be allowed to start");
const MEDIA_FILE = "gizmo.mp4";
await SpecialPowers.spawn(
tab.linkedBrowser,
[getTestWebBasedURL(MEDIA_FILE)],
async url => {
let vid = content.document.createElement("video");
vid.src = url;
ok(
await vid.play().then(
_ => true,
_ => false
),
"video started playing"
);
}
);
info("Navigate to a cross-origin video file");
BrowserTestUtils.startLoadingURIString(
tab.linkedBrowser,
getTestWebBasedURL(MEDIA_FILE, { crossOrigin: true })
);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
info(
"As tab has been visited, a cross-origin media should also be able to start"
);
await SpecialPowers.spawn(tab.linkedBrowser, [], async _ => {
let vid = content.document.querySelector("video");
ok(vid, "Video exists");
ok(
await vid.play().then(
_ => true,
_ => false
),
"video started playing"
);
});
info("Remove tab");
BrowserTestUtils.removeTab(tab);
});
|