зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
1a685eee60
Коммит
2874b31c9e
|
@ -80,6 +80,7 @@ ifdef MOZ_IPC
|
|||
_MOCHITEST_FILES += \
|
||||
test_crashing.html \
|
||||
test_crashing2.html \
|
||||
test_hanging.html \
|
||||
crashing_subpage.html \
|
||||
$(NULL)
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
<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>
|
|
@ -67,8 +67,8 @@
|
|||
|
||||
int gCrashCount = 0;
|
||||
|
||||
void
|
||||
IntentionalCrash()
|
||||
static void
|
||||
NoteIntentionalCrash()
|
||||
{
|
||||
char* bloatLog = getenv("XPCOM_MEM_BLOAT_LOG");
|
||||
if (bloatLog) {
|
||||
|
@ -85,6 +85,13 @@ IntentionalCrash()
|
|||
fprintf(processfd, "==> process %d will purposefully crash\n", getpid());
|
||||
fclose(processfd);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
IntentionalCrash()
|
||||
{
|
||||
NoteIntentionalCrash();
|
||||
|
||||
int *pi = NULL;
|
||||
*pi = 55; // Crash dereferencing null pointer
|
||||
++gCrashCount;
|
||||
|
@ -146,6 +153,7 @@ static bool getCookie(NPObject* npobj, const NPVariant* args, uint32_t argCount,
|
|||
static bool getAuthInfo(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool asyncCallbackTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool checkGCRace(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool hangPlugin(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
|
||||
static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
||||
"npnEvaluateTest",
|
||||
|
@ -184,6 +192,7 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
|||
"getAuthInfo",
|
||||
"asyncCallbackTest",
|
||||
"checkGCRace",
|
||||
"hang",
|
||||
};
|
||||
static NPIdentifier sPluginMethodIdentifiers[ARRAY_LENGTH(sPluginMethodIdentifierNames)];
|
||||
static const ScriptableFunction sPluginMethodFunctions[ARRAY_LENGTH(sPluginMethodIdentifierNames)] = {
|
||||
|
@ -223,6 +232,7 @@ static const ScriptableFunction sPluginMethodFunctions[ARRAY_LENGTH(sPluginMetho
|
|||
getAuthInfo,
|
||||
asyncCallbackTest,
|
||||
checkGCRace,
|
||||
hangPlugin,
|
||||
};
|
||||
|
||||
struct URLNotifyData
|
||||
|
@ -2552,3 +2562,21 @@ checkGCRace(NPObject* npobj, const NPVariant* args, uint32_t argCount,
|
|||
OBJECT_TO_NPVARIANT(localFunc, *result);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
hangPlugin(NPObject* npobj, const NPVariant* args, uint32_t argCount,
|
||||
NPVariant* result)
|
||||
{
|
||||
NoteIntentionalCrash();
|
||||
|
||||
#ifdef XP_WIN
|
||||
Sleep(100000000);
|
||||
#else
|
||||
pause();
|
||||
#endif
|
||||
// NB: returning true here means that we weren't terminated, and
|
||||
// thus the hang detection/handling didn't work correctly. The
|
||||
// test harness will succeed in calling this function, and the
|
||||
// test will fail.
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче