Bug 1701276 - Adjust currentSrc behaviour to match the spec more closely. r=bryce

Firefox and Chrome support setting `src` with an `ObjectURL`. This is
technically a URL and should be treated as such. Firefox recently changed to
return `""` when a `MediaSource` is playing, and this is wrong, because even
though it's playing a from a "Media Provider Object", it got loaded from the
`src` attribute, so should have a non-null `currentSrc`, which should be the
blob url (`blob:origin/<an uuid>`). In this case, `currentSrc` is a string that
is opaque and doesn't allow introspection but refers to the "real" `MediaSource`
or `Blob`.

If the same `MediaSource` is loaded via the `srcObject` attribute (that Firefox
and Chrome don't support), then `currentSrc` should return `""` and `srcObject`
still has the object set to it to understand what the HTMLMediaElement is
playing. We'll implement and test this later.

Differential Revision: https://phabricator.services.mozilla.com/D110290
This commit is contained in:
Paul Adenot
2021-04-01 12:28:50 +00:00
parent 46194f8706
commit 22c499277c
2 changed files with 21 additions and 1 deletions

View File

@@ -6603,9 +6603,17 @@ void HTMLMediaElement::FireTimeUpdate(TimeupdateType aType) {
MediaError* HTMLMediaElement::GetError() const { return mErrorSink->mError; }
void HTMLMediaElement::GetCurrentSpec(nsCString& aString) {
// If playing a regular URL, an ObjectURL of a Blob/File, return that.
if (mLoadingSrc) {
mLoadingSrc->GetSpec(aString);
} else if (mSrcMediaSource) {
// If playing an ObjectURL, and it's a MediaSource, return the value of the
// `src` attribute.
nsAutoString src;
GetSrc(src);
CopyUTF16toUTF8(src, aString);
} else {
// Playing e.g. a MediaStream via an object URL - return an empty string
aString.Truncate();
}
}