Bug 975681 - Mochitest for MathML mfrac. r=fredw
authorAnuj Agarwal <anujagarwal464@gmail.com>
Tue, 01 Apr 2014 08:34:51 -0400
changeset 195012 742f05b9917b1a6063a475749eecd28cdbaca985
parent 195011 e06713a76a41e2ebb0a56163be9084fc98d2400c
child 195013 9d0ede143f7cb8f26ecbe1fb48f031987526b8c8
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfredw
bugs975681
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 975681 - Mochitest for MathML mfrac. r=fredw
layout/mathml/tests/mochitest.ini
layout/mathml/tests/test_bug975681.html
--- a/layout/mathml/tests/mochitest.ini
+++ b/layout/mathml/tests/mochitest.ini
@@ -1,6 +1,7 @@
 [DEFAULT]
 
 [test_bug553917.html]
 [test_bug706406.html]
 [test_bug827713-2.html]
 [test_bug827713.html]
+[test_bug975681.html]
new file mode 100644
--- /dev/null
+++ b/layout/mathml/tests/test_bug975681.html
@@ -0,0 +1,118 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=975681
+-->
+  <head>
+    <meta charset="utf-8">
+    <title> Test for Bug 975681 </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"/>
+  </head>
+  <body>
+  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=975681"> Mozilla Bug 975681 </a>
+  <p id="display"></p>
+    
+  <p>
+    <math>
+      <mfrac id="test_mfrac">
+        <mspace width="100px" height="20px" mathbackground="red"></mspace>
+        <mspace width="100px" height="20px" mathbackground="red"></mspace>
+      </mfrac>
+    </math>
+  </p>
+  
+  <p>
+    <math>
+      <mfrac linethickness="30px" id="mfrac_linethickness">
+        <mspace width="100px" height="20px" mathbackground="red"></mspace>
+        <mspace width="100px" height="20px" mathbackground="red"></mspace>
+      </mfrac>
+    </math>
+  </p>
+  
+  <p>
+    <math>
+      <mfrac numalign="left" id="mfrac_numalign">
+        <mspace width="50px" height="20px" mathbackground="red"></mspace>
+        <mspace width="100px" height="20px" mathbackground="red"></mspace>
+      </mfrac>
+    </math>
+  </p>
+  
+  <p>
+    <math>
+      <mfrac denomalign="right" id="mfrac_denomalign">
+        <mspace width="100px" height="20px" mathbackground="red"></mspace>
+        <mspace width="50px" height="20px" mathbackground="red"></mspace>
+      </mfrac>
+    </math>
+  </p>
+  
+  <p>
+    <math>
+      <mfrac bevelled="true" id="mfrac_bevelled">
+        <mspace width="100px" height="20px" mathbackground="red"></mspace>
+        <mspace width="100px" height="20px" mathbackground="red"></mspace>
+      </mfrac>
+    </math>
+  </p>
+  
+  <pre id="test">
+  <script type="application/javascript">
+      
+    /** Test for Bug 975681 **/
+    SimpleTest.waitForExplicitFinish();
+     
+    var epsilon = 1; // allow a small relative error
+    var delta = .25;  // used to indicate a small shift
+    
+    function almostEqualAbs(x, y) {
+      var e = Math.abs(x - y);
+      return (e <= epsilon);
+    }
+    
+    function almostLessThanAbs(x, y) {
+      var e = x - y;
+      return (e <= epsilon);
+    }
+    
+    // test: mfrac
+    var mfracNum = document.getElementById("test_mfrac").firstElementChild.getBoundingClientRect();
+    var mfracDenom = document.getElementById("test_mfrac").lastElementChild.getBoundingClientRect();
+    
+    ok(almostEqualAbs(mfracNum.left, mfracDenom.left) && 
+      almostEqualAbs(mfracNum.right, mfracDenom.right), "Numerator and denominator should be vertical aligned");
+    
+    ok(almostLessThanAbs(mfracNum.bottom, mfracDenom.top), "Numerator should be above denominator");
+    
+    // test: mfrac attributes
+    var mfrac = document.getElementById("mfrac_linethickness").getBoundingClientRect();
+    var num = document.getElementById("mfrac_linethickness").firstElementChild.getBoundingClientRect();
+    var denom = document.getElementById("mfrac_linethickness").lastElementChild.getBoundingClientRect();
+    
+    ok(almostLessThanAbs(num.height + 30 + denom.height, mfrac.height) && 
+      almostLessThanAbs(num.bottom + 30, denom.top), "numerator and denominator should be separated by linethickness");
+    
+    num = document.getElementById("mfrac_numalign").firstElementChild.getBoundingClientRect();
+    mfrac = document.getElementById("mfrac_numalign").getBoundingClientRect();
+    
+    ok(almostEqualAbs(num.left, mfrac.left), "numerator should be aligned left");
+      
+    mfrac = document.getElementById("mfrac_denomalign").getBoundingClientRect();
+    denom = document.getElementById("mfrac_denomalign").lastElementChild.getBoundingClientRect();
+    
+    ok(almostEqualAbs(mfrac.right, denom.right), "denominator should be aligned right");
+      
+    num = document.getElementById("mfrac_bevelled").firstElementChild.getBoundingClientRect();
+    denom = document.getElementById("mfrac_bevelled").lastElementChild.getBoundingClientRect();
+    
+    ok(almostLessThanAbs(num.right, denom.left) && 
+      almostLessThanAbs(num.top*(1-delta)+num.bottom*delta, denom.top), "incorrect position of mfrac children");
+    
+    SimpleTest.finish();
+    
+  </script>
+  </body>
+</html>