Bug 1384247 - Check if an HTMLMediaElement can be capture before doing it. r=dminor
☠☠ backed out by 2646388a3a8f ☠ ☠
authorPaul Adenot <paul@paul.cx>
Thu, 27 Jul 2017 16:02:28 +0200
changeset 420177 bda427f9dbeb7abf23bfaaecda3dfd3797f4e3f7
parent 420176 85b4584e1a838c8f44e6d342d2562e72c42c191f
child 420178 01ee56745069f2018060ebe46a0b016e6f86a709
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(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