Bug 1007534 - Part 6: xpcshell test for memory data in crash reporter. r=ted

This commit is contained in:
David Major 2014-08-30 17:22:14 +12:00
Родитель 8cb88f5b6b
Коммит 73981dd834
3 изменённых файлов: 60 добавлений и 2 удалений

Просмотреть файл

@ -108,12 +108,17 @@ function handleMinidump(callback)
let extrafile = minidump.clone();
extrafile.leafName = extrafile.leafName.slice(0, -4) + ".extra";
let memoryfile = minidump.clone();
memoryfile.leafName = memoryfile.leafName.slice(0, -4) + ".memory.json.gz";
// Just in case, don't let these files linger.
do_register_cleanup(function() {
if (minidump.exists())
minidump.remove(false);
if (extrafile.exists())
extrafile.remove(false);
if (memoryfile.exists())
memoryfile.remove(false);
});
do_check_true(extrafile.exists());
let extra = parseKeyValuePairsFromFile(extrafile);
@ -125,6 +130,8 @@ function handleMinidump(callback)
minidump.remove(false);
if (extrafile.exists())
extrafile.remove(false);
if (memoryfile.exists())
memoryfile.remove(false);
}
function do_content_crash(setup, callback)

Просмотреть файл

@ -0,0 +1,52 @@
function run_test()
{
if (!("@mozilla.org/toolkit/crash-reporter;1" in Components.classes)) {
dump("INFO | test_crash_oom.js | Can't test crashreporter in a non-libxul build.\n");
return;
}
// This was shamelessly copied and stripped down from do_get_profile() in
// head.js so that nsICrashReporter::saveMemoryReport can use a profile
// within the crasher subprocess.
do_crash(
function() {
let Cc = Components.classes;
let Ci = Components.interfaces;
let env = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment);
let profd = env.get("XPCSHELL_TEST_PROFILE_DIR");
let file = Cc["@mozilla.org/file/local;1"]
.createInstance(Ci.nsILocalFile);
file.initWithPath(profd);
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties);
let provider = {
getFile: function(prop, persistent) {
persistent.value = true;
if (prop == "ProfD" || prop == "ProfLD" || prop == "ProfDS" ||
prop == "ProfLDS" || prop == "TmpD") {
return file.clone();
}
throw Components.results.NS_ERROR_FAILURE;
},
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIDirectoryServiceProvider) ||
iid.equals(Ci.nsISupports)) {
return this;
}
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
dirSvc.QueryInterface(Ci.nsIDirectoryService)
.registerProvider(provider);
crashReporter.saveMemoryReport();
},
function(mdump, extra) {
do_check_eq(extra.ContainsMemoryReport, "1");
},
true);
}

Просмотреть файл

@ -14,11 +14,10 @@ support-files =
[test_crash_after_js_large_allocation_failure.js]
[test_crash_after_js_large_allocation_failure_reporting.js]
[test_crash_oom.js]
skip-if = os == 'win' && debug
[test_crash_abort.js]
skip-if = os == 'win'
[test_crash_with_memory_report.js]
[test_crashreporter.js]
[test_crashreporter_crash.js]
[test_crashreporter_crash_profile_lock.js]