Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 function run_test()
2 {
3 if (!("@mozilla.org/toolkit/crash-reporter;1" in Components.classes)) {
4 dump("INFO | test_crashreporter.js | Can't test crashreporter in a non-libxul build.\n");
5 return;
6 }
8 var is_win7_or_newer = false;
9 var is_windows = false;
10 var ph = Components.classes["@mozilla.org/network/protocol;1?name=http"]
11 .getService(Components.interfaces.nsIHttpProtocolHandler);
12 var match = ph.userAgent.match(/Windows NT (\d+).(\d+)/);
13 if (match) {
14 is_windows = true;
15 }
16 if (match && (parseInt(match[1]) > 6 ||
17 parseInt(match[1]) == 6 && parseInt(match[2]) >= 1)) {
18 is_win7_or_newer = true;
19 }
21 // try a basic crash
22 do_crash(null, function(mdump, extra) {
23 do_check_true(mdump.exists());
24 do_check_true(mdump.fileSize > 0);
25 do_check_true('StartupTime' in extra);
26 do_check_true('CrashTime' in extra);
27 do_check_true(CrashTestUtils.dumpHasStream(mdump.path, CrashTestUtils.MD_THREAD_LIST_STREAM));
28 do_check_true(CrashTestUtils.dumpHasInstructionPointerMemory(mdump.path));
29 if (is_windows) {
30 ['SystemMemoryUsePercentage', 'TotalVirtualMemory', 'AvailableVirtualMemory',
31 'AvailablePageFile', 'AvailablePhysicalMemory'].forEach(function(prop) {
32 do_check_true(/^\d+$/.test(extra[prop].toString()));
33 });
34 }
35 if (is_win7_or_newer)
36 do_check_true(CrashTestUtils.dumpHasStream(mdump.path, CrashTestUtils.MD_MEMORY_INFO_LIST_STREAM));
37 });
39 // check setting some basic data
40 do_crash(function() {
41 crashReporter.annotateCrashReport("TestKey", "TestValue");
42 crashReporter.appendAppNotesToCrashReport("Junk");
43 crashReporter.appendAppNotesToCrashReport("MoreJunk");
44 },
45 function(mdump, extra) {
46 do_check_eq(extra.TestKey, "TestValue");
47 do_check_eq(extra.Notes, "JunkMoreJunk");
48 });
49 }