Bug 630029 - Throw INDEX_SIZE_ERR instead of SYNTAX_ERR when calling CanvasGradient.addColorStop with non-finite values; r=?sicking

This commit is contained in:
Ms2ger 2011-04-02 20:50:14 +02:00
parent 7f0465be6b
commit a544f30f34
2 changed files with 5 additions and 9 deletions

View File

@ -220,14 +220,10 @@ public:
NS_IMETHOD AddColorStop (float offset,
const nsAString& colorstr)
{
nscolor color;
if (!FloatValidate(offset))
return NS_ERROR_DOM_SYNTAX_ERR;
if (offset < 0.0 || offset > 1.0)
if (!FloatValidate(offset) || offset < 0.0 || offset > 1.0)
return NS_ERROR_DOM_INDEX_SIZE_ERR;
nscolor color;
nsCSSParser parser;
nsresult rv = parser.ParseColorString(nsString(colorstr),
nsnull, 0, &color);

View File

@ -6108,13 +6108,13 @@ var _thrown = undefined; try {
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
var _thrown = undefined; try {
g.addColorStop(Infinity, '#000');
} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
var _thrown = undefined; try {
g.addColorStop(-Infinity, '#000');
} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
var _thrown = undefined; try {
g.addColorStop(NaN, '#000');
} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
}