4 https://bugzilla.mozilla.org/show_bug.cgi?id=1490890
8 <title>Test for Bug
1490890</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
14 flex-direction: column;
18 border:
1px solid black;
22 white-space: pre-wrap;
27 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1490890">Mozilla Bug
1490890</a>
31 <div id=
"overflowAuto">
32 <!-- Populated by test JS below: -->
35 <div id=
"testNode">abc
</div>
40 <script type=
"application/javascript">
43 /** Test for Bug
1490890 **/
46 * This test checks how many reflows are required, when we make a change inside
47 * a flex item, with a tall scrollable sibling flex item.
50 const gUtils = SpecialPowers.getDOMWindowUtils(window);
52 // The elements that we will modify here:
53 const gTall = document.getElementById(
"tall");
54 const gTestNode = document.getElementById(
"testNode");
56 // Helper function to undo our modifications:
59 gTall.firstChild.remove();
63 // Flush layout & return the global frame-reflow-count
64 function getReflowCount()
66 let unusedVal = document.getElementById(
"flex").offsetHeight; // flush layout
67 return gUtils.framesReflowed;
70 // This function changes gTestNode to
"display:none", and returns the number
71 // of frames that need to be reflowed as a result of that tweak.
72 function makeTweakAndCountReflows()
74 let beforeCount = getReflowCount();
75 gTestNode.style.display =
"none";
76 let afterCount = getReflowCount();
78 let numReflows = afterCount - beforeCount;
79 if (numReflows <=
0) {
80 ok(false,
"something's wrong -- we should've reflowed *something*");
85 // ACTUAL TEST LOGIC STARTS HERE
86 // -----------------------------
87 const testLineCount =
100;
88 const refLineCount =
5000;
90 //
"Reference" measurement: put enough lines of text into gTall to trigger
91 // a vertical scrollbar, and then see how many frames need to be reflowed
92 // in response to a tweak in gTestNode:
93 let text = document.createTextNode(
"a\n".repeat(testLineCount));
94 gTall.appendChild(text);
95 let numReferenceReflows = makeTweakAndCountReflows();
98 //
"Test" measurement: put many more lines of text into gTall (many more than
99 // for reference case), and then see how many frames need to be reflowed
100 // in response to a tweak in gTestNode:
101 text = document.createTextNode(
"a\n".repeat(refLineCount));
102 gTall.appendChild(text);
103 let numTestReflows = makeTweakAndCountReflows();
106 is(numTestReflows, numReferenceReflows,
107 "Tweak should trigger the same number of reflows regardless of " +
108 "how much content is present in descendant of sibling");