layout/mathml/tests/test_bug975681.html

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=975681
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <meta charset="utf-8">
michael@0 8 <title> Test for Bug 975681 </title>
michael@0 9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> </script>
michael@0 10 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"> </script>
michael@0 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 12 </head>
michael@0 13 <body>
michael@0 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=975681"> Mozilla Bug 975681 </a>
michael@0 15 <p id="display"></p>
michael@0 16
michael@0 17 <p>
michael@0 18 <math>
michael@0 19 <mfrac id="test_mfrac">
michael@0 20 <mspace width="100px" height="20px" mathbackground="red"></mspace>
michael@0 21 <mspace width="100px" height="20px" mathbackground="red"></mspace>
michael@0 22 </mfrac>
michael@0 23 </math>
michael@0 24 </p>
michael@0 25
michael@0 26 <p>
michael@0 27 <math>
michael@0 28 <mfrac linethickness="30px" id="mfrac_linethickness">
michael@0 29 <mspace width="100px" height="20px" mathbackground="red"></mspace>
michael@0 30 <mspace width="100px" height="20px" mathbackground="red"></mspace>
michael@0 31 </mfrac>
michael@0 32 </math>
michael@0 33 </p>
michael@0 34
michael@0 35 <p>
michael@0 36 <math>
michael@0 37 <mfrac numalign="left" id="mfrac_numalign">
michael@0 38 <mspace width="50px" height="20px" mathbackground="red"></mspace>
michael@0 39 <mspace width="100px" height="20px" mathbackground="red"></mspace>
michael@0 40 </mfrac>
michael@0 41 </math>
michael@0 42 </p>
michael@0 43
michael@0 44 <p>
michael@0 45 <math>
michael@0 46 <mfrac denomalign="right" id="mfrac_denomalign">
michael@0 47 <mspace width="100px" height="20px" mathbackground="red"></mspace>
michael@0 48 <mspace width="50px" height="20px" mathbackground="red"></mspace>
michael@0 49 </mfrac>
michael@0 50 </math>
michael@0 51 </p>
michael@0 52
michael@0 53 <p>
michael@0 54 <math>
michael@0 55 <mfrac bevelled="true" id="mfrac_bevelled">
michael@0 56 <mspace width="100px" height="20px" mathbackground="red"></mspace>
michael@0 57 <mspace width="100px" height="20px" mathbackground="red"></mspace>
michael@0 58 </mfrac>
michael@0 59 </math>
michael@0 60 </p>
michael@0 61
michael@0 62 <pre id="test">
michael@0 63 <script type="application/javascript">
michael@0 64
michael@0 65 /** Test for Bug 975681 **/
michael@0 66 SimpleTest.waitForExplicitFinish();
michael@0 67
michael@0 68 var epsilon = 1; // allow a small relative error
michael@0 69 var delta = .25; // used to indicate a small shift
michael@0 70
michael@0 71 function almostEqualAbs(x, y) {
michael@0 72 var e = Math.abs(x - y);
michael@0 73 return (e <= epsilon);
michael@0 74 }
michael@0 75
michael@0 76 function almostLessThanAbs(x, y) {
michael@0 77 var e = x - y;
michael@0 78 return (e <= epsilon);
michael@0 79 }
michael@0 80
michael@0 81 // test: mfrac
michael@0 82 var mfracNum = document.getElementById("test_mfrac").firstElementChild.getBoundingClientRect();
michael@0 83 var mfracDenom = document.getElementById("test_mfrac").lastElementChild.getBoundingClientRect();
michael@0 84
michael@0 85 ok(almostEqualAbs(mfracNum.left, mfracDenom.left) &&
michael@0 86 almostEqualAbs(mfracNum.right, mfracDenom.right), "Numerator and denominator should be vertical aligned");
michael@0 87
michael@0 88 ok(almostLessThanAbs(mfracNum.bottom, mfracDenom.top), "Numerator should be above denominator");
michael@0 89
michael@0 90 // test: mfrac attributes
michael@0 91 var mfrac = document.getElementById("mfrac_linethickness").getBoundingClientRect();
michael@0 92 var num = document.getElementById("mfrac_linethickness").firstElementChild.getBoundingClientRect();
michael@0 93 var denom = document.getElementById("mfrac_linethickness").lastElementChild.getBoundingClientRect();
michael@0 94
michael@0 95 ok(almostLessThanAbs(num.height + 30 + denom.height, mfrac.height) &&
michael@0 96 almostLessThanAbs(num.bottom + 30, denom.top), "numerator and denominator should be separated by linethickness");
michael@0 97
michael@0 98 num = document.getElementById("mfrac_numalign").firstElementChild.getBoundingClientRect();
michael@0 99 mfrac = document.getElementById("mfrac_numalign").getBoundingClientRect();
michael@0 100
michael@0 101 ok(almostEqualAbs(num.left, mfrac.left), "numerator should be aligned left");
michael@0 102
michael@0 103 mfrac = document.getElementById("mfrac_denomalign").getBoundingClientRect();
michael@0 104 denom = document.getElementById("mfrac_denomalign").lastElementChild.getBoundingClientRect();
michael@0 105
michael@0 106 ok(almostEqualAbs(mfrac.right, denom.right), "denominator should be aligned right");
michael@0 107
michael@0 108 num = document.getElementById("mfrac_bevelled").firstElementChild.getBoundingClientRect();
michael@0 109 denom = document.getElementById("mfrac_bevelled").lastElementChild.getBoundingClientRect();
michael@0 110
michael@0 111 ok(almostLessThanAbs(num.right, denom.left) &&
michael@0 112 almostLessThanAbs(num.top*(1-delta)+num.bottom*delta, denom.top), "incorrect position of mfrac children");
michael@0 113
michael@0 114 SimpleTest.finish();
michael@0 115
michael@0 116 </script>
michael@0 117 </body>
michael@0 118 </html>

mercurial