Bug 1349456 part 2 - mark elemet as tainted while captured via MozCaptureStream(); r?jwwang
MozReview-Commit-ID: 1V776bLuH43
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1527,22 +1527,17 @@ HTMLMediaElement::SetVisible(bool aVisib
}
mDecoder->SetForcedHidden(!aVisible);
}
already_AddRefed<layers::Image>
HTMLMediaElement::GetCurrentImage()
{
- // Mark the decoder owned by the element as tainted so that the
- // suspend-video-decoder is disabled.
- mHasSuspendTaint = true;
- if (mDecoder) {
- mDecoder->SetSuspendTaint(true);
- }
+ MarkAsTainted();
// TODO: In bug 1345404, handle case when video decoder is already suspended.
ImageContainer* container = GetImageContainer();
if (!container) {
return nullptr;
}
AutoLockImage lockImage(container);
@@ -3330,16 +3325,17 @@ HTMLMediaElement::AddCaptureMediaTrackTo
already_AddRefed<DOMMediaStream>
HTMLMediaElement::CaptureStreamInternal(bool aFinishWhenEnded,
bool aCaptureAudio,
MediaStreamGraph* aGraph)
{
MOZ_RELEASE_ASSERT(aGraph);
MarkAsContentSource(CallerAPI::CAPTURE_STREAM);
+ MarkAsTainted();
nsPIDOMWindowInner* window = OwnerDoc()->GetInnerWindow();
if (!window) {
return nullptr;
}
if (ContainsRestrictedContent()) {
return nullptr;
}
@@ -7486,16 +7482,26 @@ private:
};
already_AddRefed<GMPCrashHelper>
HTMLMediaElement::CreateGMPCrashHelper()
{
return MakeAndAddRef<MediaElementGMPCrashHelper>(this);
}
+void
+HTMLMediaElement::MarkAsTainted()
+{
+ mHasSuspendTaint = true;
+
+ if (mDecoder) {
+ mDecoder->SetSuspendTaint(true);
+ }
+}
+
bool HasDebuggerPrivilege(JSContext* aCx, JSObject* aObj)
{
return nsContentUtils::CallerHasPermission(aCx,
NS_LITERAL_STRING("debugger"));
}
} // namespace dom
} // namespace mozilla
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -1305,16 +1305,20 @@ protected:
// and queues a task to resolve them also to dispatch a "playing" event.
void NotifyAboutPlaying();
already_AddRefed<Promise> CreateDOMPromise(ErrorResult& aRv) const;
// Pass information for deciding the video decode mode to decoder.
void NotifyDecoderActivityChanges() const;
+ // Mark the decoder owned by the element as tainted so that the
+ // suspend-video-decoder is disabled.
+ void MarkAsTainted();
+
// The current decoder. Load() has been called on this decoder.
// At most one of mDecoder and mSrcStream can be non-null.
RefPtr<MediaDecoder> mDecoder;
// The DocGroup-specific AbstractThread::MainThread() of this HTML element.
RefPtr<AbstractThread> mAbstractMainThread;
// Observers listening to changes to the mDecoder principal.