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