Bug 1453862 - Log to web console when autoplay blocked. r=flod,baku
authoralwu <alwu@mozilla.com>
Wed, 29 Aug 2018 16:51:24 +0000
changeset 433807 9993da7e3300
parent 433806 cc07ed4ce971
child 433808 4804e9ef844f
push id68483
push useralwu@mozilla.com
push dateWed, 29 Aug 2018 16:52:06 +0000
treeherderautoland@9993da7e3300 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflod, baku
bugs1453862
milestone63.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 1453862 - Log to web console when autoplay blocked. r=flod,baku Log to the web console when we block autoplay, in order to help web developers debug their sites. Differential Revision: https://phabricator.services.mozilla.com/D4406
dom/html/HTMLMediaElement.cpp
dom/locales/en-US/chrome/dom/dom.properties
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4122,19 +4122,24 @@ HTMLMediaElement::EnsureAutoplayRequeste
              self->PlayInternal(handlingUserInput);
              self->UpdateCustomPolicyAfterPlayed();
            },
            [self, request](nsresult aError) {
              self->mAutoplayPermissionRequest.Complete();
              AUTOPLAY_LOG("%p Autoplay request denied request=%p",
                           self.get(),
                           request.get());
-             LOG(LogLevel::Debug, ("%s rejecting play promimses", __func__));
+             LOG(LogLevel::Debug, ("%s rejecting play promises", __func__));
              self->AsyncRejectPendingPlayPromises(
                NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR);
+             nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
+                                             NS_LITERAL_CSTRING("Media"),
+                                             self->OwnerDoc(),
+                                             nsContentUtils::eDOM_PROPERTIES,
+                                             "BlockAutoplayError");
            })
     ->Track(mAutoplayPermissionRequest);
 }
 
 void
 HTMLMediaElement::DispatchEventsWhenPlayWasNotAllowed()
 {
   if (StaticPrefs::MediaBlockEventEnabled()) {
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -143,16 +143,17 @@ MediaStreamStopDeprecatedWarning=MediaSt
 # LOCALIZATION NOTE: %S is the URL of the web page which is not served on HTTPS and thus is not encrypted and considered insecure.
 MediaEMEInsecureContextDeprecatedWarning=Using Encrypted Media Extensions at %S on an insecure (i.e. non-HTTPS) context is deprecated and will soon be removed. You should consider switching to a secure origin such as HTTPS.
 # LOCALIZATION NOTE: %S is the URL of the web page which is calling web APIs without passing data (either an audioCapabilities or a videoCapabilities) that will soon be required. See https://bugzilla.mozilla.org/show_bug.cgi?id=1368583#c21 for explanation of this string.
 MediaEMENoCapabilitiesDeprecatedWarning=Calling navigator.requestMediaKeySystemAccess() (at %S) without passing a candidate MediaKeySystemConfiguration containing audioCapabilities or videoCapabilities is deprecated and will soon become unsupported.
 # LOCALIZATION NOTE: %S is the URL of the web page which is calling web APIs without passing data (a "codecs" string in the "contentType") that will soon be required. See https://bugzilla.mozilla.org/show_bug.cgi?id=1368583#c21 for explanation of this string.
 MediaEMENoCodecsDeprecatedWarning=Calling navigator.requestMediaKeySystemAccess() (at %S) passing a candidate MediaKeySystemConfiguration containing audioCapabilities or videoCapabilities without a contentType with a “codecs” string is deprecated and will soon become unsupported.
 # LOCALIZATION NOTE: Do not translate "Mutation Event" and "MutationObserver"
 MutationEventWarning=Use of Mutation Events is deprecated. Use MutationObserver instead.
+BlockAutoplayError=Autoplay is only allowed when approved by the user, the site is activated by the user, or media is muted.
 # LOCALIZATION NOTE: Do not translate "Components"
 ComponentsWarning=The Components object is deprecated. It will soon be removed.
 PluginHangUITitle=Warning: Unresponsive plugin
 PluginHangUIMessage=%S may be busy, or it may have stopped responding. You can stop the plugin now, or you can continue to see if the plugin will complete.
 PluginHangUIWaitButton=Continue
 PluginHangUIStopButton=Stop plugin
 PrefixedFullscreenAPIWarning=Prefixed Fullscreen API is deprecated. Please use unprefixed API for fullscreen. For more help https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
 # LOCALIZATION NOTE: Do not translate "NodeIterator" or "detach()".