Bug 1383984 - Enable debugging HTMLMediaElement APIs with 'tabs' permission - r=jya,smaug
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 25 Jul 2017 15:53:01 +1200
changeset 419505 67aad6b837d40ddbb785916fe2c69b59aa7103b3
parent 419443 20344022a01d05928707dc47bf064b301ba2adf9
child 419506 1c8ae3d9f7c2973a8a1c132a55b46cbb96f2db97
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)
reviewersjya, smaug
bugs1383984
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 1383984 - Enable debugging HTMLMediaElement APIs with 'tabs' permission - r=jya,smaug While "debugger" is not available yet, we can enable these debugging APIs for extensions that have the "tabs" privilege, which includes the Media Panel Devtools extension, so we/webdev will get better media-playback information. MozReview-Commit-ID: I0MAZH9g0HU
dom/html/HTMLMediaElement.cpp
dom/html/HTMLMediaElement.h
dom/webidl/HTMLMediaElement.webidl
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -7542,20 +7542,22 @@ HTMLMediaElement::MarkAsTainted()
 {
   mHasSuspendTaint = true;
 
   if (mDecoder) {
     mDecoder->SetSuspendTaint(true);
   }
 }
 
-bool HasDebuggerPrivilege(JSContext* aCx, JSObject* aObj)
+bool
+HasDebuggerOrTabsPrivilege(JSContext* aCx, JSObject* aObj)
 {
   return nsContentUtils::CallerHasPermission(aCx,
-                                             NS_LITERAL_STRING("debugger"));
+                                             NS_LITERAL_STRING("debugger")) ||
+         nsContentUtils::CallerHasPermission(aCx, NS_LITERAL_STRING("tabs"));
  }
 
 void
 HTMLMediaElement::AsyncResolveSeekDOMPromiseIfExists()
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (mSeekDOMPromise) {
     RefPtr<dom::Promise> promise = mSeekDOMPromise.forget();
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -1795,15 +1795,16 @@ private:
   nsTArray<nsResolveOrRejectPendingPlayPromisesRunner*> mPendingPlayPromisesRunners;
 
   // A pending seek promise which is created at Seek() method call and is
   // resolved/rejected at AsyncResolveSeekDOMPromiseIfExists()/
   // AsyncRejectSeekDOMPromiseIfExists() methods.
   RefPtr<dom::Promise> mSeekDOMPromise;
 };
 
-// Check if the context is chrome or has the debugger permission
-bool HasDebuggerPrivilege(JSContext* aCx, JSObject* aObj);
+// Check if the context is chrome or has the debugger or tabs permission
+bool
+HasDebuggerOrTabsPrivilege(JSContext* aCx, JSObject* aObj);
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_HTMLMediaElement_h
--- a/dom/webidl/HTMLMediaElement.webidl
+++ b/dom/webidl/HTMLMediaElement.webidl
@@ -95,21 +95,21 @@ interface HTMLMediaElement : HTMLElement
   readonly attribute TextTrackList? textTracks;
   TextTrack addTextTrack(TextTrackKind kind,
                          optional DOMString label = "",
                          optional DOMString language = "");
 };
 
 // Mozilla extensions:
 partial interface HTMLMediaElement {
-  [Func="HasDebuggerPrivilege"]
+  [Func="HasDebuggerOrTabsPrivilege"]
   readonly attribute MediaSource? mozMediaSourceObject;
-  [Func="HasDebuggerPrivilege"]
+  [Func="HasDebuggerOrTabsPrivilege"]
   readonly attribute DOMString mozDebugReaderData;
-  [Func="HasDebuggerPrivilege", NewObject]
+  [Func="HasDebuggerOrTabsPrivilege", NewObject]
   Promise<DOMString> mozRequestDebugInfo();
 
   [Pref="media.test.dumpDebugInfo"]
   void mozDumpDebugInfo();
 
   attribute MediaStream? srcObject;
   // TODO: remove prefixed version soon (1183495).
   attribute MediaStream? mozSrcObject;