chromium/third_party/blink/web_tests/fast/forms/textarea/textarea-resize-below-min-size.html

<!DOCTYPE html>
<body>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>

<div style="width:800px; height:800px">
<textarea id="textInputID">
Some text
</textarea>
</div>

<script>
function drag(startX, startY, destX, destY, callback) {
  chrome.gpuBenchmarking.pointerActionSequence([{source: 'mouse', actions:[
    {name: 'pointerDown', x: startX, y: startY},
    {name: 'pointerMove', x: destX, y: destY},
    {name: 'pointerUp'}]}],
    callback);
}

function testDragAndMove(textArea, callback) {
  var startX = textArea.offsetLeft + 400;
  var startY = textArea.offsetTop + 400;
  drag(startX, startY, startX - 350, startY - 350, callback);
}

var t = async_test('Test for resizing the TEXTAREA below the minimum size set.');
t.step(() => {
  assert_own_property(window, 'chrome');
  assert_own_property(chrome, 'gpuBenchmarking');

  var textArea = document.getElementById('textInputID');
  textArea.style.width = '400px';
  textArea.style.height = '400px';
  textArea.style.minWidth = '200px';
  textArea.style.minHeight = '200px';
  testDragAndMove(textArea, t.step_func(() => {
    // The min-width/min-height does not include padding and border but the
    // bounding client rect does. So when we set say min-width = 200px with
    // 2px padding and 1px border, the actual bounding client width will be:
    //   (2px + 1px) + 200px + (2px + 1px) = 206px
    assert_equals(textArea.getBoundingClientRect().width, 200 + 6);
    assert_equals(textArea.getBoundingClientRect().height, 200 + 6);

    textArea.style.width = '400px';
    textArea.style.height = '400px';
    textArea.style.minWidth = '15vw';
    textArea.style.minHeight = '15vh';
    testDragAndMove(textArea, t.step_func(() => {
      assert_equals(textArea.getBoundingClientRect().width, 120 + 6);
      assert_equals(textArea.getBoundingClientRect().height, 90 + 6);

      textArea.style.width = '400px';
      textArea.style.height = '400px';
      textArea.style.minWidth = '10%';
      textArea.style.minHeight = '10%';
      testDragAndMove(textArea, t.step_func_done(() => {
        assert_equals(textArea.getBoundingClientRect().width, 80 + 6);
        assert_equals(textArea.getBoundingClientRect().height, 80 + 6);
      }));
    }));
  }));
});
</script>
</body>