<script src="../../../resources/js-test-pre.js"></script>
<div id='container'></div>
<script>
description("This test checks that we correctly update the touch event handler count when an Input element with default touch handlers changes documents.");


 shouldBe('window.internals.touchEventHandlerCount()', '0');

 // There are two touchable Input elements in Audio's shadow DOM when controls are enabled.
 var input = document.createElement('audio');
 input.setAttribute("controls", true);
 var container = document.getElementById('container');

 shouldBe('window.internals.touchEventHandlerCount()', '0');

 container.appendChild(input);
 shouldBe('window.internals.touchEventHandlerCount()', '2');

 input.ontouchend = function() { };
 shouldBe('window.internals.touchEventHandlerCount()', '3');

 input.ontouchend = null;
 shouldBe('window.internals.touchEventHandlerCount()', '2');

 document.implementation.createDocument("", "", null).adoptNode(input);
 shouldBe('window.internals.touchEventHandlerCount()', '0');


</script>
</body>
