|
1 <!DOCTYPE HTML> |
|
2 <!-- |
|
3 https://bugzilla.mozilla.org/show_bug.cgi?id=553917 |
|
4 --> |
|
5 <html> |
|
6 <head> |
|
7 <title>Test for error handling aspect of Bug 827713</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
11 <script type="application/javascript"> |
|
12 |
|
13 var stringBundleService = |
|
14 SpecialPowers.Cc["@mozilla.org/intl/stringbundle;1"] |
|
15 .getService(SpecialPowers.Ci.nsIStringBundleService); |
|
16 var g_bundl = |
|
17 stringBundleService.createBundle("chrome://global/locale/mathml/mathml.properties"); |
|
18 |
|
19 var g_errorInfo = { |
|
20 InvalidChild: { |
|
21 status : [false, false, false, false, false, false], |
|
22 args : [["mprescripts", "msubsup"], ["mprescripts", "msubsup"], |
|
23 ["mprescripts", "msub"], ["none", "msub"], ["none","msup"], |
|
24 ["none","msubsup"]] |
|
25 }, |
|
26 |
|
27 MMultiscriptsErrors: { |
|
28 status: [false, false], |
|
29 args: ["NoBase", "SubSupMismatch"] |
|
30 } |
|
31 }; |
|
32 |
|
33 var g_errorTypes = ["InvalidChild", "MMultiscriptsErrors"]; |
|
34 |
|
35 function getErrorMessage(name,idx) |
|
36 { |
|
37 if (name != "MMultiscriptsErrors") { |
|
38 return g_bundl.formatStringFromName(name,g_errorInfo[name].args[idx], |
|
39 g_errorInfo[name].args[idx].length); |
|
40 } |
|
41 else { |
|
42 return g_bundl.GetStringFromName(g_errorInfo[name].args[idx]); |
|
43 } |
|
44 } |
|
45 |
|
46 /** Checks the roll call to see if all expected error messages were present. */ |
|
47 function processRollCall() |
|
48 { |
|
49 for (var i=0; i<g_errorTypes.length;i++) { |
|
50 for (var j = 0; j < g_errorInfo[g_errorTypes[i]].status.length; j++) { |
|
51 ok(g_errorInfo[g_errorTypes[i]].status[j], |
|
52 "\"" + getErrorMessage(g_errorTypes[i], j) |
|
53 + "\" was expected to be in the error console."); |
|
54 } |
|
55 } |
|
56 } |
|
57 |
|
58 /** Tests a candidate to see if it is one of the expected messages and updates the |
|
59 g_errorInfo structure if it is. */ |
|
60 function doRollCall(msg) |
|
61 { |
|
62 for (var i = 0; i < g_errorTypes.length; i++) { |
|
63 for (var j = 0; j < g_errorInfo[g_errorTypes[i]].status.length; j++) { |
|
64 if (msg == getErrorMessage(g_errorTypes[i], j)) |
|
65 { |
|
66 g_errorInfo[g_errorTypes[i]].status[j] = true; |
|
67 } |
|
68 } |
|
69 } |
|
70 } |
|
71 |
|
72 SpecialPowers.registerConsoleListener( |
|
73 function (msg) { |
|
74 if (msg.message == "SENTINEL") { |
|
75 processRollCall(); |
|
76 SimpleTest.finish(); |
|
77 } else if (msg.isScriptError) { |
|
78 doRollCall(msg.errorMessage); |
|
79 } |
|
80 }); |
|
81 |
|
82 SimpleTest.waitForExplicitFinish(); |
|
83 </script> |
|
84 </head> |
|
85 <body onload="SpecialPowers.postConsoleSentinel();"> |
|
86 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=827713">Mozilla Bug 827713</a> |
|
87 |
|
88 <!-- InvalidChild --> |
|
89 <math> |
|
90 <msubsup> |
|
91 <mprescripts/> |
|
92 </msubsup> |
|
93 </math> |
|
94 |
|
95 <math> |
|
96 <msubsup> |
|
97 <mprescripts/> |
|
98 <mprescripts/> |
|
99 </msubsup> |
|
100 </math> |
|
101 |
|
102 <math> |
|
103 <msub> |
|
104 <mtext>a</mtext> |
|
105 <mprescripts/> |
|
106 <mtext>a</mtext> |
|
107 <mprescripts/> |
|
108 </msub> |
|
109 </math> |
|
110 |
|
111 <math> |
|
112 <msub> |
|
113 <mtext>a</mtext> |
|
114 <none/> |
|
115 </msub> |
|
116 </math> |
|
117 |
|
118 <math> |
|
119 <msup> |
|
120 <mtext>a</mtext> |
|
121 <none/> |
|
122 </msup> |
|
123 </math> |
|
124 |
|
125 <math> |
|
126 <msubsup> |
|
127 <mtext>a</mtext> |
|
128 <mtext>b</mtext> |
|
129 <none/> |
|
130 </msubsup> |
|
131 </math> |
|
132 |
|
133 <!-- NoBase --> |
|
134 <math> |
|
135 <mmultiscripts> |
|
136 <none/> |
|
137 <mtext>b</mtext> |
|
138 <mtext>c</mtext> |
|
139 </mmultiscripts> |
|
140 </math> |
|
141 |
|
142 <!-- SubSupMismatch --> |
|
143 <math> |
|
144 <mmultiscripts> |
|
145 <mtext>b</mtext> |
|
146 <mtext>c</mtext> |
|
147 <mprescripts/> |
|
148 <mtext>a</mtext> |
|
149 </mmultiscripts> |
|
150 </math> |
|
151 </body> |
|
152 </html> |