toolkit/crashreporter/test/unit/test_crashreporter_crash.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial