diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties index c3d216bea0f6..c23163a04912 100644 --- a/dom/locales/en-US/chrome/dom/dom.properties +++ b/dom/locales/en-US/chrome/dom/dom.properties @@ -93,6 +93,10 @@ MediaDecodeAudioDataUnknownError=An unknown error occured while processing decod MediaDecodeAudioDataInvalidContent=The buffer passed to decodeAudioData contains invalid content which cannot be decoded successfully. # LOCALIZATION NOTE: Do not translate decodeAudioData. MediaDecodeAudioDataNoAudio=The buffer passed to decodeAudioData does not contain any audio. +# LOCALIZATION NOTE: Do not translate HTMLMediaElement and createMediaElementSource. +MediaElementAudioSourceNodeCrossOrigin=The HTMLMediaElement passed to createMediaElementSource has a cross-origin resource, the node will output silence. +# LOCALIZATION NOTE: Do not translate MediaStream and createMediaStreamSource. +MediaStreamAudioSourceNodeCrossOrigin=The MediaStream passed to createMediaStreamSource has a cross-origin resource, the node it will output silence. MediaLoadExhaustedCandidates=All candidate resources failed to load. Media load paused. MediaLoadSourceMissingSrc= element has no "src" attribute. Media resource load failed. # LOCALIZATION NOTE: %1$S is the Http error code the server returned (e.g. 404, 500, etc), %2$S is the URL of the media resource which failed to load. diff --git a/dom/media/webaudio/MediaElementAudioSourceNode.h b/dom/media/webaudio/MediaElementAudioSourceNode.h index 1a77dd964a69..f6791f355afb 100644 --- a/dom/media/webaudio/MediaElementAudioSourceNode.h +++ b/dom/media/webaudio/MediaElementAudioSourceNode.h @@ -25,6 +25,11 @@ public: return "MediaElementAudioSourceNode"; } + const char* CrossOriginErrorString() const override + { + return "MediaElementAudioSourceNodeCrossOrigin"; + } + size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); diff --git a/dom/media/webaudio/MediaStreamAudioSourceNode.cpp b/dom/media/webaudio/MediaStreamAudioSourceNode.cpp index f9905f520f71..639208e7a1d7 100644 --- a/dom/media/webaudio/MediaStreamAudioSourceNode.cpp +++ b/dom/media/webaudio/MediaStreamAudioSourceNode.cpp @@ -165,8 +165,9 @@ MediaStreamAudioSourceNode::PrincipalChanged(MediaStreamTrack* aMediaStreamTrack MOZ_ASSERT(aMediaStreamTrack == mInputTrack); bool subsumes = false; + nsIDocument* doc = nullptr; if (nsPIDOMWindowInner* parent = Context()->GetParentObject()) { - nsIDocument* doc = parent->GetExtantDoc(); + doc = parent->GetExtantDoc(); if (doc) { nsIPrincipal* docPrincipal = doc->NodePrincipal(); nsIPrincipal* trackPrincipal = aMediaStreamTrack->GetPrincipal(); @@ -176,8 +177,16 @@ MediaStreamAudioSourceNode::PrincipalChanged(MediaStreamTrack* aMediaStreamTrack } } auto stream = static_cast(mStream.get()); - stream->SetInt32Parameter(MediaStreamAudioSourceNodeEngine::ENABLE, - subsumes || aMediaStreamTrack->GetCORSMode() != CORS_NONE); + bool enabled = subsumes || aMediaStreamTrack->GetCORSMode() != CORS_NONE; + stream->SetInt32Parameter(MediaStreamAudioSourceNodeEngine::ENABLE, enabled); + + if (!enabled && doc) { + nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, + NS_LITERAL_CSTRING("Web Audio"), + doc, + nsContentUtils::eDOM_PROPERTIES, + CrossOriginErrorString()); + } } size_t diff --git a/dom/media/webaudio/MediaStreamAudioSourceNode.h b/dom/media/webaudio/MediaStreamAudioSourceNode.h index fc6049838ea5..10df404fe9e5 100644 --- a/dom/media/webaudio/MediaStreamAudioSourceNode.h +++ b/dom/media/webaudio/MediaStreamAudioSourceNode.h @@ -62,6 +62,11 @@ public: return "MediaStreamAudioSourceNode"; } + virtual const char* CrossOriginErrorString() const + { + return "MediaStreamAudioSourceNodeCrossOrigin"; + } + size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override; size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;