summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-ui/resize-interactive.html
blob: 2a2332d3ef58184aa55114758fa219a51f8fbd78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS resize: interactive behavior</title>
<link rel="help" href="https://drafts.csswg.org/css-ui/#resize">
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<meta name="assert" content="This test checks that elements are correctly resized
  when a user interacts with their resizing mechanism (simulated via WebDriver).">

<style>
body {
  margin-bottom: 1000px;
}
.test {
  width: 100px;
  height: 100px;
  overflow: scroll;
}
.resize-both {
  resize: both;
}
.resize-horizontal {
  resize: horizontal;
}
.resize-vertical {
  resize: vertical;
}
.resize-block {
  resize: block;
}
.resize-inline {
  resize: inline;
}
.wm-horizontal {
  writing-mode: horizontal-tb;
}
.wm-vertical {
  writing-mode: vertical-lr;
}
.test::before {
  content: "";
  display: block;
  width: 1000px;
  height: 1000px;
}
</style>

<div class="test resize-both wm-horizontal"></div>
<div class="test resize-both wm-vertical"></div>
<div class="test resize-horizontal wm-horizontal"></div>
<div class="test resize-horizontal wm-vertical"></div>
<div class="test resize-vertical wm-horizontal"></div>
<div class="test resize-vertical wm-vertical"></div>
<div class="test resize-block wm-horizontal"></div>
<div class="test resize-block wm-vertical"></div>
<div class="test resize-inline wm-horizontal"></div>
<div class="test resize-inline wm-vertical"></div>

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<script>
function hasHorizontalWritingMode(cs) {
  return cs.writingMode === "horizontal-tb";
}

function getResolvedResize(cs) {
  let { resize } = cs;
  switch (resize) {
    case "block":
      return hasHorizontalWritingMode(cs) ? "vertical" : "horizontal";
    case "inline":
      return hasHorizontalWritingMode(cs) ? "horizontal" : "vertical";
    default:
      return resize;
  }
}

for (let target of document.querySelectorAll(".test")) {
  promise_test(async () => {
    // Scroll element to the top, to ensure that the pointer stays within the vieport
    // when resizing the element.
    target.scrollIntoView();

    await new test_driver.Actions()
      // Place pointer on the resizing mechanism.
      .pointerMove(49, 49, {origin: target})
      .pointerDown()
      // Resize the element.
      .pointerMove(149, 149, {origin: target})
      .pointerUp()
      .send();

    let resize = getResolvedResize(getComputedStyle(target));
    if (resize === "horizontal" || resize === "both") {
      assert_equals(target.offsetWidth, 200, "Width should have grown to 200px");
    } else {
      assert_equals(target.offsetWidth, 100, "Width should have stayed as 100px");
    }
    if (resize === "vertical" || resize === "both") {
      assert_equals(target.offsetHeight, 200, "Height should have grown to 200px");
    } else {
      assert_equals(target.offsetHeight, 100, "Height should have stayed as 100px");
    }
  }, target.className);
}
</script>