gecko/modules/plugin/test/mochitest/test_hanging.html
Chris Jones efa51c360c Bug 544345: Mochitest of plugin hangs. r=bsmedberg
--HG--
extra : transplant_source : %0F%8A%10%CC%7C%A3%1C%F3%A1%05%B0%0D%AA%7EH%A6%29%23%EE%85
2010-02-11 14:32:19 -06:00

76 lines
2.2 KiB
HTML

<head>
<title>Plugin hanging</title>
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<body>
<iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
var iframe = document.getElementById('iframe1');
window.frameLoaded = function frameLoaded_toCrash() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var prefs = Components.classes['@mozilla.org/preferences-service;1']
.getService(Components.interfaces.nsIPrefBranch);
if (!prefs.getBoolPref('dom.ipc.plugins.enabled')) {
ok(true, "Skipping this test when IPC plugins are not enabled.");
SimpleTest.finish();
return;
}
// the default timeout is annoying high for mochitest runs
var timeoutPref = "dom.ipc.plugins.timeoutSecs";
prefs.setIntPref(timeoutPref, 5);
var p = iframe.contentDocument.getElementById('plugin1');
p.setColor("FFFF00FF");
try {
p.hang();
ok(false, "p.hang() should throw an exception");
}
catch (e) {
ok(true, "p.hang() should throw an exception");
}
try {
p.setColor("FFFF0000");
ok(false, "p.setColor should throw after the plugin crashes");
}
catch (e) {
ok(true, "p.setColor should throw after the plugin crashes");
}
window.frameLoaded = function reloaded() {
var p = iframe.contentDocument.getElementById('plugin1');
try {
p.setColor('FF00FF00');
ok(true, "Reloading worked");
}
catch (e) {
ok(false, "Reloading didn't give us a usable plugin");
}
try {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var prefs = Components.classes['@mozilla.org/preferences-service;1']
.getService(Components.interfaces.nsIPrefBranch);
prefs.clearUserPref(timeoutPref);
}
catch(e) {
ok(false, "Couldn't reset timeout pref");
}
SimpleTest.finish();
}
iframe.contentWindow.location.reload();
}
</script>