Bug 724993 - "ASSERTION: Item should only return null for out-of-bounds access" after explicitly adding null. r=dholbert.

This commit is contained in:
Jonathan Watt 2012-02-08 20:09:01 +00:00
Родитель deed914cc3
Коммит 3cf3246000
3 изменённых файлов: 126 добавлений и 0 удалений

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

@ -141,6 +141,9 @@ DOMSVGStringList::InsertItemBefore(const nsAString & newItem,
PRUint32 index,
nsAString & _retval)
{
if (newItem.IsEmpty()) { // takes care of DOMStringIsNull too
return NS_ERROR_DOM_SVG_INVALID_VALUE_ERR;
}
index = NS_MIN(index, InternalList().Length());
// Ensure we have enough memory so we can avoid complex error handling below:
@ -160,6 +163,9 @@ DOMSVGStringList::ReplaceItem(const nsAString & newItem,
PRUint32 index,
nsAString & _retval)
{
if (newItem.IsEmpty()) { // takes care of DOMStringIsNull too
return NS_ERROR_DOM_SVG_INVALID_VALUE_ERR;
}
if (index >= InternalList().Length()) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}

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

@ -90,6 +90,7 @@ _TEST_FILES = \
test_SVGMatrix.xhtml \
test_SVGPathSegList.xhtml \
test_SVGStyleElement.xhtml \
test_SVGStringList.xhtml \
test_SVGTransformList.xhtml \
test_SVGTransformListAddition.xhtml \
test_SVGxxxList.xhtml \

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

@ -0,0 +1,119 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=724993-->
<head>
<title>Tests specific to SVGStringList</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=724993">Mozilla Bug 724993</a>
<p id="display"></p>
<div id="content" style="display:none;">
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<g id="g" requiredFeatures="foo bar baz"/>
</svg>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
/*
This file runs a series of SVGStringList specific tests. Generic SVGXxxList
tests can be found in test_SVGxxxList.xhtml. Anything that can be generalized
to other list types belongs there.
*/
function initializeThrowsFor(stringList, value)
{
try {
stringList.initialize(value);
} catch (e) {
return true;
}
return false;
}
function insertItemBeforeThrowsFor(stringList, value)
{
try {
stringList.insertItemBefore(value, 0);
} catch (e) {
return true;
}
return false;
}
function replaceItemThrowsFor(stringList, value)
{
try {
stringList.replaceItem(value, 0);
} catch (e) {
return true;
}
return false;
}
function appendItemThrowsFor(stringList, value)
{
try {
stringList.appendItem(value);
} catch (e) {
return true;
}
return false;
}
function run_tests()
{
var g = document.getElementById("g");
var strings = g.requiredFeatures;
// sanity check:
is(strings.numberOfItems, 3, 'numberOfItems should be 3');
ok(initializeThrowsFor(strings, null),
"SVGStringList.initialize() should throw when passed null");
ok(initializeThrowsFor(strings, ""),
"SVGStringList.initialize() should throw when passed the empty string");
ok(insertItemBeforeThrowsFor(strings, null),
"SVGStringList.insertItemBefore() should throw when passed null");
ok(insertItemBeforeThrowsFor(strings, ""),
"SVGStringList.insertItemBefore() should throw when passed the empty string");
ok(replaceItemThrowsFor(strings, null),
"SVGStringList.replaceItem() should throw when passed null");
ok(replaceItemThrowsFor(strings, ""),
"SVGStringList.replaceItem() should throw when passed the empty string");
ok(appendItemThrowsFor(strings, null),
"SVGStringList.appendItem() should throw when passed null");
ok(appendItemThrowsFor(strings, ""),
"SVGStringList.appendItem() should throw when passed the empty string");
// more sanity checks:
ok(!initializeThrowsFor(strings, "valid-string"),
"SVGStringList.initialize() should not throw when passed a valid string");
ok(!insertItemBeforeThrowsFor(strings, "valid-string"),
"SVGStringList.insertItemBefore() should not throw when passed a valid string");
ok(!replaceItemThrowsFor(strings, "valid-string"),
"SVGStringList.replaceItem() should not throw when passed a valid string");
ok(!appendItemThrowsFor(strings, "valid-string"),
"SVGStringList.appendItem() should not throw when passed a valid string");
is(strings.length, 3, 'numberOfItems should be 3');
SimpleTest.finish();
}
window.addEventListener("load", run_tests, false);
]]>
</script>
</pre>
</body>
</html>