forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts-addChild.html
166 lines (146 loc) · 10.4 KB
/
scripts-addChild.html
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!doctype html>
<html>
<head>
<title>MathML script elements: adding children</title>
<!-- This test verifies insertion of children into an <mmultiscripts> element using DOM operations. It should not crash and should render the same as the equivalent static page. -->
<style type="text/css">
div { border: 1px solid; margin: .5em; }
</style>
<script type="text/javascript">
var mathmlNS = "http://www.w3.org/1998/Math/MathML";
function newMn(n)
{
var t = document.createTextNode(n.toString());
var mn = document.createElementNS(mathmlNS, "mn");
mn.appendChild(t);
return mn;
}
function newPrescripts()
{
var mprescripts = document.createElementNS(mathmlNS, "mprescripts");
return mprescripts;
}
function test1()
{
var test1content = document.getElementById("test1content");
var mmultiscripts = document.getElementById("test1").getElementsByTagNameNS(mathmlNS, "mmultiscripts");
// Insert in normal order
for (var child = test1content.firstChild; child; child = child.nextSibling) {
mmultiscripts[0].appendChild(child.cloneNode(true));
}
// Insert in reverse order
for (var child = test1content.lastChild; child; child = child.previousSibling) {
mmultiscripts[1].insertBefore(child.cloneNode(true), mmultiscripts[1].firstChild);
}
}
function test2()
{
var mmultiscripts = document.getElementById("test2").getElementsByTagNameNS(mathmlNS, "mmultiscripts");
for (var i = 0; i < mmultiscripts.length; i++) {
var childRef = mmultiscripts[i].firstChild;
for (var j = 0; j < i; j++) childRef = childRef.nextSibling;
mmultiscripts[i].insertBefore(newPrescripts(), childRef);
}
}
function test3()
{
var mmultiscripts = document.getElementById("test3").getElementsByTagNameNS(mathmlNS, "mmultiscripts");
for (var i = 0; i < mmultiscripts.length; i++) {
var childRef = mmultiscripts[i].firstChild;
for (var j = 0; j < i; j++) childRef = childRef.nextSibling;
mmultiscripts[i].insertBefore(newMn(10+i), childRef);
}
}
function test4()
{
var mmultiscripts = document.getElementById("test4").getElementsByTagNameNS(mathmlNS, "mmultiscripts");
for (var i = 0; i < mmultiscripts.length; i++) {
var childRef = mmultiscripts[i].firstChild;
for (var j = 0; j < i; j++) childRef = childRef.nextSibling;
mmultiscripts[i].insertBefore(newPrescripts(), childRef);
}
}
function test5()
{
var mmultiscripts = document.getElementById("test5").getElementsByTagNameNS(mathmlNS, "mmultiscripts");
for (var i = 0; i < mmultiscripts.length; i++) {
var childRef = mmultiscripts[i].firstChild;
for (var j = 0; j < i; j++) childRef = childRef.nextSibling;
mmultiscripts[i].insertBefore(newMn(10+i), childRef);
}
}
function run()
{
test1();
test2();
test3();
test4();
test5();
}
</script>
</head>
<body onload="run()">
<!-- Test 1: insert in normal and reverse order. -->
<div style="display: none">
<math id="test1content"><mn>0</mn><mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn><mn>7</mn><mn>8</mn></math>
</div>
<div id="test1">Test 1:
<math><mmultiscripts></mmultiscripts></math>
<math><mmultiscripts></mmultiscripts></math>
</div>
<!-- Test 2: insert an <mprescripts/> element. -->
<div id="test2">Test 2:
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
</div>
<!-- Test 3: insert an <mn> element. -->
<div id="test3">Test 3:
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
</div>
<!-- Test 4: insert an <mprescripts> element (different number of consecutive scripts) . -->
<div id="test4">Test 4:
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
</div>
<!-- Test 5: insert an <mn> element (different number of consecutive scripts) . -->
<div id="test5">Test 5:
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
</div>
</body>
</html>