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