Bug 1399796 - UnsubmittedCrashHandler should never check for unsubmitted crash reports if disabled or suppressed. r=Felipe

Bug 1355492 moved the logic for scanning for unsubmitted crash reports out of the initialization
of UnsubmittedCrashHandler, and the initialization is what decided whether or not it was
appropriate to scan in the first place. This was done so that scanning could be deferred
until idle after first paint.

This patch makes it so that the scanning logic first ensures that the UnsubmittedCrashHandler
is actually enabled and not suppressed (which is calculated earlier).

I've also taken the liberty of adding a regression test.

MozReview-Commit-ID: 3Aihom5Q17R

--HG--
extra : rebase_source : 0430dc2464acfd7b648ba9d4658ab3fb01606570
extra : source : 593ef0951840f01384def383c2690cc90767a118
This commit is contained in:
Mike Conley 2017-09-15 09:25:04 -07:00
Родитель ecdacdf4a0
Коммит 2e651bf46f
2 изменённых файлов: 23 добавлений и 0 удалений

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

@ -660,6 +660,10 @@ this.UnsubmittedCrashHandler = {
* If a notification cannot be shown, will resolve with null.
*/
async checkForUnsubmittedCrashReports() {
if (!this.enabled || this.suppressed) {
return null;
}
let dateLimit = new Date();
dateLimit.setDate(dateLimit.getDate() - PENDING_CRASH_REPORT_DAYS);

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

@ -206,6 +206,25 @@ add_task(async function setup() {
// disabled is an intentional choice, as this allows for easier
// simulation of startup and shutdown.
UnsubmittedCrashHandler.uninit();
// While we're here, let's test that we don't show the notification
// if we're disabled and something happens to check for unsubmitted
// crash reports.
await SpecialPowers.pushPrefEnv({
set: [
["browser.crashReports.unsubmittedCheck.enabled", false],
],
});
await createPendingCrashReports(1);
notification =
await UnsubmittedCrashHandler.checkForUnsubmittedCrashReports();
Assert.ok(!notification, "There should not be a notification");
clearPendingCrashReports();
await SpecialPowers.popPrefEnv();
await SpecialPowers.pushPrefEnv({
set: [
["browser.crashReports.unsubmittedCheck.enabled", true],