Bug 1244768 part 5 - reject pending play promises while the playback reaching the end; r=jwwang
authorKaku Kuo <tkuo@mozilla.com>
Fri, 19 Aug 2016 11:52:04 +0800
changeset 325499 391d56cd85f751cf7f4682c41e842c795664d0a3
parent 325498 fafd16dfeac96ca44c5f704f049e23d40fabd591
child 325500 ed3195c64abcb14360766eff8f13ae715a4fc756
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1244768
milestone53.0a1
Bug 1244768 part 5 - reject pending play promises while the playback reaching the end; r=jwwang 4.8.12.8 https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-ended MozReview-Commit-ID: H7Tw0XGzpW0
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -5141,25 +5141,29 @@ void HTMLMediaElement::PlaybackEnded()
     DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
   }
 
   if (HasAttr(kNameSpaceID_None, nsGkAtoms::loop)) {
     SetCurrentTime(0);
     return;
   }
 
-  Pause();
+  FireTimeUpdate(false);
+
+  if (!mPaused) {
+    Pause();
+    AsyncRejectPendingPlayPromises(NS_ERROR_DOM_MEDIA_ABORT_ERR);
+  }
 
   if (mSrcStream) {
     // A MediaStream that goes from inactive to active shall be eligible for
     // autoplay again according to the mediacapture-main spec.
     mAutoplaying = true;
   }
 
-  FireTimeUpdate(false);
   DispatchAsyncEvent(NS_LITERAL_STRING("ended"));
 }
 
 void HTMLMediaElement::SeekStarted()
 {
   DispatchAsyncEvent(NS_LITERAL_STRING("seeking"));
 }