dom/plugins/test/mochitest/test_crash_nested_loop.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/test/mochitest/test_crash_nested_loop.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +<head>
     1.5 +  <title>Plugin crashing in nested loop</title>
     1.6 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.7 +  <script type="application/javascript" src="utils.js"></script>
     1.8 +
     1.9 +<body>
    1.10 +  <script class="testbody" type="application/javascript">
    1.11 +  SimpleTest.waitForExplicitFinish();
    1.12 +  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    1.13 +
    1.14 +  window.frameLoaded = function frameLoaded_toCrash() {
    1.15 +    if (!SimpleTest.testPluginIsOOP()) {
    1.16 +      ok(true, "Skipping this test when test plugin is not OOP.");
    1.17 +      SimpleTest.finish();
    1.18 +      return;
    1.19 +    }
    1.20 +
    1.21 +    var iframe = document.getElementById('iframe1');
    1.22 +    var p = iframe.contentDocument.getElementById('plugin1');
    1.23 +
    1.24 +    // This test is for bug 550026, which is inherently nondeterministic.
    1.25 +    // If we hit that bug, the browser process would crash when the plugin
    1.26 +    // crashes in crashInNestedLoop.  If not, we'll pass "spuriously".
    1.27 +    try {
    1.28 +      p.crashInNestedLoop();
    1.29 +      // The plugin didn't crash when expected.  This happens sometimes.  Give
    1.30 +      // it longer to crash.  If it crashes (but not at the apropriate time),
    1.31 +      // soft fail with a todo; if it doesn't crash then something went wrong,
    1.32 +      // so fail.
    1.33 +      setTimeout(
    1.34 +        function() {
    1.35 +          try {
    1.36 +            p.getPaintCount();
    1.37 +            ok(false, "plugin should crash");
    1.38 +          } catch (e) {
    1.39 +            todo(false, "p.crashInNestedLoop() should throw an exception");
    1.40 +          }
    1.41 +
    1.42 +          SimpleTest.finish();
    1.43 +        },
    1.44 +        1000);
    1.45 +    }
    1.46 +    catch (e) {
    1.47 +      ok(true, "p.crashInNestedLoop() should throw an exception");
    1.48 +      SimpleTest.finish();
    1.49 +    }
    1.50 +
    1.51 +  }
    1.52 +
    1.53 +  </script>
    1.54 +  <iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>

mercurial