diff options
Diffstat (limited to 'layout/mathml/tests/test_opentype-fraction.html')
-rw-r--r-- | layout/mathml/tests/test_opentype-fraction.html | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/layout/mathml/tests/test_opentype-fraction.html b/layout/mathml/tests/test_opentype-fraction.html new file mode 100644 index 000000000..ad25b2e4d --- /dev/null +++ b/layout/mathml/tests/test_opentype-fraction.html @@ -0,0 +1,187 @@ +<!doctype html> +<html> + <head> + <title>Open Type MATH - fraction</title> + <script type="application/javascript" + src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="application/javascript" + src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <meta charset="utf-8"/> + <style type="text/css"> + math { + font-size: 10px; + } + @font-face { + font-family: fraction-1; + src: url(/tests/fonts/math/fraction-1.otf); + } + @font-face { + font-family: fraction-2; + src: url(/tests/fonts/math/fraction-2.otf); + } + @font-face { + font-family: fraction-3; + src: url(/tests/fonts/math/fraction-3.otf); + } + @font-face { + font-family: fraction-4; + src: url(/tests/fonts/math/fraction-4.otf); + } + @font-face { + font-family: fraction-5; + src: url(/tests/fonts/math/fraction-5.otf); + } + @font-face { + font-family: fraction-6; + src: url(/tests/fonts/math/fraction-6.otf); + } + @font-face { + font-family: fraction-7; + src: url(/tests/fonts/math/fraction-7.otf); + } + @font-face { + font-family: fraction-8; + src: url(/tests/fonts/math/fraction-8.otf); + } + @font-face { + font-family: fraction-9; + src: url(/tests/fonts/math/fraction-9.otf); + } + </style> + <script type="text/javascript"> + var epsilon = 5; + function almostEqual(x, y) { return Math.abs(x - y) < epsilon; } + + function getBox(aId) { + return document.getElementById(aId).getBoundingClientRect(); + } + + function doTest() { + /* inline style */ + var ref = getBox("ref").height; + + ok(almostEqual(getBox("d1").top - getBox("n1").bottom, ref * 20), + "Bad FractionRuleThickness"); + + ok(almostEqual(getBox("n1").top, getBox("n2").top) && + almostEqual(getBox("d2").top - getBox("n2").bottom, ref * 10.5), + "Bad FractionNumeratorGapMin"); + + ok(almostEqual(getBox("d1").bottom, getBox("d3").bottom) && + almostEqual(getBox("d3").top - getBox("n3").bottom, ref * 10.5), + "Bad FractionDenominatorGapMin"); + + ok(almostEqual(getBox("ref").top - getBox("n4").top, ref*3), + "Bad FractionNumeratorShiftUp"); + + ok(almostEqual(getBox("d5").bottom - getBox("ref").bottom, ref*3), + "Bad FractionDenominatorShiftDown"); + + /* display style */ + ref = getBox("dref").height; + + ok(almostEqual(getBox("dd1").top - getBox("dn1").bottom, ref * 20), + "Bad FractionRuleThickness"); + + ok(almostEqual(getBox("dn1").top, getBox("n6").top) && + almostEqual(getBox("d6").top - getBox("n6").bottom, ref * 10.5), + "Bad FractionNumeratorDisplayStyleGapMin"); + + ok(almostEqual(getBox("dd1").bottom, getBox("d7").bottom) && + almostEqual(getBox("d7").top - getBox("n7").bottom, ref * 10.5), + "Bad FractionDenominatorDisplayStyleGapMin"); + + ok(almostEqual(getBox("dref").top - getBox("n8").top, ref*3), + "Bad FractionNumeratorDisplayStyleShiftUp"); + + ok(almostEqual(getBox("d9").bottom - getBox("dref").bottom, ref*3), + "Bad FractionDenominatorDisplayStyleShiftDown"); + + SimpleTest.finish(); + } + </script> + </head> + <body onload="doTest()"> + + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=961365"> + Mozilla Bug 961365 + </a> + + <p id="display"></p> + + <p> + <math> + <mspace id="ref" height="1em" width="1em" mathbackground="green"/> + </math> + <math style="font-family: fraction-1;"> + <mfrac> + <mspace id="n1" height="1em" width="1em" mathbackground="red"/> + <mspace id="d1" height="1em" width="1em" mathbackground="red"/> + </mfrac> + </math> + <math style="font-family: fraction-2;"> + <mfrac> + <mspace id="n2" height="1em" width="1em" mathbackground="red"/> + <mspace id="d2" height="1em" width="1em" mathbackground="red"/> + </mfrac> + </math> + <math style="font-family: fraction-3;"> + <mfrac> + <mspace id="n3" height="1em" width="1em" mathbackground="red"/> + <mspace id="d3" height="1em" width="1em" mathbackground="red"/> + </mfrac> + </math> + <math style="font-family: fraction-4;"> + <mfrac> + <mspace id="n4" height="1em" width="1em" mathbackground="red"/> + <mspace id="d4" height="1em" width="1em" mathbackground="red"/> + </mfrac> + </math> + <math style="font-family: fraction-5;"> + <mfrac> + <mspace id="n5" height="1em" width="1em" mathbackground="red"/> + <mspace id="d5" height="1em" width="1em" mathbackground="red"/> + </mfrac> + </math> + </p> + + <p> + <math displaystyle="true"> + <mspace id="dref" height="1em" width="1em" mathbackground="green"/> + </math> + <math displaystyle="true" style="font-family: fraction-1;"> + <mfrac> + <mspace id="dn1" height="1em" width="1em" mathbackground="red"/> + <mspace id="dd1" height="1em" width="1em" mathbackground="red"/> + </mfrac> + </math> + <math displaystyle="true" style="font-family: fraction-6;"> + <mfrac> + <mspace id="n6" height="1em" width="1em" mathbackground="red"/> + <mspace id="d6" height="1em" width="1em" mathbackground="red"/> + </mfrac> + </math> + <math displaystyle="true" style="font-family: fraction-7;"> + <mfrac> + <mspace id="n7" height="1em" width="1em" mathbackground="red"/> + <mspace id="d7" height="1em" width="1em" mathbackground="red"/> + </mfrac> + </math> + <math displaystyle="true" style="font-family: fraction-8;"> + <mfrac> + <mspace id="n8" height="1em" width="1em" mathbackground="red"/> + <mspace id="d8" height="1em" width="1em" mathbackground="red"/> + </mfrac> + </math> + <math displaystyle="true" style="font-family: fraction-9;"> + <mfrac> + <mspace id="n9" height="1em" width="1em" mathbackground="red"/> + <mspace id="d9" height="1em" width="1em" mathbackground="red"/> + </mfrac> + </math> + </p> + + </body> +</html> |