mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
0d460e3432
This is split from the previous changeset since if we include dom/ the file size is too large for phabricator to handle. This is an autogenerated commit to handle scripts loading mochitest harness files, in the simple case where the script src is on the same line as the tag. This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170 using the `--part 2` argument. Differential Revision: https://phabricator.services.mozilla.com/D27457 --HG-- extra : moz-landing-system : lando
159 lines
5.0 KiB
HTML
159 lines
5.0 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Autoplay policy test</title>
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
<script type="text/javascript" src="manifest.js"></script>
|
|
<script type="text/javascript" src="AutoplayTestUtils.js"></script>
|
|
</head>
|
|
<body>
|
|
<pre id="test">
|
|
<script>
|
|
|
|
// Tests that videos can only play audibly in windows/frames
|
|
// which have been activated by same-origin user gesture.
|
|
|
|
gTestPrefs.push(["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
|
|
["media.autoplay.enabled.user-gestures-needed", true]);
|
|
|
|
SpecialPowers.pushPrefEnv({'set': gTestPrefs}, () => {
|
|
runTest();
|
|
});
|
|
|
|
let test_cases = [
|
|
{
|
|
name: "inaudible playback in unactivated same-origin iframe in activated parent allowed",
|
|
muted: true,
|
|
same_origin_child: true,
|
|
activated_child: false,
|
|
activated_parent: true,
|
|
should_play: true,
|
|
},
|
|
|
|
{
|
|
name: "inaudible playback in unactivated same-origin iframe in unactivated parent allowed",
|
|
muted: true,
|
|
same_origin_child: true,
|
|
activated_child: false,
|
|
activated_parent: false,
|
|
should_play: true,
|
|
},
|
|
|
|
{
|
|
name: "audible playback in unactivated same-origin iframe in activated parent allowed",
|
|
muted: false,
|
|
same_origin_child: true,
|
|
activated_child: false,
|
|
activated_parent: true,
|
|
should_play: true,
|
|
},
|
|
|
|
{
|
|
name: "audible playback in unactivated same-origin iframe in unactivated parent blocked",
|
|
muted: false,
|
|
same_origin_child: true,
|
|
activated_child: false,
|
|
activated_parent: false,
|
|
should_play: false,
|
|
},
|
|
|
|
{
|
|
name: "inaudible playback in unactivated cross-origin iframe in activated parent allowed",
|
|
muted: true,
|
|
same_origin_child: false,
|
|
activated_child: false,
|
|
activated_parent: true,
|
|
should_play: true,
|
|
},
|
|
|
|
{
|
|
name: "inaudible playback in unactivated cross-origin iframe in unactivated parent allowed",
|
|
muted: true,
|
|
same_origin_child: false,
|
|
activated_child: false,
|
|
activated_parent: false,
|
|
should_play: true,
|
|
},
|
|
|
|
{
|
|
name: "audible playback in unactivated cross-origin iframe in activated parent allowed",
|
|
muted: false,
|
|
same_origin_child: false,
|
|
activated_child: false,
|
|
activated_parent: true,
|
|
should_play: true,
|
|
},
|
|
|
|
{
|
|
name: "audible playback in unactivated cross-origin iframe in unactivated parent blocked",
|
|
muted: false,
|
|
same_origin_child: false,
|
|
activated_child: false,
|
|
activated_parent: false,
|
|
should_play: false,
|
|
},
|
|
|
|
{
|
|
name: "audible playback in activated cross-origin iframe allowed",
|
|
muted: false,
|
|
same_origin_child: false,
|
|
activated_child: true,
|
|
activated_parent: false,
|
|
should_play: true,
|
|
},
|
|
|
|
{
|
|
name: "audible playback in activated document allowed",
|
|
muted: false,
|
|
activated_parent: true,
|
|
should_play: true,
|
|
},
|
|
|
|
{
|
|
name: "audible playback in unactivated document blocked",
|
|
muted: false,
|
|
activated_parent: false,
|
|
should_play: false,
|
|
},
|
|
|
|
{
|
|
name: "inaudible playback in activated document allowed",
|
|
muted: true,
|
|
activated_parent: true,
|
|
should_play: true,
|
|
},
|
|
|
|
{
|
|
name: "inaudible playback in unactivated document allowed",
|
|
muted: true,
|
|
activated_parent: false,
|
|
should_play: true,
|
|
},
|
|
|
|
];
|
|
|
|
let child_url = "file_autoplay_policy_activation_window.html";
|
|
|
|
async function runTest() {
|
|
for (test_case of test_cases) {
|
|
// Run each test in a new window, to ensure its user gesture
|
|
// activation state isn't tainted by preceeding tests.
|
|
let child = window.open(child_url, "", "width=500,height=500");
|
|
await once(child, "load");
|
|
child.postMessage(test_case, window.origin);
|
|
let result = await nextWindowMessage();
|
|
SimpleTest.is(result.data.allowedToPlay, test_case.should_play, "allowed - " + test_case.name);
|
|
SimpleTest.is(result.data.played, test_case.should_play, "played - " + test_case.name);
|
|
child.close();
|
|
}
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|