Backed out changeset 483b831b7822
authorDan Witte <dwitte@gmail.com>
Mon, 16 Mar 2009 01:33:31 -0700
changeset 26213 1d114a5c22d9a606bfb728e6df05f5448b0a0d93
parent 26212 483b831b7822cf858e4b7cc9aa90afde5a4c49c0
child 26215 2fbc3d17e654bf3b0feb5b4992379d3006cc450f
push id5953
push userdwitte@stanford.edu
push dateMon, 16 Mar 2009 08:34:28 +0000
treeherdermozilla-central@2fbc3d17e654 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.2a1pre
backs out483b831b7822cf858e4b7cc9aa90afde5a4c49c0
Backed out changeset 483b831b7822
extensions/cookie/test/test_eviction.html
deleted file mode 100644
--- a/extensions/cookie/test/test_eviction.html
+++ /dev/null
@@ -1,106 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for cookie eviction</title>
-  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body onload="setupTest()">
-<p id="display"></p>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-  function setupTest() {
-    SimpleTest.waitForExplicitFinish();
-
-    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
-    // twiddle prefs to convenient values for this test
-    var prefs = Components.classes["@mozilla.org/preferences-service;1"]
-                          .getService(Components.interfaces.nsIPrefBranch);
-    prefs.setIntPref("network.cookie.purgeAge", 2);
-    prefs.setIntPref("network.cookie.maxNumber", 1000);
-
-    var cm = Components.classes["@mozilla.org/cookiemanager;1"]
-                       .getService(Components.interfaces.nsICookieManager2);
-
-    // eviction is performed based on two limits: when the total number of cookies
-    // exceeds maxNumber + 10% (1100), and when cookies are older than purgeAge
-    // (1 second). purging is done when both conditions are satisfied, and only
-    // those cookies are purged.
-
-    // we test the following cases of eviction:
-    // 1) excess and age are satisfied, but only some of the excess are old enough
-    // to be purged.
-    is(testEviction(cm, 1101, 5, 50, 1051), 1051, "incorrect number of cookies");
-
-    // 2) excess and age are satisfied, and all of the excess are old enough
-    // to be purged.
-    is(testEviction(cm, 1101, 5, 100, 1001), 1001, "incorrect number of cookies");
-
-    // 3) excess and age are satisfied, and more than the excess are old enough
-    // to be purged.
-    is(testEviction(cm, 1101, 5, 500, 1001), 1001, "incorrect number of cookies");
-
-    // 4) excess but not age are satisfied.
-    is(testEviction(cm, 2000, 0, 0, 2000), 2000, "incorrect number of cookies");
-
-    // 5) age but not excess are satisfied.
-    is(testEviction(cm, 1100, 5, 200, 1100), 1100, "incorrect number of cookies");
-
-    cm.removeAll();
-
-    // reset prefs to defaults
-    prefs.setIntPref("network.cookie.purgeAge", 30 * 24 * 60 * 60);
-    prefs.setIntPref("network.cookie.maxNumber", 2000);
-
-    SimpleTest.finish();
-  }
-
-  // test that cookies are evicted by order of lastAccessed time, if both the limit
-  // on total cookies (maxNumber + 10%) and the purge age are exceeded
-  function
-  testEviction(aCM, aNumberTotal, aSleepDuration, aNumberAfter, aNumberToExpect)
-  {
-      const Ci = Components.interfaces;
-
-      aCM.removeAll();
-
-      var i;
-      for (i = 0; i < aNumberTotal; ++i) {
-        var host = "eviction." + i + ".tests";
-        aCM.add(host, "", "test", "eviction", false, false, false, Math.pow(2, 62));
-
-        if ((i == aNumberAfter - 1) && aSleepDuration) {
-          // sleep a while, to make sure the first batch of cookies is older than
-          // the second (timer resolution varies on different platforms).
-          sleep(aSleepDuration * 1000);
-        }
-      }
-
-      var enumerator = aCM.enumerator;
-
-      i = 0;
-      while (enumerator.hasMoreElements()) {
-        var cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
-        ++i;
-
-        if (aNumberTotal != aNumberToExpect) {
-          var hostNumber = new Number(cookie.rawHost.split(".")[1]);
-          if (hostNumber < (aNumberTotal - aNumberToExpect)) break;
-        }
-      }
-
-      return i;
-  }
-
-  // delay for a number of milliseconds
-  function sleep(delay)
-  {
-      var start = new Date().getTime();
-      while (new Date().getTime() < start + delay);
-  }
-</script>
-</pre>
-</body>
-</html>