Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp

Issue 2315113002: MSE: Throw TypeError instead of InvalidAccessError per spec update (Closed)
Patch Set: addSourceBuffer(null) is really addSourceBuffer("null") in at least Blink Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 DEFINE_STATIC_LOCAL(const AtomicString, segments, ("segments")); 157 DEFINE_STATIC_LOCAL(const AtomicString, segments, ("segments"));
158 return segments; 158 return segments;
159 } 159 }
160 160
161 const AtomicString& SourceBuffer::sequenceKeyword() 161 const AtomicString& SourceBuffer::sequenceKeyword()
162 { 162 {
163 DEFINE_STATIC_LOCAL(const AtomicString, sequence, ("sequence")); 163 DEFINE_STATIC_LOCAL(const AtomicString, sequence, ("sequence"));
164 return sequence; 164 return sequence;
165 } 165 }
166 166
167 void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptio nState) 167 void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptio nState)
chcunningham 2016/09/07 18:36:06 Not covered: If generate timestamps flag equals tr
wolenetz 2016/09/07 21:09:26 This is expected. Fixing this in Chrome is tracked
168 { 168 {
169 BLINK_SBLOG << __func__ << " this=" << this << " newMode=" << newMode; 169 BLINK_SBLOG << __func__ << " this=" << this << " newMode=" << newMode;
170 // Section 3.1 On setting mode attribute steps. 170 // Section 3.1 On setting mode attribute steps.
171 // 1. Let new mode equal the new value being assigned to this attribute. 171 // 1. Let new mode equal the new value being assigned to this attribute.
172 // 2. If this object has been removed from the sourceBuffers attribute of th e parent media source, then throw 172 // 2. If this object has been removed from the sourceBuffers attribute of th e parent media source, then throw
173 // an INVALID_STATE_ERR exception and abort these steps. 173 // an INVALID_STATE_ERR exception and abort these steps.
174 // 3. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps. 174 // 3. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps.
175 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e)) 175 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e))
176 return; 176 return;
177 177
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 double SourceBuffer::appendWindowStart() const 256 double SourceBuffer::appendWindowStart() const
257 { 257 {
258 return m_appendWindowStart; 258 return m_appendWindowStart;
259 } 259 }
260 260
261 void SourceBuffer::setAppendWindowStart(double start, ExceptionState& exceptionS tate) 261 void SourceBuffer::setAppendWindowStart(double start, ExceptionState& exceptionS tate)
262 { 262 {
263 BLINK_SBLOG << __func__ << " this=" << this << " start=" << start; 263 BLINK_SBLOG << __func__ << " this=" << this << " start=" << start;
264 // Section 3.1 appendWindowStart attribute setter steps. 264 // Section 3.1 appendWindowStart attribute setter steps.
265 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-SourceBuffer-appendWindowStart 265 // https://www.w3.org/TR/media-source/#widl-SourceBuffer-appendWindowStart
266 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an 266 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
267 // InvalidStateError exception and abort these steps. 267 // InvalidStateError exception and abort these steps.
268 // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps. 268 // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
269 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e)) 269 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e))
270 return; 270 return;
271 271
272 // 3. If the new value is less than 0 or greater than or equal to appendWind owEnd then throw an InvalidAccessError 272 // 3. If the new value is less than 0 or greater than or equal to appendWind owEnd then throw a TypeError
273 // exception and abort these steps. 273 // exception and abort these steps.
274 if (start < 0 || start >= m_appendWindowEnd) { 274 if (start < 0 || start >= m_appendWindowEnd) {
chcunningham 2016/09/07 18:36:05 Weird that we don't check NaN for start like we do
wolenetz 2016/09/07 21:09:27 We do and spec does. That's enforced by IDL bindin
275 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::indexOutsideRange("value", start, 0.0, ExceptionMessages::Ex clusiveBound, m_appendWindowEnd, ExceptionMessages::InclusiveBound)); 275 MediaSource::logAndThrowTypeError(exceptionState, ExceptionMessages::ind exOutsideRange("value", start, 0.0, ExceptionMessages::ExclusiveBound, m_appendW indowEnd, ExceptionMessages::InclusiveBound));
276 return; 276 return;
277 } 277 }
278 278
279 m_webSourceBuffer->setAppendWindowStart(start); 279 m_webSourceBuffer->setAppendWindowStart(start);
280 280
281 // 4. Update the attribute to the new value. 281 // 4. Update the attribute to the new value.
282 m_appendWindowStart = start; 282 m_appendWindowStart = start;
283 } 283 }
284 284
285 double SourceBuffer::appendWindowEnd() const 285 double SourceBuffer::appendWindowEnd() const
286 { 286 {
287 return m_appendWindowEnd; 287 return m_appendWindowEnd;
288 } 288 }
289 289
290 void SourceBuffer::setAppendWindowEnd(double end, ExceptionState& exceptionState ) 290 void SourceBuffer::setAppendWindowEnd(double end, ExceptionState& exceptionState )
291 { 291 {
292 BLINK_SBLOG << __func__ << " this=" << this << " end=" << end; 292 BLINK_SBLOG << __func__ << " this=" << this << " end=" << end;
293 // Section 3.1 appendWindowEnd attribute setter steps. 293 // Section 3.1 appendWindowEnd attribute setter steps.
294 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-SourceBuffer-appendWindowEnd 294 // https://www.w3.org/TR/media-source/#widl-SourceBuffer-appendWindowEnd
295 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an 295 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
296 // InvalidStateError exception and abort these steps. 296 // InvalidStateError exception and abort these steps.
297 // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps. 297 // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
298 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e)) 298 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e))
299 return; 299 return;
300 300
301 // 3. If the new value equals NaN, then throw an InvalidAccessError and abor t these steps. 301 // 3. If the new value equals NaN, then throw a TypeError and abort these st eps.
302 if (std::isnan(end)) { 302 if (std::isnan(end)) {
303 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::notAFiniteNumber(end)); 303 MediaSource::logAndThrowTypeError(exceptionState, ExceptionMessages::not AFiniteNumber(end));
304 return; 304 return;
305 } 305 }
306 // 4. If the new value is less than or equal to appendWindowStart then throw an InvalidAccessError 306 // 4. If the new value is less than or equal to appendWindowStart then throw a TypeError
307 // exception and abort these steps. 307 // exception and abort these steps.
308 if (end <= m_appendWindowStart) { 308 if (end <= m_appendWindowStart) {
309 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::indexExceedsMinimumBound("value", end, m_appendWindowStart)) ; 309 MediaSource::logAndThrowTypeError(exceptionState, ExceptionMessages::ind exExceedsMinimumBound("value", end, m_appendWindowStart));
310 return; 310 return;
311 } 311 }
312 312
313 m_webSourceBuffer->setAppendWindowEnd(end); 313 m_webSourceBuffer->setAppendWindowEnd(end);
314 314
315 // 5. Update the attribute to the new value. 315 // 5. Update the attribute to the new value.
316 m_appendWindowEnd = end; 316 m_appendWindowEnd = end;
317 } 317 }
318 318
319 void SourceBuffer::appendBuffer(DOMArrayBuffer* data, ExceptionState& exceptionS tate) 319 void SourceBuffer::appendBuffer(DOMArrayBuffer* data, ExceptionState& exceptionS tate)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 // 7. Set appendWindowEnd to positive Infinity. 392 // 7. Set appendWindowEnd to positive Infinity.
393 setAppendWindowEnd(std::numeric_limits<double>::infinity(), exceptionState); 393 setAppendWindowEnd(std::numeric_limits<double>::infinity(), exceptionState);
394 } 394 }
395 395
396 void SourceBuffer::remove(double start, double end, ExceptionState& exceptionSta te) 396 void SourceBuffer::remove(double start, double end, ExceptionState& exceptionSta te)
397 { 397 {
398 BLINK_SBLOG << __func__ << " this=" << this << " start=" << start << " end=" << end; 398 BLINK_SBLOG << __func__ << " this=" << this << " start=" << start << " end=" << end;
399 399
400 // Section 3.2 remove() method steps. 400 // Section 3.2 remove() method steps.
401 // 1. If duration equals NaN, then throw an InvalidAccessError exception and abort these steps. 401 // https://www.w3.org/TR/media-source/#widl-SourceBuffer-remove-void-double- start-unrestricted-double-end
402 // 2. If start is negative or greater than duration, then throw an InvalidAc cessError exception and abort these steps. 402 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
403 // InvalidStateError exception and abort these steps.
404 // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
405 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e))
406 return;
403 407
404 if (start < 0 || (m_source && (std::isnan(m_source->duration()) || start > m _source->duration()))) { 408 // 3. If duration equals NaN, then throw a TypeError exception and abort the se steps.
405 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::indexOutsideRange("start", start, 0.0, ExceptionMessages::Ex clusiveBound, !m_source || std::isnan(m_source->duration()) ? 0 : m_source->dura tion(), ExceptionMessages::ExclusiveBound)); 409 // 4. If start is negative or greater than duration, then throw a TypeError exception and abort these steps.
410 if (start < 0 || std::isnan(m_source->duration()) || start > m_source->durat ion()) {
411 MediaSource::logAndThrowTypeError(exceptionState, ExceptionMessages::ind exOutsideRange("start", start, 0.0, ExceptionMessages::ExclusiveBound, std::isna n(m_source->duration()) ? 0 : m_source->duration(), ExceptionMessages::Exclusive Bound));
406 return; 412 return;
407 } 413 }
408 414
409 // 3. If end is less than or equal to start or end equals NaN, then throw an InvalidAccessError exception and abort these steps. 415 // 5. If end is less than or equal to start or end equals NaN, then throw a TypeError exception and abort these steps.
410 if (end <= start || std::isnan(end)) { 416 if (end <= start || std::isnan(end)) {
411 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, "The end value provided (" + String::number(end) + ") must be greater than the start value provided (" + String::number(start) + ")."); 417 MediaSource::logAndThrowTypeError(exceptionState, "The end value provide d (" + String::number(end) + ") must be greater than the start value provided (" + String::number(start) + ").");
412 return; 418 return;
413 } 419 }
414 420
415 // 4. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
416 // InvalidStateError exception and abort these steps.
417 // 5. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
418 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e))
419 return;
420
421 TRACE_EVENT_ASYNC_BEGIN0("media", "SourceBuffer::remove", this); 421 TRACE_EVENT_ASYNC_BEGIN0("media", "SourceBuffer::remove", this);
422 422
423 // 6. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: 423 // 6. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps:
424 // 6.1. Set the readyState attribute of the parent media source to "open" 424 // 6.1. Set the readyState attribute of the parent media source to "open"
425 // 6.2. Queue a task to fire a simple event named sourceopen at the parent m edia source . 425 // 6.2. Queue a task to fire a simple event named sourceopen at the parent m edia source .
426 m_source->openIfInEndedState(); 426 m_source->openIfInEndedState();
427 427
428 // 7. Run the range removal algorithm with start and end as the start and en d of the removal range. 428 // 7. Run the range removal algorithm with start and end as the start and en d of the removal range.
429 // 7.3. Set the updating attribute to true. 429 // 7.3. Set the updating attribute to true.
430 m_updating = true; 430 m_updating = true;
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 visitor->trace(m_removeAsyncPartRunner); 1258 visitor->trace(m_removeAsyncPartRunner);
1259 visitor->trace(m_appendStreamAsyncPartRunner); 1259 visitor->trace(m_appendStreamAsyncPartRunner);
1260 visitor->trace(m_stream); 1260 visitor->trace(m_stream);
1261 visitor->trace(m_audioTracks); 1261 visitor->trace(m_audioTracks);
1262 visitor->trace(m_videoTracks); 1262 visitor->trace(m_videoTracks);
1263 EventTargetWithInlineData::trace(visitor); 1263 EventTargetWithInlineData::trace(visitor);
1264 ActiveDOMObject::trace(visitor); 1264 ActiveDOMObject::trace(visitor);
1265 } 1265 }
1266 1266
1267 } // namespace blink 1267 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698