dom/tests/mochitest/bugs/test_bug531176.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:bcb3526fcc9b
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=531176
5 -->
6 <head>
7 <title>Test for Bug 531176</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=531176">Mozilla Bug 531176</a>
13 <p id="display"></p>
14 <div id="content" style="display: none">
15
16 </div>
17 <pre id="test">
18 <script type="application/javascript">
19
20 /** Test for Bug 531176 **/
21
22 var errorCount = 0;
23 function errorHandler(msg, filename, linenr) {
24 is(msg, "SyntaxError: syntax error", "Wrong error!");
25 is(filename, window.location, "Wrong filename!");
26 is(linenr, 1, "Wrong linenr!");
27 ++errorCount;
28 }
29
30 window.onerror = errorHandler;
31 document.body.setAttribute("onclick", "var x=;");
32 // Force eager compilation
33 document.body.onclick;
34 is(errorCount, 1, "Error handler should have been called! (1)");
35
36 function recursiveHandler(msg, filename, linenr) {
37 is(msg, "SyntaxError: syntax error", "Wrong error!");
38 is(filename, window.location, "Wrong filename!");
39 is(linenr, 1, "Wrong linenr!");
40 ++errorCount;
41 document.body.setAttribute("onclick", "var z=;");
42 }
43
44 window.onerror = recursiveHandler;
45 document.body.setAttribute("onclick", "var y=;");
46 // Force eager compilation
47 document.body.onclick;
48 is(errorCount, 2, "Error handler should have been called! (2)");
49
50 // Check that error handler works even after recursion error.
51 document.body.setAttribute("onclick", "var foo=;");
52 // Force eager compilation
53 document.body.onclick;
54 is(errorCount, 3, "Error handler should have been called! (3)");
55
56 window.onerror = function() { ++errorCount; };
57 </script>
58 <script>
59 var foo =;
60 </script>
61 <script>
62 is(errorCount, 4, "Error handler should have been called! (4)");
63 </script>
64 </pre>
65 </body>
66 </html>

mercurial