dom/plugins/test/mochitest/test_crashing.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

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

mercurial