Bug 1133483 - Dispatch |NoSupportedMediaSourceError| to main thread in |SelectResource|. r?jwwang draft
authorctai <ctai@mozilla.com>
Fri, 18 Nov 2016 11:04:36 +0800
changeset 445143 4f9204b9687d0651464b8a0a6574ca17304923b8
parent 427779 f0f1aaf051d6798e1e73d1feee07ca847333167a
child 445144 5a2938afebf16c2f6e3ac0fbab889c71b5091ecb
push id37429
push userbmo:ctai@mozilla.com
push dateTue, 29 Nov 2016 06:35:01 +0000
reviewersjwwang
bugs1133483
milestone52.0a1
Bug 1133483 - Dispatch |NoSupportedMediaSourceError| to main thread in |SelectResource|. r?jwwang We need to end the synchronous section when the src attribute is empty and then run the "failed with elements step" in non-sync section. MozReview-Commit-ID: DJ7GYqa6aI5
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1207,17 +1207,22 @@ void HTMLMediaElement::SelectResource()
       rv = LoadResource();
       if (NS_SUCCEEDED(rv)) {
         return;
       }
     } else {
       const char16_t* params[] = { src.get() };
       ReportLoadError("MediaLoadInvalidURI", params, ArrayLength(params));
     }
-    NoSupportedMediaSourceError();
+    // The media element has neither a src attribute nor a source element child:
+    // set the networkState to NETWORK_EMPTY, and abort these steps; the
+    // synchronous section ends.
+    nsCOMPtr<nsIRunnable> event =
+        NewRunnableMethod<nsCString>(this, &HTMLMediaElement::NoSupportedMediaSourceError, nsCString());
+    NS_DispatchToMainThread(event);
   } else {
     // Otherwise, the source elements will be used.
     mIsLoadingFromSourceChildren = true;
     LoadFromSourceChildren();
   }
 }
 
 void HTMLMediaElement::NotifyLoadError()