2018-02-19 03:31:36 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Autoplay policy test</title>
|
2019-04-16 03:53:28 +00:00
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
2018-02-19 03:31:36 +00:00
|
|
|
<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.
|
|
|
|
|
2018-06-29 13:14:33 +00:00
|
|
|
gTestPrefs.push(["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
|
2018-02-19 03:31:36 +00:00
|
|
|
["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,
|
|
|
|
},
|
|
|
|
|
2018-03-01 04:21:09 +00:00
|
|
|
{
|
Bug 1470346 - Gesture activate all documents in tab, even across origins, upon user interaction. r=smaug
Sometimes when video is playing, a preroll ad plays, and that may be in a cross
origin iframe. If autoplay media is disabled, we require a user gesture in a
document before playback in that document is permitted, and we require each
origin to be gesture activated separately. So in the cross origin preroll video
add case, then the user will have to click once to unblock playback for the
cross origin ad, and then once the preroll ad finishes, the user will have to
click again to activate playback of the same origin content video.
This is a bad user experience.
So we should instead make gesture activation propagate up the doc tree
irrespective of crossing origins. This way, when the user clicks to activate,
all documents in that tab are also also effectively gesture activated, and so
can autoplay.
MozReview-Commit-ID: 1HZQ5zkubR
--HG--
extra : rebase_source : d6b75732548cb1d73b9f82dce60a5e6e97d1da14
2018-06-21 23:52:20 +00:00
|
|
|
name: "audible playback in unactivated cross-origin iframe in activated parent allowed",
|
2018-03-01 04:21:09 +00:00
|
|
|
muted: false,
|
|
|
|
same_origin_child: false,
|
|
|
|
activated_child: false,
|
|
|
|
activated_parent: true,
|
Bug 1470346 - Gesture activate all documents in tab, even across origins, upon user interaction. r=smaug
Sometimes when video is playing, a preroll ad plays, and that may be in a cross
origin iframe. If autoplay media is disabled, we require a user gesture in a
document before playback in that document is permitted, and we require each
origin to be gesture activated separately. So in the cross origin preroll video
add case, then the user will have to click once to unblock playback for the
cross origin ad, and then once the preroll ad finishes, the user will have to
click again to activate playback of the same origin content video.
This is a bad user experience.
So we should instead make gesture activation propagate up the doc tree
irrespective of crossing origins. This way, when the user clicks to activate,
all documents in that tab are also also effectively gesture activated, and so
can autoplay.
MozReview-Commit-ID: 1HZQ5zkubR
--HG--
extra : rebase_source : d6b75732548cb1d73b9f82dce60a5e6e97d1da14
2018-06-21 23:52:20 +00:00
|
|
|
should_play: true,
|
2018-03-01 04:21:09 +00:00
|
|
|
},
|
2018-02-19 03:31:36 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
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();
|
2018-07-25 02:25:17 +00:00
|
|
|
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);
|
2018-02-19 03:31:36 +00:00
|
|
|
child.close();
|
|
|
|
}
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|