| <!DOCTYPE html> |
| <html> |
| <head> |
| <style> |
| body { margin: 0; padding: 0;} |
| #resizable { |
| background: yellow; |
| box-sizing: border-box; |
| resize: both; |
| overflow: auto; |
| } |
| </style> |
| </head> |
| <body> |
| <div style="width:800px; height:800px"> |
| <div id="resizable"></div> |
| </div> |
| |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../../imported/w3c/web-platform-tests/resources/testdriver.js"></script> |
| <script src="../../imported/w3c/web-platform-tests/resources/testdriver-actions.js"></script> |
| <script src="../../imported/w3c/web-platform-tests/resources/testdriver-vendor.js"></script> |
| <script> |
| function drag(startX, startY, destX, destY) { |
| const actions = new test_driver.Actions() |
| .pointerMove(startX - 1, startY - 1) |
| .pointerDown() |
| .pointerMove(destX - 1, destY - 1) |
| .pointerUp(); |
| return actions.send(); |
| } |
| |
| async function testDragAndMove(box) { |
| const startX = box.getBoundingClientRect().right; |
| const startY = box.getBoundingClientRect().bottom; |
| await drag(startX, startY, startX - 350, startY - 350); |
| } |
| |
| promise_test(async () => { |
| const box = document.getElementById("resizable"); |
| box.style.width = "400px"; |
| box.style.height = "400px"; |
| box.style.minWidth = "200px"; |
| box.style.minHeight = "200px"; |
| await testDragAndMove(box); |
| assert_equals(box.style.width, "200px"); |
| assert_equals(box.style.height, "200px"); |
| box.style.width = "400px"; |
| box.style.height = "400px"; |
| box.style.minWidth = "15vw"; |
| box.style.minHeight = "15vh"; |
| await testDragAndMove(box); |
| assert_equals(box.style.width, (0.15 * window.innerWidth) + "px"); |
| assert_equals(box.style.height, (0.15 * window.innerHeight) + "px"); |
| box.style.width = "400px"; |
| box.style.height = "400px"; |
| box.style.minWidth = "10%"; |
| box.style.minHeight = "10%"; |
| await testDragAndMove(box); |
| assert_equals(box.style.width, "80px"); // 10% of container |
| assert_equals(box.style.height, "80px"); // 10% of container |
| }, "Test for resizing the box below the minimum size set."); |
| </script> |
| </body> |
| </html> |