Bug 1384247 - Check if an HTMLMediaElement can be capture before doing it. r=dminor
authorPaul Adenot <paul@paul.cx>
Thu, 27 Jul 2017 16:02:28 +0200
changeset 420425 b5d83e1d3a96995d3bb0dba9785623716c5a3d90
parent 420424 6e3ba727a94a487b0df71986d7456101a3486dbf
child 420426 4de88c868d39d9da24acb8836d0b8e45a4457b4c
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdminor
bugs1384247
milestone56.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 1384247 - Check if an HTMLMediaElement can be capture before doing it. r=dminor MozReview-Commit-ID: EWpf2qA2Yce
dom/html/HTMLMediaElement.cpp
dom/media/test/crashtests/1384248.html
dom/media/test/crashtests/crashtests.list
--- 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(true)) {
+    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