dom/plugins/test/mochitest/test_crashing.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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>
     7   <script class="testbody" type="application/javascript">
     8   SimpleTest.waitForExplicitFinish();
     9   setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    11   window.frameLoaded = function frameLoaded_toCrash() {
    12    if (!SimpleTest.testPluginIsOOP()) {
    13       ok(true, "Skipping this test when test plugin is not OOP.");
    14       SimpleTest.finish();
    15       return;
    16     }
    18     SimpleTest.expectChildProcessCrash();
    20     var iframe = document.getElementById('iframe1');
    21     var p = iframe.contentDocument.getElementById('plugin1');
    23     p.setColor("FFFF00FF");
    25     try {
    26       p.crash();
    27       ok(false, "p.crash() should throw an exception");
    28     }
    29     catch (e) {
    30       ok(true, "p.crash() should throw an exception");
    31     }
    33     // Create random identifiers to test bug 560213
    34     for (var i = 0; i < 5; ++i) {
    35       var r = 'rid_' + Math.floor(Math.random() * 10000 + 1);
    36       try {
    37         ok(!(r in p), "unknown identifier in crashed plugin should fail silently");
    38       }
    39       catch (e) {
    40         ok(false, "unknown identifier check threw");
    41       }
    42     }
    44     try {
    45       p.setColor("FFFF0000");
    46       ok(false, "p.setColor should throw after the plugin crashes");
    47     }
    48     catch (e) {
    49       ok(true, "p.setColor should throw after the plugin crashes");
    50     }
    52     window.frameLoaded = function reloaded() {
    53       var p = iframe.contentDocument.getElementById('plugin1');
    54       try {
    55         p.setColor('FF00FF00');
    56         ok(true, "Reloading worked");
    57       }
    58       catch (e) {
    59         ok(false, "Reloading didn't give us a usable plugin");
    60       }
    61       SimpleTest.finish();
    62     }
    64     iframe.contentWindow.location.reload();
    65   }
    67   </script>
    68   <iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>

mercurial