2009-09-10 04:49:42 -07:00
|
|
|
function run_test()
|
|
|
|
{
|
|
|
|
if (!("@mozilla.org/toolkit/crash-reporter;1" in Components.classes)) {
|
|
|
|
dump("INFO | test_crashreporter.js | Can't test crashreporter in a non-libxul build.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-12 11:14:15 -08:00
|
|
|
var is_win7_or_newer = false;
|
|
|
|
var ph = Components.classes["@mozilla.org/network/protocol;1?name=http"]
|
|
|
|
.getService(Components.interfaces.nsIHttpProtocolHandler);
|
|
|
|
var match = ph.userAgent.match(/Windows NT (\d+).(\d+)/);
|
|
|
|
if (match && (parseInt(match[1]) > 6 ||
|
|
|
|
parseInt(match[1]) == 6 && parseInt(match[2]) >= 1)) {
|
|
|
|
is_win7_or_newer = true;
|
|
|
|
}
|
|
|
|
|
2009-09-10 04:49:42 -07:00
|
|
|
// try a basic crash
|
|
|
|
do_crash(null, function(mdump, extra) {
|
|
|
|
do_check_true(mdump.exists());
|
|
|
|
do_check_true(mdump.fileSize > 0);
|
|
|
|
do_check_true('StartupTime' in extra);
|
|
|
|
do_check_true('CrashTime' in extra);
|
2011-01-12 11:14:15 -08:00
|
|
|
do_check_true(CrashTestUtils.dumpHasStream(mdump.path, CrashTestUtils.MD_THREAD_LIST_STREAM));
|
2011-01-28 08:57:08 -08:00
|
|
|
do_check_true(CrashTestUtils.dumpHasInstructionPointerMemory(mdump.path));
|
2011-01-12 11:14:15 -08:00
|
|
|
if (is_win7_or_newer)
|
|
|
|
do_check_true(CrashTestUtils.dumpHasStream(mdump.path, CrashTestUtils.MD_MEMORY_INFO_LIST_STREAM));
|
2009-09-10 04:49:42 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
// check setting some basic data
|
|
|
|
do_crash(function() {
|
|
|
|
crashReporter.annotateCrashReport("TestKey", "TestValue");
|
|
|
|
crashReporter.appendAppNotesToCrashReport("Junk");
|
|
|
|
crashReporter.appendAppNotesToCrashReport("MoreJunk");
|
|
|
|
},
|
|
|
|
function(mdump, extra) {
|
|
|
|
do_check_eq(extra.TestKey, "TestValue");
|
|
|
|
do_check_eq(extra.Notes, "JunkMoreJunk");
|
|
|
|
});
|
|
|
|
}
|