77 lines
2.1 KiB
HTML
77 lines
2.1 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
<script src="resources/scripted-random.js"></script>
|
|
</head>
|
|
<body>
|
|
<p id="description"></p>
|
|
<div id="console"></div>
|
|
<script>
|
|
description("This test fuzzes the length list parser with semi-random attribute values and dumps the results of any values that parse successfully.");
|
|
|
|
var characters = [
|
|
"0",
|
|
// Long numeric string to force crossing page boundaries.
|
|
"-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
|
|
"1",
|
|
"2",
|
|
"3",
|
|
"4",
|
|
"5",
|
|
"6",
|
|
"7",
|
|
"8",
|
|
"9",
|
|
".",
|
|
"e",
|
|
"+",
|
|
"-",
|
|
",",
|
|
" ",
|
|
"\t"
|
|
];
|
|
|
|
var textElement = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
function parseLengthList(string)
|
|
{
|
|
textElement.setAttributeNS(null, "x", string);
|
|
|
|
var lengthList = textElement.x.baseVal;
|
|
if (!lengthList.numberOfItems)
|
|
return;
|
|
|
|
var debugStr = "Parsed as " + lengthList.numberOfItems + " length(s)";
|
|
debugStr += " [ ";
|
|
for (var i = 0; i < lengthList.numberOfItems; i++) { //>
|
|
debugStr += lengthList.getItem(i).valueAsString;
|
|
if (i < lengthList.numberOfItems - 1) //>
|
|
debugStr += ", ";
|
|
}
|
|
debugStr += " ]";
|
|
debugStr += ": " + string;
|
|
debug(debugStr);
|
|
}
|
|
|
|
function fuzz()
|
|
{
|
|
// Random assortments of valid characters
|
|
for (var i = 0; i < 250; i++) { //>
|
|
var lengthList = "";
|
|
var count = Math.scriptedRandomInt(100);
|
|
for (var j = 0; j < count; j++) { //>
|
|
lengthList += characters[Math.scriptedRandomInt(characters.length)];
|
|
}
|
|
parseLengthList(lengthList);
|
|
}
|
|
|
|
// Empty-ish length lists
|
|
parseLengthList("");
|
|
parseLengthList(String.fromCharCode(0));
|
|
}
|
|
|
|
fuzz();
|
|
|
|
</script>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</html>
|