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

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

mercurial