dom/tests/mochitest/bugs/test_bug531176.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/bugs/test_bug531176.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=531176
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 531176</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=531176">Mozilla Bug 531176</a>
    1.16 +<p id="display"></p>
    1.17 +<div id="content" style="display: none">
    1.18 +  
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script type="application/javascript">
    1.22 +
    1.23 +/** Test for Bug 531176 **/
    1.24 +
    1.25 +var errorCount = 0;
    1.26 +function errorHandler(msg, filename, linenr) {
    1.27 +  is(msg, "SyntaxError: syntax error", "Wrong error!");
    1.28 +  is(filename, window.location, "Wrong filename!");
    1.29 +  is(linenr, 1, "Wrong linenr!");
    1.30 +  ++errorCount;
    1.31 +}
    1.32 +
    1.33 +window.onerror = errorHandler;
    1.34 +document.body.setAttribute("onclick", "var x=;");
    1.35 +// Force eager compilation
    1.36 +document.body.onclick;
    1.37 +is(errorCount, 1, "Error handler should have been called! (1)");
    1.38 +
    1.39 +function recursiveHandler(msg, filename, linenr) {
    1.40 +  is(msg, "SyntaxError: syntax error", "Wrong error!");
    1.41 +  is(filename, window.location, "Wrong filename!");
    1.42 +  is(linenr, 1, "Wrong linenr!");
    1.43 +  ++errorCount;
    1.44 +  document.body.setAttribute("onclick", "var z=;");
    1.45 +}
    1.46 +
    1.47 +window.onerror = recursiveHandler;
    1.48 +document.body.setAttribute("onclick", "var y=;");
    1.49 +// Force eager compilation
    1.50 +document.body.onclick;
    1.51 +is(errorCount, 2, "Error handler should have been called! (2)");
    1.52 +
    1.53 +// Check that error handler works even after recursion error.
    1.54 +document.body.setAttribute("onclick", "var foo=;");
    1.55 +// Force eager compilation
    1.56 +document.body.onclick;
    1.57 +is(errorCount, 3, "Error handler should have been called! (3)");
    1.58 +
    1.59 +window.onerror = function() { ++errorCount; };
    1.60 +</script>
    1.61 +<script>
    1.62 +var foo =;
    1.63 +</script>
    1.64 +<script>
    1.65 +is(errorCount, 4, "Error handler should have been called! (4)");
    1.66 +</script>
    1.67 +</pre>
    1.68 +</body>
    1.69 +</html>

mercurial