chromium/third_party/blink/web_tests/svg/dom/string-list-parser.html

<html>
<head>
<script src="../../resources/js-test.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 string list parser with semi-random attribute values and dumps the results of any values that parse successfully.");
    
    var characters = [
        "0",
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8",
        "9",
        ".",
        ";",
        " ",
        "\t"
    ];
    
    var setElement = document.createElementNS("http://www.w3.org/2000/svg", "set");
    function parseStringList(string)
    {
        setElement.setAttributeNS(null, "begin", string);
        debug("Can't test the result of parsing a string list: they have no effect yet.");
    }

    function fuzz()
    {
        // Random assortments of valid characters
        for (var i = 0; i < 250; i++) { //>
            var lengthList = "";
            var count = Math.scriptedRandomInt(40);
            for (var j = 0; j < count; j++) { //>
                lengthList += characters[Math.scriptedRandomInt(characters.length)];
            }
            parseStringList(lengthList);
        }
        
        // Empty-ish string lists
        parseStringList("");
        parseStringList(String.fromCharCode(0));
    }
    
    fuzz();

</script>
</html>