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
110
111
112
113
114
115
|
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>CSS Overflow: Test scrollbar-gutter reflow counts</title>
<link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1746098">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#target {
inline-size: 200px;
block-size: 100px;
background: lightgray;
overflow: auto;
}
#targetChild {
inline-size: 100%;
block-size: 100%;
background: orange;
}
</style>
<p>Here is a scroll contaier for testing:</p>
<div id="target">
<div id="targetChild"></div>
</div>
<script>
let gUtils = SpecialPowers.getDOMWindowUtils(window);
let gTarget = document.getElementById("target");
let gTargetChild = document.getElementById("targetChild");
function getReflowCount()
{
document.documentElement.offsetHeight; // flush layout
return gUtils.framesReflowed;
}
function cleanUp() {
gTarget.style.writingMode = "";
gTarget.style.scrollbarGutter = "";
gTargetChild.style.blockSize = "";
}
function tweakStyleAndCountReflows(aAddStyle, aAddScrollbarGutter)
{
let beforeCount = getReflowCount();
if (aAddScrollbarGutter) {
gTarget.style.scrollbarGutter = "stable";
}
aAddStyle();
let afterCount = getReflowCount();
cleanUp();
let numReflows = afterCount - beforeCount;
assert_greater_than(numReflows, 0, "We should've reflowed *something* after changing styles:");
return numReflows;
}
let gTestCases = [
{
name : "Enlarge the child's block-size to 200%",
addStyle : function () {
gTargetChild.style.blockSize = "200%";
},
},
{
name : "Enlarge the child's block-size to 300px",
addStyle : function () {
gTargetChild.style.blockSize = "300px";
},
},
{
name : "Enlarge the child's block-size to 200% in a vertical-lr scroll container",
addStyle : function () {
gTarget.style.writingMode = "vertical-lr";
gTargetChild.style.blockSize = "200%";
},
},
{
name : "Enlarge the child's block-size to 300px in a vertical-lr scroll container",
addStyle : function () {
gTarget.style.writingMode = "vertical-lr";
gTargetChild.style.blockSize = "300px";
},
},
{
name : "Enlarge the child's block-size to 200% in a vertical-rl scroll container",
addStyle : function () {
gTarget.style.writingMode = "vertical-rl";
gTargetChild.style.blockSize = "200%";
},
},
{
name : "Enlarge the child's block-size to 300px in a vertical-rl scroll container",
addStyle : function () {
gTarget.style.writingMode = "vertical-rl";
gTargetChild.style.blockSize = "300px";
},
},
];
for (let testcase of gTestCases) {
test(function () {
let numTestReflows = tweakStyleAndCountReflows(testcase.addStyle, true);
let numReferenceReflows = tweakStyleAndCountReflows(testcase.addStyle, false);
assert_less_than(numTestReflows, numReferenceReflows,
"A scroll container with 'scrollbar-gutter:stable' should have less reflow counts:");
}, testcase.name)
}
</script>
</html>
|