Bug 1384247 - Check if an HTMLMediaElement can be capture before doing it. r=dminor
MozReview-Commit-ID: EWpf2qA2Yce
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3530,16 +3530,21 @@ HTMLMediaElement::CaptureStreamInternal(
}
already_AddRefed<DOMMediaStream>
HTMLMediaElement::CaptureAudio(ErrorResult& aRv,
MediaStreamGraph* aGraph)
{
MOZ_RELEASE_ASSERT(aGraph);
+ if (!CanBeCaptured(false)) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return nullptr;
+ }
+
RefPtr<DOMMediaStream> stream =
CaptureStreamInternal(false, true, aGraph);
if (!stream) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
return stream.forget();
new file mode 100644
--- /dev/null
+++ b/dom/media/test/crashtests/1384248.html
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <script>
+ try { o1 = document.createElement('audio') } catch(e) { }
+ try { o2 = document.implementation.createDocument('', '', null).adoptNode(o1); } catch(e) { };
+ try { o3 = new AudioContext('alarm') } catch(e) { }
+ try { o3.createMediaElementSource(o1) } catch(e) { }
+ </script>
+ </head>
+</html>
--- a/dom/media/test/crashtests/crashtests.list
+++ b/dom/media/test/crashtests/crashtests.list
@@ -79,16 +79,17 @@ load 1122218.html
load 1127188.html
load 1157994.html
load 1158427.html
load 1185176.html
load 1185192.html
load 1304948.html
load 1319486.html
load 1291702.html
+load 1384248.html
load disconnect-wrong-destination.html
load analyser-channels-1.html
load audiocontext-double-suspend.html
load buffer-source-duration-1.html
load buffer-source-ended-1.html
load buffer-source-resampling-start-1.html
load buffer-source-slow-resampling-1.html
load doppler-1.html