mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 541446 - sort out details of where OOP minidumps should wind up. r=benjamin
--HG-- rename : modules/plugin/test/mochitest/test_crash_notify.xul => modules/plugin/test/mochitest/test_crash_notify_no_report.xul
This commit is contained in:
parent
38218420d5
commit
264dc95781
@ -45,68 +45,69 @@ include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_MOCHITEST_FILES = \
|
||||
test_getauthenticationinfo.html \
|
||||
test_npobject_getters.html \
|
||||
test_npruntime_npnevaluate.html \
|
||||
test_npruntime_npninvoke.html \
|
||||
test_npruntime_npninvokedefault.html \
|
||||
loremipsum.txt \
|
||||
loremipsum_file.txt \
|
||||
post.sjs \
|
||||
pluginstream.js \
|
||||
plugin_window.html \
|
||||
test_painting.html \
|
||||
test_pluginstream_err.html \
|
||||
test_pluginstream_src.html \
|
||||
test_pluginstream_geturl.html \
|
||||
test_pluginstream_geturlnotify.html \
|
||||
test_pluginstream_asfile.html \
|
||||
test_pluginstream_asfileonly.html \
|
||||
test_pluginstream_post.html \
|
||||
test_pluginstream_poststream.html \
|
||||
test_pluginstream_seek.html \
|
||||
test_pluginstream_newstream.html \
|
||||
test_multipleinstanceobjects.html \
|
||||
test_streamNotify.html \
|
||||
test_instantiation.html \
|
||||
test_cookies.html \
|
||||
test_npn_timers.html \
|
||||
test_npn_asynccall.html \
|
||||
$(NULL)
|
||||
test_getauthenticationinfo.html \
|
||||
test_npobject_getters.html \
|
||||
test_npruntime_npnevaluate.html \
|
||||
test_npruntime_npninvoke.html \
|
||||
test_npruntime_npninvokedefault.html \
|
||||
loremipsum.txt \
|
||||
loremipsum_file.txt \
|
||||
post.sjs \
|
||||
pluginstream.js \
|
||||
plugin_window.html \
|
||||
test_painting.html \
|
||||
test_pluginstream_err.html \
|
||||
test_pluginstream_src.html \
|
||||
test_pluginstream_geturl.html \
|
||||
test_pluginstream_geturlnotify.html \
|
||||
test_pluginstream_asfile.html \
|
||||
test_pluginstream_asfileonly.html \
|
||||
test_pluginstream_post.html \
|
||||
test_pluginstream_poststream.html \
|
||||
test_pluginstream_seek.html \
|
||||
test_pluginstream_newstream.html \
|
||||
test_multipleinstanceobjects.html \
|
||||
test_streamNotify.html \
|
||||
test_instantiation.html \
|
||||
test_cookies.html \
|
||||
test_npn_timers.html \
|
||||
test_npn_asynccall.html \
|
||||
$(NULL)
|
||||
|
||||
# test_npruntime_npnsetexception.html \ Disabled for e10s
|
||||
# test_npruntime_npnsetexception.html \ Disabled for e10s
|
||||
|
||||
ifdef MOZ_IPC
|
||||
_MOCHITEST_FILES += \
|
||||
test_crashing.html \
|
||||
test_crashing2.html \
|
||||
crashing_subpage.html \
|
||||
$(NULL)
|
||||
test_crashing.html \
|
||||
test_crashing2.html \
|
||||
crashing_subpage.html \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
_MOCHITEST_FILES += \
|
||||
test_windowed_invalidate.html \
|
||||
$(NULL)
|
||||
test_windowed_invalidate.html \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
_MOCHICHROME_FILES = \
|
||||
test_bug479979.xul \
|
||||
test_npruntime.xul \
|
||||
test_privatemode.xul \
|
||||
test_wmode.xul \
|
||||
$(NULL)
|
||||
test_bug479979.xul \
|
||||
test_npruntime.xul \
|
||||
test_privatemode.xul \
|
||||
test_wmode.xul \
|
||||
$(NULL)
|
||||
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
_MOCHICHROME_FILES += \
|
||||
test_convertpoint.xul \
|
||||
$(NULL)
|
||||
test_convertpoint.xul \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_IPC
|
||||
_MOCHICHROME_FILES += \
|
||||
test_crash_notify.xul \
|
||||
$(NULL)
|
||||
test_crash_notify.xul \
|
||||
test_crash_notify_no_report.xul \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
libs:: $(_MOCHICHROME_FILES)
|
||||
|
127
modules/plugin/test/mochitest/test_crash_notify_no_report.xul
Normal file
127
modules/plugin/test/mochitest/test_crash_notify_no_report.xul
Normal file
@ -0,0 +1,127 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<window title="Basic Plugin Tests"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<title>Plugin Crash Notification Test</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" />
|
||||
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
|
||||
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
|
||||
</body>
|
||||
<script class="testbody" type="application/javascript">
|
||||
<![CDATA[
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var success = false;
|
||||
|
||||
var observerFired = false;
|
||||
|
||||
var testObserver = {
|
||||
observe: function(subject, topic, data) {
|
||||
observerFired = true;
|
||||
ok(true, "Observer fired");
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
is(topic, "plugin-crashed", "Checking correct topic");
|
||||
is(data, null, "Checking null data");
|
||||
ok((subject instanceof Components.interfaces.nsIPropertyBag2), "got Propbag");
|
||||
ok((subject instanceof Components.interfaces.nsIWritablePropertyBag2),
|
||||
"got writable Propbag");
|
||||
|
||||
var id = subject.getPropertyAsAString("minidumpID");
|
||||
isnot(id, "", "got a non-empty crash id");
|
||||
let directoryService =
|
||||
Components.classes["@mozilla.org/file/directory_service;1"].
|
||||
getService(Components.interfaces.nsIProperties);
|
||||
let pendingD = directoryService.get("UAppData",
|
||||
Components.interfaces.nsIFile);
|
||||
pendingD.append("Crash Reports");
|
||||
pendingD.append("pending");
|
||||
let dumpFile = pendingD.clone();
|
||||
dumpFile.append(id + ".dmp");
|
||||
ok(dumpFile.exists(), "minidump exists");
|
||||
let extraFile = pendingD.clone();
|
||||
extraFile.append(id + ".extra");
|
||||
ok(extraFile.exists(), "extra file exists");
|
||||
// cleanup, to be nice
|
||||
dumpFile.remove(false);
|
||||
extraFile.remove(false);
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
if (iid.equals(Components.interfaces.nsIObserver) ||
|
||||
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
|
||||
iid.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function onPluginCrashed(aEvent) {
|
||||
ok(true, "Plugin crashed notification received");
|
||||
ok(observerFired, "Observer should have fired first");
|
||||
is(aEvent.type, "PluginCrashed", "event is correct type");
|
||||
|
||||
var pluginElement = document.getElementById("plugin1");
|
||||
is (pluginElement, aEvent.target, "Plugin crashed event target is plugin element");
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
ok(aEvent instanceof Components.interfaces.nsIDOMDataContainerEvent,
|
||||
"plugin crashed event has the right interface");
|
||||
var pluginName = aEvent.getData("pluginName");
|
||||
is(pluginName, "Test Plug-in");
|
||||
var didReport = aEvent.getData("submittedCrashReport");
|
||||
// The app itself may or may not have decided to submit the report, so
|
||||
// allow either true or false here.
|
||||
ok((didReport == true || didReport == false), "event said crash report was submitted");
|
||||
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"].
|
||||
getService(Components.interfaces.nsIObserverService);
|
||||
os.removeObserver(testObserver, "plugin-crashed");
|
||||
|
||||
// re-set MOZ_CRASHREPORTER_NO_REPORT
|
||||
let env = Components.classes["@mozilla.org/process/environment;1"]
|
||||
.getService(Components.interfaces.nsIEnvironment);
|
||||
env.set("MOZ_CRASHREPORTER_NO_REPORT", "1");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
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 test harness will have set MOZ_CRASHREPORTER_NO_REPORT,
|
||||
// ensure that we can change the setting and have our minidumps
|
||||
// wind up in Crash Reports/pending
|
||||
let env = Components.classes["@mozilla.org/process/environment;1"]
|
||||
.getService(Components.interfaces.nsIEnvironment);
|
||||
env.set("MOZ_CRASHREPORTER_NO_REPORT", "");
|
||||
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"].
|
||||
getService(Components.interfaces.nsIObserverService);
|
||||
os.addObserver(testObserver, "plugin-crashed", true);
|
||||
|
||||
document.addEventListener("PluginCrashed", onPluginCrashed, false);
|
||||
|
||||
var pluginElement = document.getElementById("plugin1");
|
||||
try {
|
||||
pluginElement.crash();
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
||||
|
@ -11,24 +11,9 @@ var id;
|
||||
function collectData() {
|
||||
let directoryService = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
pendingDir = directoryService.get("UAppData", Ci.nsIFile);
|
||||
pendingDir.append("Crash Reports");
|
||||
pendingDir.append("pending");
|
||||
if (!pendingDir.exists())
|
||||
pendingDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0770);
|
||||
|
||||
reportsDir = directoryService.get("UAppData", Ci.nsIFile);
|
||||
reportsDir.append("Crash Reports");
|
||||
reportsDir.append("submitted");
|
||||
if (!reportsDir.exists())
|
||||
reportsDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0770);
|
||||
|
||||
let dumpFile = window.arguments[0].QueryInterface(Ci.nsIFile);
|
||||
let extraFile = dumpFile.clone();
|
||||
id = dumpFile.leafName.replace(/.dmp$/, "");
|
||||
extraFile.leafName = id + ".extra";
|
||||
dumpFile.moveTo(pendingDir, "");
|
||||
extraFile.moveTo(pendingDir, "");
|
||||
}
|
||||
|
||||
function submitDone()
|
||||
|
@ -975,10 +975,6 @@ public:
|
||||
SubmitCrashReport(nsIFile* dumpFile) : mDumpFile(dumpFile) { }
|
||||
|
||||
NS_IMETHOD Run() {
|
||||
char* e = getenv("MOZ_CRASHREPORTER_NO_REPORT");
|
||||
if (e && *e)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> windowWatcher =
|
||||
do_GetService(NS_WINDOWWATCHER_CONTRACTID);
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
@ -1025,6 +1021,25 @@ static PLDHashOperator EnumerateChildAnnotations(const nsACString& key,
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static bool
|
||||
MoveToPending(nsIFile* dumpFile, nsIFile* extraFile)
|
||||
{
|
||||
nsCOMPtr<nsIProperties> dirSvc
|
||||
= do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
|
||||
if (!dirSvc)
|
||||
return false;
|
||||
nsCOMPtr<nsILocalFile> pendingDir;
|
||||
if (NS_FAILED(dirSvc->Get("UAppData",
|
||||
NS_GET_IID(nsILocalFile),
|
||||
getter_AddRefs(pendingDir))) ||
|
||||
NS_FAILED(pendingDir->Append(NS_LITERAL_STRING("Crash Reports"))) ||
|
||||
NS_FAILED(pendingDir->Append(NS_LITERAL_STRING("pending"))))
|
||||
return false;
|
||||
|
||||
return NS_FAILED(dumpFile->MoveTo(pendingDir, EmptyString())) ||
|
||||
NS_FAILED(extraFile->MoveTo(pendingDir, EmptyString()));
|
||||
}
|
||||
|
||||
static void
|
||||
OnChildProcessDumpRequested(void* aContext,
|
||||
const ClientInfo* aClientInfo,
|
||||
@ -1084,13 +1099,23 @@ OnChildProcessDumpRequested(void* aContext,
|
||||
stream->Write("\n", 1, &written);
|
||||
stream->Close();
|
||||
|
||||
bool doReport = true;
|
||||
char* e = getenv("MOZ_CRASHREPORTER_NO_REPORT");
|
||||
if (e && *e)
|
||||
doReport = false;
|
||||
|
||||
if (doReport)
|
||||
MoveToPending(lf, extraFile);
|
||||
|
||||
{
|
||||
MutexAutoLock lock(*dumpMapLock);
|
||||
pidToMinidump->Put(pid, lf);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> r = new SubmitCrashReport(lf);
|
||||
NS_DispatchToMainThread(r);
|
||||
if (doReport) {
|
||||
nsCOMPtr<nsIRunnable> r = new SubmitCrashReport(lf);
|
||||
NS_DispatchToMainThread(r);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
|
Loading…
Reference in New Issue
Block a user