Bug 1133483 - Dispatch |NoSupportedMediaSourceError| to main thread in |SelectResource|. r=jwwang
authorctai <ctai@mozilla.com>
Fri, 18 Nov 2016 11:04:36 +0800
changeset 324623 3b47698f77033ea2e0e0d812ece1f4a2c651b53b
parent 324622 357234ded571f22c456f3076b90f2c2cf5ca6950
child 324624 9f8294cdd9bb9f672993e62543696d182ff268a8
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1133483
milestone53.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
@@ -1754,17 +1754,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()