<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description">There was a bug that moving focus with TAB from a number input with an invalid string dispatched an extra focus event and an extra blur event.</p>
<div id="console"></div>

<input type=number id=number>
<input type=text>

<script>
function handleFocus() {
    numOfFocus++;
}

function handleBlur() {
    numOfBlur++;
}

var numOfFocus = 0;
var numOfBlur = 0;
var num = document.getElementById('number');
num.addEventListener('focus', handleFocus);
num.addEventListener('blur', handleBlur);
num.focus();
document.execCommand('InsertText', false, '123');
document.execCommand('InsertText', false, 'a');
var tabEvent = document.createEvent('KeyboardEvent');
tabEvent.initKeyboardEvent('keydown', true, true, document.defaultView, 'U+0009');
num.dispatchEvent(tabEvent);

shouldBe('numOfFocus', '1');
shouldBe('numOfBlur', '1');
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>
