Bug 882535 - Set HTMLTrackElement Readiness State during WebVTT Parsing. r=rillian
authorCaitlin Potter <snowball@defpixel.com>
Wed, 12 Jun 2013 22:26:14 -0400
changeset 146604 de0018e03e39fe75b82ca6dffa78507365ce23fa
parent 146603 d1fc221d10a0bf57fee15389164aed7d0519b5fe
child 146605 494c2b42bd9440d2dc68768ee9c10135de5c8cdf
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs882535
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 882535 - Set HTMLTrackElement Readiness State during WebVTT Parsing. r=rillian This patch enables "LOADING", "LOADED" and "ERROR" readiness states to be applied to the Parent HTMLTrackElement, in order to avoid test flakiness, and to comply with the HTML5 draft http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#text-track-readiness-state.
content/media/WebVTTLoadListener.cpp
--- a/content/media/WebVTTLoadListener.cpp
+++ b/content/media/WebVTTLoadListener.cpp
@@ -68,32 +68,36 @@ WebVTTLoadListener::LoadResource()
     NS_ENSURE_TRUE(status != WEBVTT_INVALID_PARAM,
                    NS_ERROR_INVALID_ARG);
     return NS_ERROR_FAILURE;
   }
 
   mParser.own(parser);
   NS_ENSURE_TRUE(mParser != nullptr, NS_ERROR_FAILURE);
 
+  mElement->mReadyState = HTMLTrackElement::LOADING;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 WebVTTLoadListener::OnStartRequest(nsIRequest* aRequest,
                                    nsISupports* aContext)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 WebVTTLoadListener::OnStopRequest(nsIRequest* aRequest,
                                   nsISupports* aContext,
                                   nsresult aStatus)
 {
   webvtt_finish_parsing(mParser);
+  if(mElement->mReadyState != HTMLTrackElement::ERROR) {
+    mElement->mReadyState = HTMLTrackElement::LOADED;
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 WebVTTLoadListener::OnDataAvailable(nsIRequest* aRequest,
                                     nsISupports* aContext,
                                     nsIInputStream* aStream,
                                     uint64_t aOffset,
@@ -222,16 +226,21 @@ WebVTTLoadListener::OnReportError(uint32
   if (aError >= 0) {
     error = webvtt_strerror(aError);
   }
 
   LOG("error: %s(%d:%d) - %s\n", file.get(), aLine, aCol, error);
 #endif
 
   switch(aError) {
+    // Non-recoverable errors require us to abort parsing:
+    case WEBVTT_MALFORMED_TAG:
+      mElement->mReadyState = HTMLTrackElement::ERROR;
+      return -1;
+
     // Errors which should result in dropped cues
     // if the return value is negative:
     case WEBVTT_MALFORMED_TIMESTAMP:
       return -1;
 
     // By default, we can safely ignore other errors
     // or else parsing the document will be aborted regardless
     // of the return value.