Bug 1274626 part 1 - add a method to HTMLMediaElement for debugging visibilty change; r=jwwang,ehsan draft
authorKaku Kuo <tkuo@mozilla.com>
Thu, 28 Jul 2016 16:09:02 +0800
changeset 396016 f785c04568430116ab60c2b01c334af52c6f8b47
parent 395624 6608e5864780589b25d5421c3d3673ab30c4c318
child 396017 6696ee41757de6286fc5153e1ba0d79a745449af
push id24896
push usertkuo@mozilla.com
push dateWed, 03 Aug 2016 07:58:00 +0000
reviewersjwwang, ehsan
bugs1274626
milestone51.0a1
Bug 1274626 part 1 - add a method to HTMLMediaElement for debugging visibilty change; r=jwwang,ehsan MozReview-Commit-ID: B1gAc0KfmCQ
dom/html/HTMLMediaElement.cpp
dom/html/HTMLMediaElement.h
dom/webidl/HTMLMediaElement.webidl
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -792,16 +792,27 @@ HTMLMediaElement::GetMozDebugReaderData(
 void
 HTMLMediaElement::MozDumpDebugInfo()
 {
   if (mDecoder) {
     mDecoder->DumpDebugInfo();
   }
 }
 
+void
+HTMLMediaElement::SetVisible(bool aVisible)
+{
+  if (!mDecoder) {
+    return;
+  }
+
+  mDecoder->NotifyOwnerActivityChanged(aVisible);
+
+}
+
 already_AddRefed<DOMMediaStream>
 HTMLMediaElement::GetSrcObject() const
 {
   NS_ASSERTION(!mSrcAttrStream || mSrcAttrStream->GetPlaybackStream(),
                "MediaStream should have been set up properly");
   RefPtr<DOMMediaStream> stream = mSrcAttrStream;
   return stream.forget();
 }
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -601,16 +601,18 @@ public:
 
   already_AddRefed<MediaSource> GetMozMediaSourceObject() const;
   // Returns a string describing the state of the media player internal
   // data. Used for debugging purposes.
   void GetMozDebugReaderData(nsAString& aString);
 
   void MozDumpDebugInfo();
 
+  void SetVisible(bool aVisible);
+
   already_AddRefed<DOMMediaStream> GetSrcObject() const;
   void SetSrcObject(DOMMediaStream& aValue);
   void SetSrcObject(DOMMediaStream* aValue);
 
   // TODO: remove prefixed versions soon (1183495).
   already_AddRefed<DOMMediaStream> GetMozSrcObject() const;
   void SetMozSrcObject(DOMMediaStream& aValue);
   void SetMozSrcObject(DOMMediaStream* aValue);
--- a/dom/webidl/HTMLMediaElement.webidl
+++ b/dom/webidl/HTMLMediaElement.webidl
@@ -209,8 +209,17 @@ partial interface HTMLMediaElement {
  *     beginning time, then the SeekToNextFrame() operation sets the media's
  *     currentTime to the duration of the media source and dispatches a "seeked"
  *     event and an "ended" event.
  */
 partial interface HTMLMediaElement {
   [Throws, Pref="media.seekToNextFrame.enabled"]
   Promise<void> seekToNextFrame();
 };
+
+/*
+ * This is an API for simulating visibility changes to help debug and write
+ * tests about suspend-video-decoding.
+ */
+partial interface HTMLMediaElement {
+  [Pref="media.test.setVisible"]
+  void setVisible(boolean aVisible);
+};