167 lines
10 KiB
HTML
167 lines
10 KiB
HTML
<!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>
|