Backed out changeset e80a847a8b9b (bug 1533129) for causing perma mda failures in dom/media/mediasource/test/test_isTypeSupportedExtensions.html

--HG--
extra : rebase_source : 434f35ad3363c0c59eea03858f045d122cc3f114
This commit is contained in:
shindli 2019-04-10 06:35:39 +03:00
Родитель 76ab5cf265
Коммит ab80016442
6 изменённых файлов: 6 добавлений и 240 удалений

Просмотреть файл

@ -116,7 +116,7 @@ static int32_t GetParameterAsNumber(const nsContentTypeParser& aParser,
MediaExtendedMIMEType::MediaExtendedMIMEType(
const nsACString& aOriginalString, const nsACString& aMIMEType,
bool aHaveCodecs, const nsAString& aCodecs, int32_t aWidth, int32_t aHeight,
double aFramerate, int32_t aBitrate, EOTF aEOTF, int32_t aChannels)
double aFramerate, int32_t aBitrate)
: mOriginalString(aOriginalString),
mMIMEType(aMIMEType),
mHaveCodecs(aHaveCodecs),
@ -124,8 +124,6 @@ MediaExtendedMIMEType::MediaExtendedMIMEType(
mWidth(aWidth),
mHeight(aHeight),
mFramerate(aFramerate),
mEOTF(aEOTF),
mChannels(aChannels),
mBitrate(aBitrate) {}
MediaExtendedMIMEType::MediaExtendedMIMEType(
@ -183,18 +181,6 @@ Maybe<double> MediaExtendedMIMEType::ComputeFractionalString(
return Some(result);
}
static EOTF GetParameterAsEOTF(const nsContentTypeParser& aParser) {
nsAutoString eotf;
nsresult rv = aParser.GetParameter("eotf", eotf);
if (NS_FAILED_impl(rv)) {
return EOTF::UNSPECIFIED;
}
if (eotf.LowerCaseEqualsASCII("bt709")) {
return EOTF::BT709;
}
return EOTF::NOT_SUPPORTED;
}
Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(const nsAString& aType) {
nsContentTypeParser parser(aType);
nsAutoString mime;
@ -216,12 +202,10 @@ Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(const nsAString& aType) {
int32_t height = GetParameterAsNumber(parser, "height", -1);
double framerate = GetParameterAsNumber(parser, "framerate", -1);
int32_t bitrate = GetParameterAsNumber(parser, "bitrate", -1);
EOTF eotf = GetParameterAsEOTF(parser);
int32_t channels = GetParameterAsNumber(parser, "channels", -1);
return Some(MediaExtendedMIMEType(NS_ConvertUTF16toUTF8(aType), mime8,
haveCodecs, codecs, width, height,
framerate, bitrate, eotf, channels));
framerate, bitrate));
}
Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(
@ -251,10 +235,9 @@ Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(
return Nothing();
}
return Some(MediaExtendedMIMEType(NS_ConvertUTF16toUTF8(aConfig.mContentType),
mime8, haveCodecs, codecs, aConfig.mWidth,
aConfig.mHeight, framerate.ref(),
aConfig.mBitrate, EOTF::UNSPECIFIED));
return Some(MediaExtendedMIMEType(
NS_ConvertUTF16toUTF8(aConfig.mContentType), mime8, haveCodecs, codecs,
aConfig.mWidth, aConfig.mHeight, framerate.ref(), aConfig.mBitrate));
}
Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(

Просмотреть файл

@ -143,13 +143,6 @@ class MediaCodecs {
nsString mCodecs;
};
// Electro-Optical Transfer Functions
enum class EOTF {
UNSPECIFIED = -1,
NOT_SUPPORTED = 0,
BT709 = 1,
};
// Class containing pre-parsed media MIME type parameters, e.g.:
// MIME type/subtype, optional codecs, etc.
class MediaExtendedMIMEType {
@ -172,9 +165,6 @@ class MediaExtendedMIMEType {
Maybe<int32_t> GetBitrate() const { return GetMaybeNumber(mBitrate); }
Maybe<int32_t> GetChannels() const { return GetMaybeNumber(mChannels); }
Maybe<int32_t> GetSamplerate() const { return GetMaybeNumber(mSamplerate); }
Maybe<EOTF> GetEOTF() const {
return (mEOTF == EOTF::UNSPECIFIED) ? Nothing() : Some(mEOTF);
}
// Original string. Note that "type/subtype" may not be lowercase,
// use Type().AsString() instead to get the normalized "type/subtype".
@ -197,8 +187,7 @@ class MediaExtendedMIMEType {
MediaExtendedMIMEType(const nsACString& aOriginalString,
const nsACString& aMIMEType, bool aHaveCodecs,
const nsAString& aCodecs, int32_t aWidth,
int32_t aHeight, double aFramerate, int32_t aBitrate,
EOTF aEOTF = EOTF::UNSPECIFIED, int32_t aChannels = -1);
int32_t aHeight, double aFramerate, int32_t aBitrate);
MediaExtendedMIMEType(const nsACString& aOriginalString,
const nsACString& aMIMEType, bool aHaveCodecs,
const nsAString& aCodecs, int32_t aChannels,
@ -217,7 +206,6 @@ class MediaExtendedMIMEType {
int32_t mWidth = -1; // -1 if not provided.
int32_t mHeight = -1; // -1 if not provided.
double mFramerate = -1; // -1 if not provided.
EOTF mEOTF = EOTF::UNSPECIFIED;
// For audio
int32_t mChannels = -1; // -1 if not provided.
int32_t mSamplerate = -1; // -1 if not provided.

Просмотреть файл

@ -361,62 +361,12 @@ void MediaSource::EndOfStream(const MediaResult& aError) {
mDecoder->DecodeError(aError);
}
static bool AreExtraParametersSane(const nsAString& aType) {
Maybe<MediaContainerType> containerType = MakeMediaContainerType(aType);
if (!containerType) {
return false;
}
auto extendedType = containerType->ExtendedType();
auto bitrate = extendedType.GetBitrate();
if (bitrate && *bitrate > 10000000) {
return false;
}
if (containerType->Type().HasVideoMajorType()) {
auto width = extendedType.GetWidth();
if (width && *width > MAX_VIDEO_WIDTH) {
return false;
}
auto height = extendedType.GetHeight();
if (height && *height > MAX_VIDEO_HEIGHT) {
return false;
}
auto framerate = extendedType.GetFramerate();
if (framerate && *framerate > 1000) {
return false;
}
auto eotf = extendedType.GetEOTF();
if (eotf && *eotf == EOTF::NOT_SUPPORTED) {
return false;
}
} else if (containerType->Type().HasAudioMajorType()) {
auto channels = extendedType.GetChannels();
if (channels && *channels > 6) {
return false;
}
auto samplerate = extendedType.GetSamplerate();
if (samplerate && *samplerate > 192000) {
return false;
}
}
return true;
}
static bool IsYouTube(const GlobalObject& aOwner) {
nsCString domain;
return aOwner.GetSubjectPrincipal() &&
NS_SUCCEEDED(aOwner.GetSubjectPrincipal()->GetBaseDomain(domain)) &&
domain.EqualsLiteral("youtube.com");
}
/* static */
bool MediaSource::IsTypeSupported(const GlobalObject& aOwner,
const nsAString& aType) {
MOZ_ASSERT(NS_IsMainThread());
DecoderDoctorDiagnostics diagnostics;
nsresult rv = IsTypeSupported(aType, &diagnostics);
if (NS_SUCCEEDED(rv) && IsYouTube(aOwner) && !AreExtraParametersSane(aType)) {
rv = NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
nsCOMPtr<nsPIDOMWindowInner> window =
do_QueryInterface(aOwner.GetAsSupports());
diagnostics.StoreFormatDiagnostics(window ? window->GetExtantDoc() : nullptr,

Просмотреть файл

@ -1,17 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>MSE: isTypeSupported extended mime extensions</title>
</head>
<body>
<script>
window.addEventListener("message", (e) => {
const result = MediaSource.isTypeSupported(e.data);
const w = window.opener || window.parent;
w.postMessage(result, "*");
});
const w = window.opener || window.parent;
w.postMessage("ready", "*");
</script>
</body>
</html>

Просмотреть файл

@ -49,7 +49,6 @@ support-files =
tags_before_cluster.webm
tags_before_cluster.webm^header^
1516754.webm 1516754.webm^headers^
file_isTypeSupported.html
[test_AbortAfterPartialMediaSegment.html]
[test_AppendPartialInitSegment.html]
@ -89,7 +88,6 @@ skip-if = android_version == '22' || toolkit == 'android' || (os == "win" && pro
skip-if = android_version == '22' || toolkit == 'android' # bug 1341519, bug 1401090
[test_FrameSelection_mp4.html]
skip-if = toolkit == 'android' || os == 'win' # Not supported on android, # bug 1487973
[test_isTypeSupportedExtensions.html]
[test_HaveMetadataUnbufferedSeek.html]
skip-if = android_version == '22' || toolkit == 'android' # bug 1342247, bug 1401090
[test_HaveMetadataUnbufferedSeek_mp4.html]

Просмотреть файл

@ -1,136 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>MSE: isTypeSupported extended mime extensions</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<iframe id="frame" src="https://mochitest.youtube.com:443/tests/dom/media/mediasource/test/file_isTypeSupported.html"></iframe>
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
// Returns a promise that resolves with the next message received on
// our window.
function nextMessage() {
return new Promise((resolve, reject) => {
const f = (event) => {
window.removeEventListener("message", f);
resolve(event);
};
window.addEventListener("message", f);
});
}
// Tests YouTube's MIME type extensions. Runs through the list of cases
// and checks that the MIME extensions are only supported on a YouTube
// origin, where supported means we check the invalid cases and reject
// them.
async function runTest() {
const supportedCases = [
'video/mp4; codecs="avc1.42001E"',
'audio/mp4; codecs="mp4a.40.2"',
'video/webm; codecs="vp09.02.51.10.01.09.16.09"',
'audio/webm; codecs="opus"',
'audio/webm; codecs="opus"; channels=2',
'video/webm; codecs="vp9"',
'video/webm; codecs="vp9"; width=640',
'video/webm; codecs="vp9"',
'video/webm; codecs="vp9"; height=360',
'video/webm; codecs="vp9"',
'video/webm; codecs="vp9"; framerate=30',
'video/webm; codecs="vp9"; width=3840; height=2160; bitrate=2000000',
'video/mp4; codecs="avc1.4d4015"; width=426; height=240; framerate=24',
'video/mp4; codecs="avc1.4d401e"; width=640; height=360; framerate=24',
'video/mp4; codecs="avc1.4d401e"; width=854; height=480; framerate=24',
'video/mp4; codecs="avc1.4d401f"; width=1280; height=720; framerate=24',
'video/mp4; codecs="avc1.640028"; width=1920; height=1080; framerate=24',
'audio/mp4; codecs="mp4a.40.2"; channels=2',
'video/mp4; codecs="avc1.4d400c"; width=256; height=144; framerate=24',
'audio/webm; codecs="vorbis"; channels=2',
'video/webm; codecs="vp9"',
'video/webm; codecs="vp9"; eotf=bt709',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=426; height=240; framerate=24',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=640; height=360; framerate=24',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=854; height=480; framerate=24',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=1280; height=720; framerate=24',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=1920; height=1080; framerate=24',
'audio/webm; codecs="opus"; channels=2',
'audio/webm; codecs="opus"; channels=2',
'audio/webm; codecs="opus"; channels=2',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=2560; height=1440; framerate=24',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=3840; height=2160; framerate=24',
'video/mp4; codecs="av01.0.05M.08"; width=256; height=144; framerate=24',
'video/mp4; codecs="av01.0.05M.08"; width=426; height=240; framerate=24',
'video/mp4; codecs="av01.0.05M.08"; width=640; height=360; framerate=24',
'video/mp4; codecs="av01.0.05M.08"; width=854; height=480; framerate=24',
'video/mp4; codecs="av01.0.05M.08"; width=1280; height=720; framerate=24',
'video/mp4; codecs="avc1.4d4015"; width=426; height=240; framerate=25',
'video/mp4; codecs="avc1.4d401e"; width=640; height=360; framerate=25',
'video/mp4; codecs="avc1.4d401e"; width=854; height=480; framerate=25',
'video/mp4; codecs="avc1.4d401f"; width=1280; height=720; framerate=25',
'video/mp4; codecs="avc1.640028"; width=1920; height=1080; framerate=25',
'audio/mp4; codecs="mp4a.40.2"; channels=2',
'video/mp4; codecs="avc1.4d400c"; width=256; height=144; framerate=25',
'audio/webm; codecs="vorbis"; channels=2',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=426; height=240; framerate=25',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=640; height=360; framerate=25',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=854; height=480; framerate=25',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=1280; height=720; framerate=25',
'video/webm; codecs="vp09.00.51.08.01.01.01.01"; width=1920; height=1080; framerate=25',
'audio/webm; codecs="opus"; channels=2',
'audio/webm; codecs="opus"; channels=2',
'audio/webm; codecs="opus"; channels=2',
];
const unsupportedOnYTCases = [
'audio/webm; codecs="opus"; channels=99',
'video/webm; codecs="vp9"; width=99999',
'video/webm; codecs="vp9"; height=99999',
'video/webm; codecs="vp9"; framerate=9999',
'video/webm; codecs="vp9"; width=3840; height=2160; bitrate=20000000',
'video/webm; codecs="vp9"; eotf=catavision',
];
const unsupportedCases = [
'video/webm; codecs="vp09.02.51.10.01.09.99.99"',
];
const frame = document.getElementById("frame");
const supportedOnYT = async (t) => {
// Sends a message to the YouTube iframe, which runs the check there.
const m = nextMessage();
frame.contentWindow.postMessage(t, "*");
const result = await m;
return result.data;
};
for (const t of supportedCases) {
ok(MediaSource.isTypeSupported(t), "Case '" + t + "' supported in non-YouTube origin");
is(await supportedOnYT(t), true, "Case '" + t + "' supported in YouTube origin");
}
for (const t of unsupportedOnYTCases) {
ok(MediaSource.isTypeSupported(t), "Case '" + t + "' supported in non-YouTube origin");
is(await supportedOnYT(t), false, "Case '" + t + "' *not* supported in YouTube origin");
}
for (const t of unsupportedCases) {
ok(!MediaSource.isTypeSupported(t), "Case '" + t + "' *not* supported in non-YouTube origin");
is(await supportedOnYT(t), false, "Case '" + t + "' *not* supported in YouTube origin");
}
SimpleTest.finish();
}
// Start the test once the child fake YouTube origin frame has signaled
// it's ready to receive requests.
nextMessage().then(runTest);
</script>
</pre>
</body>
</html>