layout/mathml/tests/test_bug827713-2.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/mathml/tests/test_bug827713-2.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,152 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<!--
     1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=553917
     1.7 +-->
     1.8 +<html>
     1.9 +  <head>
    1.10 +    <title>Test for error handling aspect of Bug 827713</title>
    1.11 +    <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +    <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.13 +    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.14 +    <script type="application/javascript">
    1.15 +
    1.16 +      var stringBundleService = 
    1.17 +        SpecialPowers.Cc["@mozilla.org/intl/stringbundle;1"]
    1.18 +                    .getService(SpecialPowers.Ci.nsIStringBundleService);
    1.19 +      var g_bundl =
    1.20 +        stringBundleService.createBundle("chrome://global/locale/mathml/mathml.properties");
    1.21 +      
    1.22 +      var g_errorInfo = {
    1.23 +        InvalidChild: {
    1.24 +          status : [false, false, false, false, false, false],
    1.25 +          args : [["mprescripts", "msubsup"], ["mprescripts", "msubsup"],
    1.26 +                 ["mprescripts", "msub"], ["none", "msub"], ["none","msup"],
    1.27 +                 ["none","msubsup"]]
    1.28 +        },
    1.29 +
    1.30 +        MMultiscriptsErrors: {
    1.31 +          status: [false, false],
    1.32 +          args: ["NoBase", "SubSupMismatch"]
    1.33 +        }
    1.34 +    };
    1.35 +      
    1.36 +      var g_errorTypes = ["InvalidChild", "MMultiscriptsErrors"];
    1.37 +      
    1.38 +      function getErrorMessage(name,idx)
    1.39 +      {
    1.40 +        if (name != "MMultiscriptsErrors") {
    1.41 +          return g_bundl.formatStringFromName(name,g_errorInfo[name].args[idx], 
    1.42 +                                            g_errorInfo[name].args[idx].length);
    1.43 +        }
    1.44 +        else {
    1.45 +          return g_bundl.GetStringFromName(g_errorInfo[name].args[idx]);
    1.46 +        }
    1.47 +      }
    1.48 +    
    1.49 +    /** Checks the roll call to see if all expected error messages were present. */
    1.50 +    function processRollCall()
    1.51 +    {
    1.52 +      for (var i=0; i<g_errorTypes.length;i++) {
    1.53 +        for (var j = 0; j < g_errorInfo[g_errorTypes[i]].status.length; j++) {
    1.54 +          ok(g_errorInfo[g_errorTypes[i]].status[j],
    1.55 +             "\"" + getErrorMessage(g_errorTypes[i], j)
    1.56 +                  + "\" was expected to be in the error console.");
    1.57 +        }
    1.58 +      }
    1.59 +    }
    1.60 +    
    1.61 +    /** Tests a candidate to see if it is one of the expected messages and updates the 
    1.62 +        g_errorInfo structure if it is. */
    1.63 +    function doRollCall(msg)
    1.64 +    {
    1.65 +      for (var i = 0; i < g_errorTypes.length; i++) {
    1.66 +        for (var j = 0; j < g_errorInfo[g_errorTypes[i]].status.length; j++) {
    1.67 +          if (msg == getErrorMessage(g_errorTypes[i], j))
    1.68 +          {
    1.69 +            g_errorInfo[g_errorTypes[i]].status[j] = true;
    1.70 +          }
    1.71 +        }
    1.72 +      }
    1.73 +    }
    1.74 +    
    1.75 +    SpecialPowers.registerConsoleListener(
    1.76 +      function (msg) {
    1.77 +        if (msg.message == "SENTINEL") {
    1.78 +          processRollCall();
    1.79 +          SimpleTest.finish();
    1.80 +        } else if (msg.isScriptError) {
    1.81 +          doRollCall(msg.errorMessage);
    1.82 +        }
    1.83 +      });
    1.84 +      
    1.85 +    SimpleTest.waitForExplicitFinish();
    1.86 +  </script>
    1.87 +  </head>
    1.88 +  <body onload="SpecialPowers.postConsoleSentinel();">
    1.89 +    <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=827713">Mozilla Bug 827713</a>
    1.90 +    
    1.91 +    <!-- InvalidChild -->
    1.92 +    <math>
    1.93 +      <msubsup>
    1.94 +        <mprescripts/>
    1.95 +      </msubsup>
    1.96 +    </math>
    1.97 +
    1.98 +    <math>
    1.99 +      <msubsup>
   1.100 +        <mprescripts/>
   1.101 +        <mprescripts/>
   1.102 +      </msubsup>
   1.103 +    </math>
   1.104 +
   1.105 +    <math>
   1.106 +      <msub>
   1.107 +        <mtext>a</mtext>
   1.108 +        <mprescripts/>
   1.109 +        <mtext>a</mtext>
   1.110 +        <mprescripts/>
   1.111 +      </msub>
   1.112 +    </math>
   1.113 +
   1.114 +    <math>
   1.115 +      <msub>
   1.116 +        <mtext>a</mtext>
   1.117 +        <none/>
   1.118 +      </msub>
   1.119 +    </math>
   1.120 +
   1.121 +    <math>
   1.122 +      <msup>
   1.123 +        <mtext>a</mtext>
   1.124 +        <none/>
   1.125 +      </msup>
   1.126 +    </math>
   1.127 +
   1.128 +    <math>
   1.129 +      <msubsup>
   1.130 +        <mtext>a</mtext>
   1.131 +        <mtext>b</mtext>
   1.132 +        <none/>
   1.133 +      </msubsup>
   1.134 +    </math>
   1.135 +
   1.136 +    <!-- NoBase -->
   1.137 +    <math>
   1.138 +      <mmultiscripts>
   1.139 +        <none/>
   1.140 +        <mtext>b</mtext>
   1.141 +        <mtext>c</mtext>
   1.142 +      </mmultiscripts>
   1.143 +    </math>
   1.144 +
   1.145 +    <!-- SubSupMismatch -->
   1.146 +    <math>
   1.147 +      <mmultiscripts>
   1.148 +        <mtext>b</mtext>
   1.149 +        <mtext>c</mtext>
   1.150 +        <mprescripts/>
   1.151 +        <mtext>a</mtext>
   1.152 +      </mmultiscripts>
   1.153 +    </math>
   1.154 +  </body>
   1.155 +</html>

mercurial