blob: f4cbb71043caf09ba20b8188eb09ff6bdd5b7e02 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>Case insensitiveness of accesskey attribute</title>
<script src="../../resources/js-test.js"></script>
</head>
</head>
<body>
<script>
description('Access key should work case-insensitively. To test this manually, press &lt;alt&gt;+a, &lt;alt&gt;+&lt;shift&gt;+b and &lt;alt&gt;+&lt;shift&gt;+c keys in this order (on Mac OS X, press &lt;ctrl&gt;+&lt;opt&gt; instead of &lt;alt&gt;).');
window.jsTestIsAsync = true;
function isUpperCase(string)
{
return string === string.toUpperCase();
}
function pressKey(key)
{
var modifiers;
if (navigator.userAgent.search(/\bMac OS X\b/) !== -1)
modifiers = ["ctrlKey", "altKey"];
else
modifiers = ["altKey"];
if (isUpperCase(key)) {
modifiers.push("shiftKey");
key = key.toLowerCase();
}
if (window.eventSender)
eventSender.keyDown(key, modifiers);
}
document.addEventListener("DOMContentLoaded", function () {
var input = document.createElement('input');
input.accessKey = 'A';
input.onfocus = function () {
testPassed('Pressing the "a" access key triggered a focus event.');
input.blur();
input.accessKey = 'b';
input.onfocus = function () {
testPassed('Pressing the "B" access key triggered a focus event.');
input.blur();
input.setAttribute('accesskey', 'C');
input.onfocus = function () {
testPassed('Pressing the "C" access key triggered a focus event.');
document.body.removeChild(input);
finishJSTest();
};
pressKey('C');
};
pressKey('B');
};
document.body.appendChild(input);
pressKey('a');
});
</script>
</body>
</html>