dom/plugins/test/mochitest/test_crashing.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:d2d4d676a28f
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>
5
6 <body>
7 <script class="testbody" type="application/javascript">
8 SimpleTest.waitForExplicitFinish();
9 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
10
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 }
17
18 SimpleTest.expectChildProcessCrash();
19
20 var iframe = document.getElementById('iframe1');
21 var p = iframe.contentDocument.getElementById('plugin1');
22
23 p.setColor("FFFF00FF");
24
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 }
32
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 }
43
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 }
51
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 }
63
64 iframe.contentWindow.location.reload();
65 }
66
67 </script>
68 <iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>

mercurial