dom/plugins/test/mochitest/test_crashing.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/test/mochitest/test_crashing.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +<head>
     1.5 +  <title>Plugin crashing</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 +    SimpleTest.expectChildProcessCrash();
    1.22 +
    1.23 +    var iframe = document.getElementById('iframe1');
    1.24 +    var p = iframe.contentDocument.getElementById('plugin1');
    1.25 +
    1.26 +    p.setColor("FFFF00FF");
    1.27 +
    1.28 +    try {
    1.29 +      p.crash();
    1.30 +      ok(false, "p.crash() should throw an exception");
    1.31 +    }
    1.32 +    catch (e) {
    1.33 +      ok(true, "p.crash() should throw an exception");
    1.34 +    }
    1.35 +
    1.36 +    // Create random identifiers to test bug 560213
    1.37 +    for (var i = 0; i < 5; ++i) {
    1.38 +      var r = 'rid_' + Math.floor(Math.random() * 10000 + 1);
    1.39 +      try {
    1.40 +        ok(!(r in p), "unknown identifier in crashed plugin should fail silently");
    1.41 +      }
    1.42 +      catch (e) {
    1.43 +        ok(false, "unknown identifier check threw");
    1.44 +      }
    1.45 +    }
    1.46 +
    1.47 +    try {
    1.48 +      p.setColor("FFFF0000");
    1.49 +      ok(false, "p.setColor should throw after the plugin crashes");
    1.50 +    }
    1.51 +    catch (e) {
    1.52 +      ok(true, "p.setColor should throw after the plugin crashes");
    1.53 +    }
    1.54 +
    1.55 +    window.frameLoaded = function reloaded() {
    1.56 +      var p = iframe.contentDocument.getElementById('plugin1');
    1.57 +      try {
    1.58 +        p.setColor('FF00FF00');
    1.59 +        ok(true, "Reloading worked");
    1.60 +      }
    1.61 +      catch (e) {
    1.62 +        ok(false, "Reloading didn't give us a usable plugin");
    1.63 +      }
    1.64 +      SimpleTest.finish();
    1.65 +    }
    1.66 +
    1.67 +    iframe.contentWindow.location.reload();
    1.68 +  }
    1.69 +
    1.70 +  </script>
    1.71 +  <iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>

mercurial