dom/plugins/test/mochitest/test_crashing2.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <head>
     2   <title>Plugin crashing</title>
     3   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     4   <script type="application/javascript" src="utils.js"></script>
     6 <body onload="mainLoaded()">
     7   <iframe id="iframe1" src="about:blank" width="600" height="600"></iframe>
     9   <script class="testbody" type="application/javascript">
    10   SimpleTest.waitForExplicitFinish();
    11   setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    13   var iframe = document.getElementById('iframe1');
    15   function mainLoaded() {
    16     if (!SimpleTest.testPluginIsOOP()) {
    17       ok(true, "Skipping this test when test plugin is not OOP.");
    18       SimpleTest.finish();
    19       return;
    20     }
    22     SimpleTest.expectChildProcessCrash();
    24     var p = iframe.contentDocument.createElement('embed');
    25     p.setAttribute('id', 'plugin1');
    26     p.setAttribute('type', 'application/x-test');
    27     p.setAttribute('width', '400');
    28     p.setAttribute('height', '400');
    29     p.setAttribute('drawmode', 'solid');
    30     p.setAttribute('color', 'FF00FFFF');
    31     p.setAttribute('newCrash', 'true');
    32     iframe.contentDocument.body.appendChild(p);
    34     // The plugin will now crash when it is instantiated, but
    35     // that happens asynchronously. HACK: this should use an
    36     // event instead of nested pending runnables, but I don't
    37     // know of any DOM event that's fired when a plugin is
    38     // instantiated.
    39     SimpleTest.executeSoon(function() {
    40       SimpleTest.executeSoon(function() {
    41         ok(p.setColor === undefined,
    42            "Plugin should have crashed on creation");
    44         window.frameLoaded = reloaded1;
    45         iframe.contentWindow.location.replace('crashing_subpage.html');
    46       })
    47     });
    48   }
    50   function reloaded1() {
    51     var p = iframe.contentDocument.getElementById('plugin1');
    52     try {
    53       p.setColor('FF00FF00');
    54       ok(true, "Reloading after crash-on-new worked");
    55     }
    56     catch (e) {
    57       ok(false, "Reloading after crash-on-new didn't give us a usable plugin");
    58     }
    59     p.crashOnDestroy();
    60     // the child crash should happen here
    61     p.parentNode.removeChild(p);
    63     window.frameLoaded = reloaded2;
    64     SimpleTest.executeSoon(function() {
    65       iframe.contentWindow.location.reload();
    66     });
    67   }
    69   function reloaded2() {
    70     var p = iframe.contentDocument.getElementById('plugin1');
    71     try {
    72       p.setColor('FF00FF00');
    73       ok(true, "Reloading after crash-on-destroy worked");
    74     }
    75     catch (e) {
    76       ok(false, "Reloading after crash-on-destroy didn't give us a usable plugin");
    77     }
    78     SimpleTest.finish();
    79   }
    80   </script>

mercurial