For JS Unit test, I need to check that a double-click behaves as expected. The issue is that the event was registered via element.addEventListener. And for some reason, in this case, element.ondblclick() does not work.
HTML:
<input type="image" src="pic.jpg" id="aa"/>
Javasript:
document.getElementById('aa').addEventListener("dblclick", function(){alert('aa')});
document.getElementById('aa').ondblclick();
Fiddle: http://jsfiddle.net/prZKy/
If you double click on the image, it works, but the ondblclick() in the javascript does not work.
Anyone has an idea on how to do it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…