Bug 648068 - In Blocklist, Remove the OOB value "reset" from days since last request; r=dtownsend
authorDaniel Einspanjer <deinspanjer@mozilla.com>
Thu, 07 Apr 2011 10:41:00 -0700
changeset 67640 64a7a10fd5c0e612a7b2602576b4f8853cc50135
parent 67639 c2242c63e75f99e720b88fe2a9a2f50523f14bfe
child 67641 d5905c6cfafa79d20ac19328bdadbf35a50d2c87
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdtownsend
bugs648068
milestone2.2a1pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 648068 - In Blocklist, Remove the OOB value "reset" from days since last request; r=dtownsend
toolkit/mozapps/extensions/nsBlocklistService.js
toolkit/mozapps/extensions/test/xpcshell/test_bug620837.js
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/nsBlocklistService.js
@@ -428,22 +428,18 @@ Blocklist.prototype = {
       LOG("Blocklist::notify: The " + PREF_BLOCKLIST_URL + " preference" +
           " is missing!");
       return;
     }
 
     var pingCountVersion = getPref("getIntPref", PREF_BLOCKLIST_PINGCOUNTVERSION, 0);
     var pingCountTotal = getPref("getIntPref", PREF_BLOCKLIST_PINGCOUNTTOTAL, 1);
     var daysSinceLastPing = 0;
-    if (pingCountVersion < 1 || pingCountTotal < 1) {
-      daysSinceLastPing = pingCountVersion == 0 ? "new" : "reset";
-      if (pingCountVersion < 1)
-        pingCountVersion = 1;
-      if (pingCountTotal < 1)
-        pingCountTotal = 1;
+    if (pingCountVersion == 0) {
+      daysSinceLastPing = "new";
     }
     else {
       // Seconds in one day is used because nsIUpdateTimerManager stores the
       // last update time in seconds.
       let secondsInDay = 60 * 60 * 24;
       let lastUpdateTime = getPref("getIntPref", PREF_BLOCKLIST_LASTUPDATETIME, 0);
       if (lastUpdateTime == 0) {
         daysSinceLastPing = "invalid";
@@ -453,16 +449,21 @@ Blocklist.prototype = {
         daysSinceLastPing = Math.floor((now - lastUpdateTime) / secondsInDay);
       }
 
       if (daysSinceLastPing == 0 || daysSinceLastPing == "invalid") {
         pingCountVersion = pingCountTotal = "invalid";
       }
     }
 
+    if (pingCountVersion < 1)
+      pingCountVersion = 1;
+    if (pingCountTotal < 1)
+      pingCountTotal = 1;
+
     dsURI = dsURI.replace(/%APP_ID%/g, gApp.ID);
     dsURI = dsURI.replace(/%APP_VERSION%/g, gApp.version);
     dsURI = dsURI.replace(/%PRODUCT%/g, gApp.name);
     dsURI = dsURI.replace(/%VERSION%/g, gApp.version);
     dsURI = dsURI.replace(/%BUILD_ID%/g, gApp.appBuildID);
     dsURI = dsURI.replace(/%BUILD_TARGET%/g, gApp.OS + "_" + gABI);
     dsURI = dsURI.replace(/%OS_VERSION%/g, gOSVersion);
     dsURI = dsURI.replace(/%LOCALE%/g, getLocale());
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug620837.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug620837.js
@@ -63,17 +63,17 @@ function test3() {
   notify_blocklist();
 }
 
 function test4() {
   Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION, -1);
   Services.prefs.setIntPref(PREF_BLOCKLIST_LASTUPDATETIME,
                             (getNowInSeconds() - (SECONDS_IN_DAY * 2)));
   gNextTest = test5;
-  gExpectedQueryString = "1&3&reset";
+  gExpectedQueryString = "1&3&2";
   notify_blocklist();
 }
 
 function test5() {
   Services.prefs.setIntPref(PREF_BLOCKLIST_LASTUPDATETIME, getNowInSeconds());
   gNextTest = test6;
   gExpectedQueryString = "invalid&invalid&0";
   notify_blocklist();
@@ -95,32 +95,49 @@ function test7() {
   gExpectedQueryString = "2147483647&5&4";
   notify_blocklist();
 }
 
 function test8() {
   Services.prefs.setIntPref(PREF_BLOCKLIST_LASTUPDATETIME,
                             (getNowInSeconds() - (SECONDS_IN_DAY * 5)));
   gNextTest = test9;
-  gExpectedQueryString = "1&6&reset";
+  gExpectedQueryString = "1&6&5";
   notify_blocklist();
 }
 
 function test9() {
   Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTTOTAL, 2147483647);
   Services.prefs.setIntPref(PREF_BLOCKLIST_LASTUPDATETIME,
                             (getNowInSeconds() - (SECONDS_IN_DAY * 6)));
   gNextTest = test10;
   gExpectedQueryString = "2&2147483647&6";
   notify_blocklist();
 }
 
 function test10() {
   Services.prefs.setIntPref(PREF_BLOCKLIST_LASTUPDATETIME,
                             (getNowInSeconds() - (SECONDS_IN_DAY * 7)));
+  gNextTest = test11;
+  gExpectedQueryString = "3&1&7";
+  notify_blocklist();
+}
+
+function test11() {
+  Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION, -1);
+  Services.prefs.setIntPref(PREF_BLOCKLIST_LASTUPDATETIME,
+                            (getNowInSeconds() - (SECONDS_IN_DAY * 8)));
+  gNextTest = test12;
+  gExpectedQueryString = "1&2&8";
+  notify_blocklist();
+}
+
+function test12() {
+  Services.prefs.setIntPref(PREF_BLOCKLIST_LASTUPDATETIME,
+                            (getNowInSeconds() - (SECONDS_IN_DAY * 9)));
   gNextTest = finish;
-  gExpectedQueryString = "3&1&reset";
+  gExpectedQueryString = "2&3&9";
   notify_blocklist();
 }
 
 function finish() {
   gTestserver.stop(do_test_finished);
 }