1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/mathml/tests/test_bug975681.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,118 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=975681 1.8 +--> 1.9 + <head> 1.10 + <meta charset="utf-8"> 1.11 + <title> Test for Bug 975681 </title> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> </script> 1.13 + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"> </script> 1.14 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.15 + </head> 1.16 + <body> 1.17 + <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=975681"> Mozilla Bug 975681 </a> 1.18 + <p id="display"></p> 1.19 + 1.20 + <p> 1.21 + <math> 1.22 + <mfrac id="test_mfrac"> 1.23 + <mspace width="100px" height="20px" mathbackground="red"></mspace> 1.24 + <mspace width="100px" height="20px" mathbackground="red"></mspace> 1.25 + </mfrac> 1.26 + </math> 1.27 + </p> 1.28 + 1.29 + <p> 1.30 + <math> 1.31 + <mfrac linethickness="30px" id="mfrac_linethickness"> 1.32 + <mspace width="100px" height="20px" mathbackground="red"></mspace> 1.33 + <mspace width="100px" height="20px" mathbackground="red"></mspace> 1.34 + </mfrac> 1.35 + </math> 1.36 + </p> 1.37 + 1.38 + <p> 1.39 + <math> 1.40 + <mfrac numalign="left" id="mfrac_numalign"> 1.41 + <mspace width="50px" height="20px" mathbackground="red"></mspace> 1.42 + <mspace width="100px" height="20px" mathbackground="red"></mspace> 1.43 + </mfrac> 1.44 + </math> 1.45 + </p> 1.46 + 1.47 + <p> 1.48 + <math> 1.49 + <mfrac denomalign="right" id="mfrac_denomalign"> 1.50 + <mspace width="100px" height="20px" mathbackground="red"></mspace> 1.51 + <mspace width="50px" height="20px" mathbackground="red"></mspace> 1.52 + </mfrac> 1.53 + </math> 1.54 + </p> 1.55 + 1.56 + <p> 1.57 + <math> 1.58 + <mfrac bevelled="true" id="mfrac_bevelled"> 1.59 + <mspace width="100px" height="20px" mathbackground="red"></mspace> 1.60 + <mspace width="100px" height="20px" mathbackground="red"></mspace> 1.61 + </mfrac> 1.62 + </math> 1.63 + </p> 1.64 + 1.65 + <pre id="test"> 1.66 + <script type="application/javascript"> 1.67 + 1.68 + /** Test for Bug 975681 **/ 1.69 + SimpleTest.waitForExplicitFinish(); 1.70 + 1.71 + var epsilon = 1; // allow a small relative error 1.72 + var delta = .25; // used to indicate a small shift 1.73 + 1.74 + function almostEqualAbs(x, y) { 1.75 + var e = Math.abs(x - y); 1.76 + return (e <= epsilon); 1.77 + } 1.78 + 1.79 + function almostLessThanAbs(x, y) { 1.80 + var e = x - y; 1.81 + return (e <= epsilon); 1.82 + } 1.83 + 1.84 + // test: mfrac 1.85 + var mfracNum = document.getElementById("test_mfrac").firstElementChild.getBoundingClientRect(); 1.86 + var mfracDenom = document.getElementById("test_mfrac").lastElementChild.getBoundingClientRect(); 1.87 + 1.88 + ok(almostEqualAbs(mfracNum.left, mfracDenom.left) && 1.89 + almostEqualAbs(mfracNum.right, mfracDenom.right), "Numerator and denominator should be vertical aligned"); 1.90 + 1.91 + ok(almostLessThanAbs(mfracNum.bottom, mfracDenom.top), "Numerator should be above denominator"); 1.92 + 1.93 + // test: mfrac attributes 1.94 + var mfrac = document.getElementById("mfrac_linethickness").getBoundingClientRect(); 1.95 + var num = document.getElementById("mfrac_linethickness").firstElementChild.getBoundingClientRect(); 1.96 + var denom = document.getElementById("mfrac_linethickness").lastElementChild.getBoundingClientRect(); 1.97 + 1.98 + ok(almostLessThanAbs(num.height + 30 + denom.height, mfrac.height) && 1.99 + almostLessThanAbs(num.bottom + 30, denom.top), "numerator and denominator should be separated by linethickness"); 1.100 + 1.101 + num = document.getElementById("mfrac_numalign").firstElementChild.getBoundingClientRect(); 1.102 + mfrac = document.getElementById("mfrac_numalign").getBoundingClientRect(); 1.103 + 1.104 + ok(almostEqualAbs(num.left, mfrac.left), "numerator should be aligned left"); 1.105 + 1.106 + mfrac = document.getElementById("mfrac_denomalign").getBoundingClientRect(); 1.107 + denom = document.getElementById("mfrac_denomalign").lastElementChild.getBoundingClientRect(); 1.108 + 1.109 + ok(almostEqualAbs(mfrac.right, denom.right), "denominator should be aligned right"); 1.110 + 1.111 + num = document.getElementById("mfrac_bevelled").firstElementChild.getBoundingClientRect(); 1.112 + denom = document.getElementById("mfrac_bevelled").lastElementChild.getBoundingClientRect(); 1.113 + 1.114 + ok(almostLessThanAbs(num.right, denom.left) && 1.115 + almostLessThanAbs(num.top*(1-delta)+num.bottom*delta, denom.top), "incorrect position of mfrac children"); 1.116 + 1.117 + SimpleTest.finish(); 1.118 + 1.119 + </script> 1.120 + </body> 1.121 +</html>