Commit 76818387 authored by sigbjornf@opera.com's avatar sigbjornf@opera.com

Have SourceBuffer throw TypeError for non-finite doubles.

Switch to throwing TypeError instead of TypeMismatchError when encountering
non-finite doubles, following what WebIDL requires

 http://heycam.github.io/webidl/#es-double

R=acolwell@chromium.org
BUG=353245

Review URL: https://codereview.chromium.org/212953004

git-svn-id: svn://svn.chromium.org/blink/trunk@170098 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d9903968
......@@ -32,15 +32,15 @@
assert_true(sourceBuffer != null, "New SourceBuffer returned");
sourceBuffer.appendWindowEnd = 500.0;
assert_throws("TypeMismatchError",
assert_throws({name: "TypeError"},
function() { sourceBuffer.appendWindowStart = Number.NEGATIVE_INFINITY; },
"set appendWindowStart throws an exception for Number.NEGATIVE_INFINITY.");
assert_throws("TypeMismatchError",
assert_throws({name: "TypeError"},
function() { sourceBuffer.appendWindowStart = Number.POSITIVE_INFINITY; },
"set appendWindowStart throws an exception for Number.POSITIVE_INFINITY.");
assert_throws("TypeMismatchError",
assert_throws({name: "TypeError"},
function() { sourceBuffer.appendWindowStart = Number.NaN; },
"set appendWindowStart throws an exception for Number.NaN.");
......@@ -101,7 +101,7 @@
sourceBuffer.abort();
assert_equals(sourceBuffer.appendWindowStart, 0, "appendWindowStart is 0 after an abort'");
assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINITY,
assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINITY,
"appendWindowStart is POSITIVE_INFINITY after an abort");
test.waitForExpectedEvents(function()
{
......
......@@ -16,8 +16,8 @@
var segmentInfo = MediaSourceUtil.SEGMENT_INFO;
var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type);
if (expected == 'TypeMismatchError') {
assert_throws('TypeMismatchError',
if (expected == 'TypeError') {
assert_throws({name: 'TypeError'},
function() { sourceBuffer.timestampOffset = value; },
'setting timestampOffset to ' + description + ' throws an exception.');
} else {
......@@ -32,10 +32,10 @@
simpleTimestampOffsetTest(10.5, 10.5, 'a positive number');
simpleTimestampOffsetTest(-10.4, -10.4, 'a negative number');
simpleTimestampOffsetTest(0, 0, 'zero');
simpleTimestampOffsetTest(Number.POSITIVE_INFINITY, 'TypeMismatchError', 'positive infinity');
simpleTimestampOffsetTest(Number.NEGATIVE_INFINITY, 'TypeMismatchError', 'negative infinity');
simpleTimestampOffsetTest(Number.NaN, 'TypeMismatchError', 'NaN');
simpleTimestampOffsetTest(undefined, 'TypeMismatchError', 'undefined');
simpleTimestampOffsetTest(Number.POSITIVE_INFINITY, 'TypeError', 'positive infinity');
simpleTimestampOffsetTest(Number.NEGATIVE_INFINITY, 'TypeError', 'negative infinity');
simpleTimestampOffsetTest(Number.NaN, 'TypeError', 'NaN');
simpleTimestampOffsetTest(undefined, 'TypeError', 'undefined');
simpleTimestampOffsetTest(null, 0, 'null');
simpleTimestampOffsetTest(false, 0, 'false');
simpleTimestampOffsetTest(true, 1, 'true');
......
......@@ -177,7 +177,7 @@ void SourceBuffer::setTimestampOffset(double offset, ExceptionState& exceptionSt
{
// Enforce throwing an exception on restricted double values.
if (!std::isfinite(offset)) {
exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::notAFiniteNumber(offset));
exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(offset));
return;
}
......@@ -213,10 +213,8 @@ double SourceBuffer::appendWindowStart() const
void SourceBuffer::setAppendWindowStart(double start, ExceptionState& exceptionState)
{
// Enforce throwing an exception on restricted double values.
if (std::isnan(start)
|| start == std::numeric_limits<double>::infinity()
|| start == -std::numeric_limits<double>::infinity()) {
exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::notAFiniteNumber(start));
if (!std::isfinite(start)) {
exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(start));
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment