mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Backed out 2 changesets (bug 1457048) for multiple failures. CLOSED TREE
Backed out changeset a5d71f8bf413 (bug 1457048) Backed out changeset cd70fc188bc8 (bug 1457048)
This commit is contained in:
parent
d7eacf6ae5
commit
48f71154c5
@ -600,16 +600,6 @@ var gPermissionObject = {
|
||||
* don't want to expose a "Hide Prompt" button to the user through pageinfo.
|
||||
*/
|
||||
|
||||
"autoplay-media": {
|
||||
exactHostMatch: true,
|
||||
getDefault() {
|
||||
if (Services.prefs.getBoolPref("media.autoplay.enabled")) {
|
||||
return SitePermissions.ALLOW;
|
||||
}
|
||||
return SitePermissions.BLOCK;
|
||||
}
|
||||
},
|
||||
|
||||
"image": {
|
||||
states: [ SitePermissions.ALLOW, SitePermissions.BLOCK ],
|
||||
},
|
||||
|
@ -10,13 +10,18 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "mozilla/dom/HTMLMediaElementBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "MediaManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/* static */ bool
|
||||
AutoplayPolicy::IsDocumentAllowedToPlay(nsIDocument* aDoc)
|
||||
{
|
||||
return aDoc ? aDoc->HasBeenUserActivated() : false;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
AutoplayPolicy::IsMediaElementAllowedToPlay(NotNull<HTMLMediaElement*> aElement)
|
||||
{
|
||||
@ -40,7 +45,7 @@ AutoplayPolicy::IsMediaElementAllowedToPlay(NotNull<HTMLMediaElement*> aElement)
|
||||
// If elelement is blessed, it would always be allowed to play().
|
||||
return aElement->IsBlessed() ||
|
||||
EventStateManager::IsHandlingUserInput();
|
||||
}
|
||||
}
|
||||
|
||||
// Muted content
|
||||
if (aElement->Volume() == 0.0 || aElement->Muted()) {
|
||||
@ -54,18 +59,7 @@ AutoplayPolicy::IsMediaElementAllowedToPlay(NotNull<HTMLMediaElement*> aElement)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Whitelisted.
|
||||
if (nsContentUtils::IsExactSitePermAllow(
|
||||
aElement->NodePrincipal(), "autoplay-media")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Activated by user gesture.
|
||||
if (aElement->OwnerDoc()->HasBeenUserActivated()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return AutoplayPolicy::IsDocumentAllowedToPlay(aElement->OwnerDoc());
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
@ -25,13 +25,14 @@ class HTMLMediaElement;
|
||||
* conditions is true.
|
||||
* 1) Owner document is activated by user gestures
|
||||
* We restrict user gestures to "mouse click", "keyboard press" and "touch".
|
||||
* 2) Muted media content or video without audio content.
|
||||
* 3) Document's origin has the "autoplay-media" permission.
|
||||
* 2) Muted media content or video without audio content
|
||||
*/
|
||||
class AutoplayPolicy
|
||||
{
|
||||
public:
|
||||
static bool IsMediaElementAllowedToPlay(NotNull<HTMLMediaElement*> aElement);
|
||||
private:
|
||||
static bool IsDocumentAllowedToPlay(nsIDocument* aDoc);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -25,15 +25,3 @@ function log(msg) {
|
||||
log_pane.appendChild(document.createTextNode(msg));
|
||||
log_pane.appendChild(document.createElement("br"));
|
||||
}
|
||||
|
||||
const autoplayPermission = "autoplay-media";
|
||||
|
||||
async function pushAutoplayAllowedPermission() {
|
||||
return new Promise((resolve, reject) => {
|
||||
SpecialPowers.pushPermissions([{
|
||||
'type': autoplayPermission,
|
||||
'allow': true,
|
||||
'context': document
|
||||
}], resolve);
|
||||
});
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Autoplay policy window</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
<script type="text/javascript" src="AutoplayTestUtils.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script>
|
||||
|
||||
window.ok = window.opener.ok;
|
||||
window.is = window.opener.is;
|
||||
window.info = window.opener.info;
|
||||
|
||||
async function testAutoplayPermission(testCase, parentWindow) {
|
||||
info("trying to play origin=" + testCase.origin + " shouldPlay=" + testCase.shouldPlay);
|
||||
const url = testCase.origin + "/tests/dom/media/test/file_autoplay_policy_activation_frame.html"
|
||||
info("canPlayIn " + url);
|
||||
|
||||
// Create a child iframe...
|
||||
var frame = document.createElement("iframe");
|
||||
frame.src = url;
|
||||
// Wait for it to load...
|
||||
document.body.appendChild(frame);
|
||||
info("awaiting loaded");
|
||||
await once(frame, "load");
|
||||
// Ask the child iframe to try to play video.
|
||||
info("loaded, trying to play");
|
||||
frame.contentWindow.postMessage("play-audible", "*");
|
||||
// Wait for the iframe to tell us whether it could play video.
|
||||
let result = await nextWindowMessage();
|
||||
is(result.data.played, testCase.shouldPlay, testCase.message);
|
||||
}
|
||||
|
||||
nextWindowMessage().then(
|
||||
async (event) => {
|
||||
try {
|
||||
await testAutoplayPermission(event.data, event.source);
|
||||
} catch (e) {
|
||||
ok(false, "Caught exception " + e + " " + e.message + " " + e.stackTrace);
|
||||
}
|
||||
event.source.postMessage("done", "*");
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -442,7 +442,6 @@ support-files =
|
||||
file_autoplay_policy_unmute_pauses.html
|
||||
file_autoplay_policy_activation_window.html
|
||||
file_autoplay_policy_activation_frame.html
|
||||
file_autoplay_policy_permission.html
|
||||
file_autoplay_policy_play_before_loadedmetadata.html
|
||||
flac-s24.flac
|
||||
flac-s24.flac^headers^
|
||||
@ -705,8 +704,6 @@ skip-if = android_version == '23' # bug 1424903
|
||||
skip-if = android_version == '23' # bug 1424903
|
||||
[test_autoplay_policy_play_before_loadedmetadata.html]
|
||||
skip-if = android_version == '23' # bug 1424903
|
||||
[test_autoplay_policy_permission.html]
|
||||
skip-if = android_version == '23' # bug 1424903
|
||||
[test_buffered.html]
|
||||
skip-if = android_version == '15' || android_version == '22' # bug 1308388, android(bug 1232305)
|
||||
[test_bug448534.html]
|
||||
|
@ -1,77 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Autoplay policy test</title>
|
||||
<script type="text/javascript" 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 origins with "autoplay-media" permission can autoplay.
|
||||
|
||||
gTestPrefs.push(["media.autoplay.enabled", false],
|
||||
["media.autoplay.enabled.user-gestures-needed", true]);
|
||||
|
||||
SpecialPowers.pushPrefEnv({ 'set': gTestPrefs }, () => {
|
||||
runTest();
|
||||
});
|
||||
|
||||
async function canPlayIn(testCase) {
|
||||
// Run test in a new window, to ensure its user gesture
|
||||
// activation state isn't tainted by preceeding tests.
|
||||
let child = window.open("file_autoplay_policy_permission.html", "", "width=500,height=500");
|
||||
await once(child, "load");
|
||||
child.postMessage(testCase, "*");
|
||||
let result = await nextWindowMessage();
|
||||
child.close();
|
||||
return result.played == true;
|
||||
}
|
||||
|
||||
async function runTest() {
|
||||
// First verify that we can't play in a document unwhitelisted.
|
||||
is(window.origin, "http://mochi.test:8888", "Origin should be as we assume, otherwise the rest of the test is bogus!");
|
||||
|
||||
await canPlayIn({
|
||||
origin: "http://mochi.test:8888",
|
||||
shouldPlay: false,
|
||||
message: "Should not be able to play unwhitelisted."
|
||||
});
|
||||
|
||||
// Add our origin to the whitelist.
|
||||
await pushAutoplayAllowedPermission();
|
||||
|
||||
// Now we should be able to play...
|
||||
await canPlayIn({
|
||||
origin: "http://mochi.test:8888",
|
||||
shouldPlay: true,
|
||||
message: "Should be able to play since whitelisted."
|
||||
});
|
||||
|
||||
// But sub-origins should not.
|
||||
await canPlayIn({
|
||||
origin: "http://test1.mochi.test:8888",
|
||||
shouldPlay: false,
|
||||
message: "Sub origin should not count as whitelisted."
|
||||
});
|
||||
await canPlayIn({
|
||||
origin: "http://sub1.test1.mochi.test:8888",
|
||||
shouldPlay: false,
|
||||
message: "Sub-sub-origins should not count as whitelisted."
|
||||
});
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user