dom/plugins/test/mochitest/test_crashing2.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/test/mochitest/test_crashing2.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     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 onload="mainLoaded()">
    1.10 +  <iframe id="iframe1" src="about:blank" width="600" height="600"></iframe>
    1.11 +
    1.12 +  <script class="testbody" type="application/javascript">
    1.13 +  SimpleTest.waitForExplicitFinish();
    1.14 +  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    1.15 +
    1.16 +  var iframe = document.getElementById('iframe1');
    1.17 +
    1.18 +  function mainLoaded() {
    1.19 +    if (!SimpleTest.testPluginIsOOP()) {
    1.20 +      ok(true, "Skipping this test when test plugin is not OOP.");
    1.21 +      SimpleTest.finish();
    1.22 +      return;
    1.23 +    }
    1.24 +
    1.25 +    SimpleTest.expectChildProcessCrash();
    1.26 +
    1.27 +    var p = iframe.contentDocument.createElement('embed');
    1.28 +    p.setAttribute('id', 'plugin1');
    1.29 +    p.setAttribute('type', 'application/x-test');
    1.30 +    p.setAttribute('width', '400');
    1.31 +    p.setAttribute('height', '400');
    1.32 +    p.setAttribute('drawmode', 'solid');
    1.33 +    p.setAttribute('color', 'FF00FFFF');
    1.34 +    p.setAttribute('newCrash', 'true');
    1.35 +    iframe.contentDocument.body.appendChild(p);
    1.36 +
    1.37 +    // The plugin will now crash when it is instantiated, but
    1.38 +    // that happens asynchronously. HACK: this should use an
    1.39 +    // event instead of nested pending runnables, but I don't
    1.40 +    // know of any DOM event that's fired when a plugin is
    1.41 +    // instantiated.
    1.42 +    SimpleTest.executeSoon(function() {
    1.43 +      SimpleTest.executeSoon(function() {
    1.44 +        ok(p.setColor === undefined,
    1.45 +           "Plugin should have crashed on creation");
    1.46 +
    1.47 +        window.frameLoaded = reloaded1;
    1.48 +        iframe.contentWindow.location.replace('crashing_subpage.html');
    1.49 +      })
    1.50 +    });
    1.51 +  }
    1.52 +
    1.53 +  function reloaded1() {
    1.54 +    var p = iframe.contentDocument.getElementById('plugin1');
    1.55 +    try {
    1.56 +      p.setColor('FF00FF00');
    1.57 +      ok(true, "Reloading after crash-on-new worked");
    1.58 +    }
    1.59 +    catch (e) {
    1.60 +      ok(false, "Reloading after crash-on-new didn't give us a usable plugin");
    1.61 +    }
    1.62 +    p.crashOnDestroy();
    1.63 +    // the child crash should happen here
    1.64 +    p.parentNode.removeChild(p);
    1.65 +
    1.66 +    window.frameLoaded = reloaded2;
    1.67 +    SimpleTest.executeSoon(function() {
    1.68 +      iframe.contentWindow.location.reload();
    1.69 +    });
    1.70 +  }
    1.71 +
    1.72 +  function reloaded2() {
    1.73 +    var p = iframe.contentDocument.getElementById('plugin1');
    1.74 +    try {
    1.75 +      p.setColor('FF00FF00');
    1.76 +      ok(true, "Reloading after crash-on-destroy worked");
    1.77 +    }
    1.78 +    catch (e) {
    1.79 +      ok(false, "Reloading after crash-on-destroy didn't give us a usable plugin");
    1.80 +    }
    1.81 +    SimpleTest.finish();
    1.82 +  }
    1.83 +  </script>

mercurial