<!DOCTYPE HTML>
<script src="../../resources/js-test.js"></script>
<style>
textarea {
  width: 100px;
  height: 100px;
  margin: 10px;
}
</style>
<textarea id="target"></textarea>
<div id="console"></div>
<script>
description("Verifies that correct mouse events are fired and when resizing an element");
var testEventList = ['focus', 'mousedown', 'mouseup', 'click'];
var preventDefaultList = ['mousedown', ''];
var eventToPreventDefault = '';
function init() {
  var target = document.getElementById("target");
  testEventList.forEach(function(eventName) {
    target.addEventListener(eventName, function(event) {
      if (event.type == eventToPreventDefault) {
        event.preventDefault();
      }
      debug("Received " + event.type);
    });
  });
}
function runTests() {
  var rect = document.getElementById("target").getBoundingClientRect();
  var x = rect.right - 5;
  var y = rect.bottom - 5;
  preventDefaultList.forEach(function(eventName) {
    eventToPreventDefault = eventName;
    debug("--- test with preventDefault on '" + eventName + "' ---");
    debug("--- move mouse into target ---");
    eventSender.mouseMoveTo(x, y);
    debug("--- start resizing ---");
    eventSender.mouseDown();
    eventSender.mouseMoveTo(x + 30, y + 30);
    debug("--- mouse released ---");
    eventSender.mouseUp();
    debug("");
  });
}
init();
if (window.eventSender)
  runTests();
else
  debug("This test requires eventSender");
</script>