Bug 1286796: [MSE] P1. Replace InvalidAccessError usage with TypeError. r?gerald
See https://github.com/w3c/media-source/issues/34
MozReview-Commit-ID: 6RDjhxnaOGM
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -84,17 +84,17 @@ IsWebMForced(DecoderDoctorDiagnostics* a
bool hwsupported = gfxPlatform::GetPlatform()->CanUseHardwareVideoDecoding();
return !mp4supported || !hwsupported || VP9Benchmark::IsVP9DecodeFast();
}
static nsresult
IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* aDiagnostics)
{
if (aType.IsEmpty()) {
- return NS_ERROR_DOM_INVALID_ACCESS_ERR;
+ return NS_ERROR_DOM_TYPE_ERR;
}
nsContentTypeParser parser(aType);
nsAutoString mimeType;
nsresult rv = parser.GetType(mimeType);
if (NS_FAILED(rv)) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
NS_ConvertUTF16toUTF8 mimeTypeUTF8(mimeType);
@@ -196,17 +196,17 @@ MediaSource::Duration()
}
void
MediaSource::SetDuration(double aDuration, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
MSE_API("SetDuration(aDuration=%f, ErrorResult)", aDuration);
if (aDuration < 0 || IsNaN(aDuration)) {
- aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+ aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
return;
}
if (mReadyState != MediaSourceReadyState::Open ||
mSourceBuffers->AnyUpdating()) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
SetDuration(aDuration, MSRangeRemovalAction::RUN);
@@ -335,17 +335,17 @@ MediaSource::EndOfStream(const Optional<
switch (aError.Value()) {
case MediaSourceEndOfStreamError::Network:
mDecoder->NetworkError();
break;
case MediaSourceEndOfStreamError::Decode:
mDecoder->DecodeError();
break;
default:
- aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+ aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
}
}
/* static */ bool
MediaSource::IsTypeSupported(const GlobalObject& aOwner, const nsAString& aType)
{
MOZ_ASSERT(NS_IsMainThread());
DecoderDoctorDiagnostics diagnostics;
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -46,17 +46,17 @@ SourceBuffer::SetMode(SourceBufferAppend
MOZ_ASSERT(NS_IsMainThread());
MSE_API("SetMode(aMode=%d)", aMode);
if (!IsAttached() || mUpdating) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (mCurrentAttributes.mGenerateTimestamps &&
aMode == SourceBufferAppendMode::Segments) {
- aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+ aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
return;
}
MOZ_ASSERT(mMediaSource->ReadyState() != MediaSourceReadyState::Closed);
if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) {
mMediaSource->SetReadyState(MediaSourceReadyState::Open);
}
if (mCurrentAttributes.GetAppendState() == AppendState::PARSING_MEDIA_SEGMENT){
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
@@ -133,34 +133,34 @@ SourceBuffer::SetAppendWindowStart(doubl
MOZ_ASSERT(NS_IsMainThread());
MSE_API("SetAppendWindowStart(aAppendWindowStart=%f)", aAppendWindowStart);
if (!IsAttached() || mUpdating) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (aAppendWindowStart < 0 ||
aAppendWindowStart >= mCurrentAttributes.GetAppendWindowEnd()) {
- aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+ aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
return;
}
mCurrentAttributes.SetAppendWindowStart(aAppendWindowStart);
}
void
SourceBuffer::SetAppendWindowEnd(double aAppendWindowEnd, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
MSE_API("SetAppendWindowEnd(aAppendWindowEnd=%f)", aAppendWindowEnd);
if (!IsAttached() || mUpdating) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (IsNaN(aAppendWindowEnd) ||
aAppendWindowEnd <= mCurrentAttributes.GetAppendWindowStart()) {
- aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+ aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
return;
}
mCurrentAttributes.SetAppendWindowEnd(aAppendWindowEnd);
}
void
SourceBuffer::AppendBuffer(const ArrayBuffer& aData, ErrorResult& aRv)
{
@@ -227,17 +227,17 @@ SourceBuffer::Remove(double aStart, doub
}
if (mUpdating) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (IsNaN(mMediaSource->Duration()) ||
aStart < 0 || aStart > mMediaSource->Duration() ||
aEnd <= aStart || IsNaN(aEnd)) {
- aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+ aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
return;
}
if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) {
mMediaSource->SetReadyState(MediaSourceReadyState::Open);
}
RangeRemoval(aStart, aEnd);
}