chromium/third_party/blink/web_tests/fast/dom/tabindex-clamp.html

<html>
<head>
    <style>
        input { display: none; }
    </style>
    <script>
        function log(msg) {
            document.getElementById('log').appendChild(document.createTextNode(msg + '\n'));
        }

        function logTabIndex(elem) {
            log('getAttribute("tabindex") = ' + elem.getAttribute('tabindex') + '; tabIndex = ' + elem.tabIndex);
        }

        function test() {
            if (window.testRunner) {
                testRunner.dumpAsText();
            }

            log('Testing input elements in the page');

            var inputs = document.getElementsByTagName('input');
            for (var i = 0; i < inputs.length; ++i) {
                logTabIndex(inputs[i]);
            }

            var indices = [3147483648, 2147483648, 2147483647, 2147483646, 0, -1, -2147483647, -2147483648, -3147483648, "", "foo"];

            log('Testing setAttribute on an anchor element made with document.createElement');

            var elem = document.createElement('a');
            for (var i = 0; i < indices.length; ++i) {
                elem.setAttribute('tabindex', indices[i]);
                logTabIndex(elem);
            }

            log('Testing tabIndex on an area element made with document.createElement');

            var elem = document.createElement('area');
            for (var i = 0; i < indices.length; ++i) {
                elem.tabIndex = indices[i];
                logTabIndex(elem);
            }
        }
    </script>
</head>
<body onload="test()">
    <p>This page tests that the <tt>tabindex</tt> attribute is accepted for
    values between -2147483648 and 2147483647. Values outside of this range will
    make the tabIndex reflected value zero.</p>

    <input tabindex="3147483648">
    <input tabindex="2147483648">
    <input tabindex="2147483647">
    <input tabindex="2147483646">
    <input tabindex="0">
    <input tabindex="-1">
    <input tabindex="-2147483647">
    <input tabindex="-2147483648">
    <input tabindex="-2147483649">
    <input tabindex="-3147483648">

    <pre id="log"></pre>
</body>
</html>