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
|
<?xml version="1.0" encoding="UTF-8"?>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!--
This test verifies that we reconstruct frames as necessary, after content
(including whitespace & spans) is dynamically inserted as a child of a
flexbox. (Note that in cases where we know the whitespace is going to be
dropped, we don't bother reconstructing frames. This test is to be sure we
aren't overzealous with that optimization.)
-->
<html xmlns="http://www.w3.org/1999/xhtml"
class="reftest-wait">
<head>
<style>
body { font-size: 10px; }
<!-- to make inserted span elements stand out -->
span.inserted { background: teal; }
div.flexbox {
border: 1px dashed blue;
width: 300px;
display: flex;
justify-content: space-around;
margin-bottom: 1px;
white-space: pre;
}
</style>
<script>
function insertNodeAtPosnInElem(aNodeToInsert, aPosn, aParentId) {
var parent = document.getElementById(aParentId);
var insertBeforeTarget = parent.firstChild;
for (var i = 0; i < aPosn; i++) {
insertBeforeTarget = insertBeforeTarget.nextSibling;
}
parent.insertBefore(aNodeToInsert, insertBeforeTarget);
}
function createSpanElem() {
var span = document.createElement("span");
span.setAttribute("class", "inserted");
span.appendChild(document.createTextNode("[NewSpan]"));
return span;
}
function tweak() {
// Inserting span, on either side of existing content
// --------------------------------------------------
insertNodeAtPosnInElem(createSpanElem(), 0, "f0");
insertNodeAtPosnInElem(createSpanElem(), 1, "f1");
// Inserting span and whitespace, before existing content
// ------------------------------------------------------
insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f2");
insertNodeAtPosnInElem(createSpanElem(), 0, "f2");
insertNodeAtPosnInElem(createSpanElem(), 0, "f3");
insertNodeAtPosnInElem(document.createTextNode(" "), 0, "f3");
// Inserting span and whitespace, after existing content
// -----------------------------------------------------
insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f4");
insertNodeAtPosnInElem(createSpanElem(), 1, "f4");
insertNodeAtPosnInElem(createSpanElem(), 1, "f5");
insertNodeAtPosnInElem(document.createTextNode(" "), 1, "f5");
// Inserting span and text, before existing content
// ------------------------------------------------
insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f6");
insertNodeAtPosnInElem(createSpanElem(), 0, "f6");
insertNodeAtPosnInElem(createSpanElem(), 0, "f7");
insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 0, "f7");
// Inserting span and text, after existing content
// -----------------------------------------------
insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f8");
insertNodeAtPosnInElem(createSpanElem(), 1, "f8");
insertNodeAtPosnInElem(createSpanElem(), 1, "f9");
insertNodeAtPosnInElem(document.createTextNode("[NewText]"), 1, "f9");
document.documentElement.removeAttribute("class");
}
window.addEventListener("MozReftestInvalidate", tweak, false);
</script>
</head>
<body>
<div class="flexbox" id="f0"><div>[OldText]</div></div>
<div class="flexbox" id="f1"><div>[OldText]</div></div>
<div class="flexbox" id="f2"><div>[OldText]</div></div>
<div class="flexbox" id="f3"><div>[OldText]</div></div>
<div class="flexbox" id="f4"><div>[OldText]</div></div>
<div class="flexbox" id="f5"><div>[OldText]</div></div>
<div class="flexbox" id="f6"><div>[OldText]</div></div>
<div class="flexbox" id="f7"><div>[OldText]</div></div>
<div class="flexbox" id="f8"><div>[OldText]</div></div>
<div class="flexbox" id="f9"><div>[OldText]</div></div>
</body>
</html>
|