tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_cache2-28a-OPEN_SECRETLY.js (1021B)


      1 "use strict";
      2 
      3 function run_test() {
      4  do_get_profile();
      5  function NowSeconds() {
      6    return parseInt(new Date().getTime() / 1000);
      7  }
      8  function do_check_time(a, b) {
      9    Assert.less(Math.abs(a - b), 0.5);
     10  }
     11 
     12  asyncOpenCacheEntry(
     13    "http://t/",
     14    "disk",
     15    Ci.nsICacheStorage.OPEN_NORMALLY,
     16    null,
     17    new OpenCallback(NEW, "m", "d", function (entry) {
     18      var now1 = NowSeconds();
     19      Assert.equal(entry.fetchCount, 1);
     20      do_check_time(entry.lastFetched, now1);
     21      do_check_time(entry.lastModified, now1);
     22 
     23      do_timeout(2000, () => {
     24        asyncOpenCacheEntry(
     25          "http://t/",
     26          "disk",
     27          Ci.nsICacheStorage.OPEN_SECRETLY,
     28          null,
     29          new OpenCallback(NORMAL, "m", "d", function (entry1) {
     30            Assert.equal(entry1.fetchCount, 1);
     31            do_check_time(entry1.lastFetched, now1);
     32            do_check_time(entry1.lastModified, now1);
     33 
     34            finish_cache2_test();
     35          })
     36        );
     37      });
     38    })
     39  );
     40 
     41  do_test_pending();
     42 }