зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1313794: Remove Date.prototype.toLocaleFormat uses in browser/modules. r=Felipe
--HG-- extra : rebase_source : 7e3469cb7f43c6bdcb9cc4dd24d4fdac78309fd6
This commit is contained in:
Родитель
07274b231c
Коммит
76734fefb3
|
@ -746,7 +746,10 @@ this.UnsubmittedCrashHandler = {
|
|||
* @returns String
|
||||
*/
|
||||
dateString(someDate = new Date()) {
|
||||
return someDate.toLocaleFormat("%Y%m%d");
|
||||
let year = String(someDate.getFullYear()).padStart(4, "0");
|
||||
let month = String(someDate.getMonth() + 1).padStart(2, "0");
|
||||
let day = String(someDate.getDate()).padStart(2, "0");
|
||||
return year + month + day;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -446,7 +446,7 @@ add_task(function* test_last_shown_date() {
|
|||
yield UnsubmittedCrashHandler.checkForUnsubmittedCrashReports();
|
||||
Assert.ok(notification, "There should be a notification");
|
||||
|
||||
let today = new Date().toLocaleFormat("%Y%m%d");
|
||||
let today = UnsubmittedCrashHandler.dateString(new Date());
|
||||
let lastShownDate =
|
||||
UnsubmittedCrashHandler.prefs.getCharPref("lastShownDate");
|
||||
Assert.equal(today, lastShownDate,
|
||||
|
@ -541,7 +541,7 @@ add_task(function* test_dont_decrement_chances_on_same_day() {
|
|||
"We should have noticed that we uninitted while showing " +
|
||||
"the notification.");
|
||||
|
||||
let today = new Date().toLocaleFormat("%Y%m%d");
|
||||
let today = UnsubmittedCrashHandler.dateString(new Date());
|
||||
let lastShownDate =
|
||||
UnsubmittedCrashHandler.prefs.getCharPref("lastShownDate");
|
||||
Assert.equal(today, lastShownDate,
|
||||
|
@ -590,7 +590,7 @@ add_task(function* test_decrement_chances_on_other_day() {
|
|||
"the notification.");
|
||||
|
||||
// Now pretend that the notification was shown yesterday.
|
||||
let yesterday = new Date(Date.now() - DAY).toLocaleFormat("%Y%m%d");
|
||||
let yesterday = UnsubmittedCrashHandler.dateString(new Date(Date.now() - DAY));
|
||||
UnsubmittedCrashHandler.prefs.setCharPref("lastShownDate", yesterday);
|
||||
|
||||
UnsubmittedCrashHandler.init();
|
||||
|
@ -618,7 +618,7 @@ add_task(function* test_decrement_chances_on_other_day() {
|
|||
*/
|
||||
add_task(function* test_can_suppress_after_chances() {
|
||||
// Pretend that a notification was shown yesterday.
|
||||
let yesterday = new Date(Date.now() - DAY).toLocaleFormat("%Y%m%d");
|
||||
let yesterday = UnsubmittedCrashHandler.dateString(new Date(Date.now() - DAY));
|
||||
UnsubmittedCrashHandler.prefs.setCharPref("lastShownDate", yesterday);
|
||||
UnsubmittedCrashHandler.prefs.setBoolPref("shutdownWhileShowing", true);
|
||||
UnsubmittedCrashHandler.prefs.setIntPref("chancesUntilSuppress", 0);
|
||||
|
@ -633,7 +633,7 @@ add_task(function* test_can_suppress_after_chances() {
|
|||
let suppressUntilDate =
|
||||
UnsubmittedCrashHandler.prefs.getCharPref("suppressUntilDate");
|
||||
|
||||
let today = new Date().toLocaleFormat("%Y%m%d");
|
||||
let today = UnsubmittedCrashHandler.dateString(new Date());
|
||||
Assert.ok(suppressUntilDate > today,
|
||||
"We should be suppressing until some days into the future.");
|
||||
|
||||
|
@ -648,7 +648,7 @@ add_task(function* test_can_suppress_after_chances() {
|
|||
* will be shown even if there are pending crash reports.
|
||||
*/
|
||||
add_task(function* test_suppression() {
|
||||
let future = new Date(Date.now() + (DAY * 5)).toLocaleFormat("%Y%m%d");
|
||||
let future = UnsubmittedCrashHandler.dateString(new Date(Date.now() + (DAY * 5)));
|
||||
UnsubmittedCrashHandler.prefs.setCharPref("suppressUntilDate", future);
|
||||
UnsubmittedCrashHandler.uninit();
|
||||
UnsubmittedCrashHandler.init();
|
||||
|
@ -666,7 +666,7 @@ add_task(function* test_suppression() {
|
|||
* it, then we can show the notification again.
|
||||
*/
|
||||
add_task(function* test_end_suppression() {
|
||||
let yesterday = new Date(Date.now() - DAY).toLocaleFormat("%Y%m%d");
|
||||
let yesterday = UnsubmittedCrashHandler.dateString(new Date(Date.now() - DAY));
|
||||
UnsubmittedCrashHandler.prefs.setCharPref("suppressUntilDate", yesterday);
|
||||
UnsubmittedCrashHandler.uninit();
|
||||
UnsubmittedCrashHandler.init();
|
||||
|
|
Загрузка…
Ссылка в новой задаче