mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 654550 - Add a preference to disable media statistics. r = padenot,jaws
This commit is contained in:
parent
e420bef0bf
commit
3feece5ab1
@ -47,6 +47,9 @@ public:
|
||||
const nsAString& aValue,
|
||||
nsAttrValue& aResult);
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
|
||||
|
||||
static void Init();
|
||||
|
||||
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
|
||||
|
@ -33,12 +33,15 @@
|
||||
#include "nsIPowerManagerService.h"
|
||||
#include "MediaError.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Video)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
static bool sVideoStatsEnabled;
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(HTMLVideoElement, HTMLMediaElement)
|
||||
NS_IMPL_RELEASE_INHERITED(HTMLVideoElement, HTMLMediaElement)
|
||||
|
||||
@ -160,6 +163,9 @@ NS_IMPL_URI_ATTR(HTMLVideoElement, Poster, poster)
|
||||
uint32_t HTMLVideoElement::MozParsedFrames() const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
||||
if (!sVideoStatsEnabled) {
|
||||
return 0;
|
||||
}
|
||||
return mDecoder ? mDecoder->GetFrameStatistics().GetParsedFrames() : 0;
|
||||
}
|
||||
|
||||
@ -172,6 +178,9 @@ NS_IMETHODIMP HTMLVideoElement::GetMozParsedFrames(uint32_t *aMozParsedFrames)
|
||||
uint32_t HTMLVideoElement::MozDecodedFrames() const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
||||
if (!sVideoStatsEnabled) {
|
||||
return 0;
|
||||
}
|
||||
return mDecoder ? mDecoder->GetFrameStatistics().GetDecodedFrames() : 0;
|
||||
}
|
||||
|
||||
@ -184,6 +193,9 @@ NS_IMETHODIMP HTMLVideoElement::GetMozDecodedFrames(uint32_t *aMozDecodedFrames)
|
||||
uint32_t HTMLVideoElement::MozPresentedFrames() const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
||||
if (!sVideoStatsEnabled) {
|
||||
return 0;
|
||||
}
|
||||
return mDecoder ? mDecoder->GetFrameStatistics().GetPresentedFrames() : 0;
|
||||
}
|
||||
|
||||
@ -196,6 +208,9 @@ NS_IMETHODIMP HTMLVideoElement::GetMozPresentedFrames(uint32_t *aMozPresentedFra
|
||||
uint32_t HTMLVideoElement::MozPaintedFrames()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
||||
if (!sVideoStatsEnabled) {
|
||||
return 0;
|
||||
}
|
||||
layers::ImageContainer* container = GetImageContainer();
|
||||
return container ? container->GetPaintCount() : 0;
|
||||
}
|
||||
@ -282,5 +297,10 @@ HTMLVideoElement::WakeLockUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLVideoElement::Init()
|
||||
{
|
||||
Preferences::AddBoolVarCache(&sVideoStatsEnabled, "media.video_stats.enabled");
|
||||
}
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -72,6 +72,7 @@ MOCHITEST_FILES = \
|
||||
test_bug493187.html \
|
||||
test_bug495145.html \
|
||||
test_bug495300.html \
|
||||
test_bug654550.html \
|
||||
test_bug686942.html \
|
||||
test_can_play_type.html \
|
||||
test_can_play_type_mpeg.html \
|
||||
|
@ -16,6 +16,13 @@ var gSmallTests = [
|
||||
{ name:"bogus.duh", type:"bogus/duh" }
|
||||
];
|
||||
|
||||
// Used by test_bug654550.html, for videoStats preference
|
||||
var gVideoTests = [
|
||||
{ name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266 },
|
||||
{ name:"seek.webm", type:"video/webm", width:320, height:240, duration:3.966 },
|
||||
{ name:"bogus.duh", type:"bogus/duh" }
|
||||
];
|
||||
|
||||
// Used by test_progress to ensure we get the correct progress information
|
||||
// during resource download.
|
||||
var gProgressTests = [
|
||||
|
70
content/media/test/test_bug654550.html
Normal file
70
content/media/test/test_bug654550.html
Normal file
@ -0,0 +1,70 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=654550
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Test for Bug 654550</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>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=654550">Mozilla Bug 654550</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/* Test for Bug 654550 */
|
||||
|
||||
var manager = new MediaTestManager;
|
||||
|
||||
function checkStats(v, aShouldBeEnabled) {
|
||||
if (aShouldBeEnabled) {
|
||||
ok(v.mozParsedFrames != 0,
|
||||
"At least one value should be different from 0 if stats are enabled");
|
||||
} else {
|
||||
ok(!v.mozParsedFrames,
|
||||
"mozParsedFrames should be 0 if stats are disabled");
|
||||
ok(!v.mozDecodedFrames,
|
||||
"mozDecodedFrames should be 0 if stats are disabled");
|
||||
ok(!v.mozPresentedFrames,
|
||||
"mozPresentedFrames should be 0 if stats are disabled");
|
||||
ok(!v.mozPaintedFrames,
|
||||
"mozPaintedFrames should be 0 if stats are disabled");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function ontimeupdate(event) {
|
||||
var v = event.target;
|
||||
if (SpecialPowers.getBoolPref("media.video_stats.enabled")) {
|
||||
checkStats(v, true);
|
||||
SpecialPowers.setBoolPref("media.video_stats.enabled", false);
|
||||
} else {
|
||||
checkStats(v, false);
|
||||
SpecialPowers.setBoolPref("media.video_stats.enabled", true);
|
||||
v.removeEventListener("timeupdate", ontimeupdate);
|
||||
SpecialPowers.clearUserPref("media.video_stats.enabled");
|
||||
manager.finished(v.token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function startTest(test, token) {
|
||||
var v = document.createElement('video');
|
||||
v.token = token;
|
||||
v.src = test.name;
|
||||
manager.started(token);
|
||||
v.play();
|
||||
SpecialPowers.setBoolPref("media.video_stats.enabled", true);
|
||||
v.addEventListener("timeupdate", ontimeupdate);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
manager.runTests(gVideoTests, startTest);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -116,6 +116,7 @@ using namespace mozilla::system;
|
||||
#include "mozilla/dom/time/DateCacheCleaner.h"
|
||||
#include "nsIMEStateManager.h"
|
||||
#include "nsDocument.h"
|
||||
#include "mozilla/dom/HTMLVideoElement.h"
|
||||
|
||||
extern void NS_ShutdownEventTargetChainItemRecyclePool();
|
||||
|
||||
@ -272,6 +273,8 @@ nsLayoutStatics::Initialize()
|
||||
|
||||
InitializeDateCacheCleaner();
|
||||
|
||||
HTMLVideoElement::Init();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -232,6 +232,9 @@ pref("media.autoplay.enabled", true);
|
||||
// MediaDecoderReader's mVideoQueue.
|
||||
pref("media.video-queue.default-size", 10);
|
||||
|
||||
// Whether to disable the video stats to prevent fingerprinting
|
||||
pref("media.video_stats.enabled", true);
|
||||
|
||||
// Whether to enable the audio writing APIs on the audio element
|
||||
pref("media.audio_data.enabled", true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user