blob: d68da42d777b6826665dac093f77551407f4749e [file] [log] [blame]
<html>
<head>
<script>
function log(s)
{
document.getElementById('console').appendChild(document.createTextNode(s + "\n"));
}
var inputBlurFired = false;
var buttonBlurFired = false;
function test() {
if (window.testRunner)
testRunner.dumpAsText();
// hit enter
var bt = document.getElementById('i_bt');
bt.focus();
var enterEvent = document.createEvent("KeyboardEvents");
enterEvent.initKeyboardEvent("keypress", true, false, window, "Enter", 0, false, false, false, false, false);
bt.dispatchEvent(enterEvent);
if (inputBlurFired)
log('Test 1 Failed. Blur fired when hitting ENTER for input type=button element');
else
log('Test 1 Passed.');
bt = document.getElementById('b_bt');
bt.focus();
var enterEvent2 = document.createEvent("KeyboardEvents");
enterEvent2.initKeyboardEvent("keypress", true, false, window, "Enter", 0, false, false, false, false, false);
bt.dispatchEvent(enterEvent2);
if (buttonBlurFired)
log('Test 2 Failed. Blur fired when hitting ENTER for button element');
else
log('Test 2 Passed.');
}
</script>
</head>
<body onload="test()">
<p>This test verifies that the ENTER key does not fire the blur event for input type="button" and button elements.</p>
<hr>
<input id="i_bt" type="button" name="InputButtonElement" onblur="inputBlurFired = true;"></input>
<button id="b_bt" type="button" name="ButtonElement" onblur="buttonBlurFired = true;"></button>
<pre id="console"></pre>
</body>
</html>