tor-browser

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

test_cache2-14b-concurent-readers-complete.js (1509B)


      1 "use strict";
      2 
      3 function run_test() {
      4  do_get_profile();
      5 
      6  asyncOpenCacheEntry(
      7    "http://x/",
      8    "disk",
      9    Ci.nsICacheStorage.OPEN_NORMALLY,
     10    null,
     11    new OpenCallback(NEW, "x1m", "x1d", function () {
     12      // nothing to do here, we expect concurent callbacks to get
     13      // all notified, then the test finishes
     14    })
     15  );
     16 
     17  var mc = new MultipleCallbacks(3, finish_cache2_test);
     18 
     19  var order = 0;
     20 
     21  asyncOpenCacheEntry(
     22    "http://x/",
     23    "disk",
     24    Ci.nsICacheStorage.OPEN_NORMALLY,
     25    null,
     26    new OpenCallback(
     27      NORMAL | COMPLETE | NOTIFYBEFOREREAD,
     28      "x1m",
     29      "x1d",
     30      function (entry, beforeReading) {
     31        if (beforeReading) {
     32          ++order;
     33          Assert.equal(order, 3);
     34        } else {
     35          mc.fired();
     36        }
     37      }
     38    )
     39  );
     40  asyncOpenCacheEntry(
     41    "http://x/",
     42    "disk",
     43    Ci.nsICacheStorage.OPEN_NORMALLY,
     44    null,
     45    new OpenCallback(NORMAL | NOTIFYBEFOREREAD, "x1m", "x1d", function (
     46      entry,
     47      beforeReading
     48    ) {
     49      if (beforeReading) {
     50        ++order;
     51        Assert.equal(order, 1);
     52      } else {
     53        mc.fired();
     54      }
     55    })
     56  );
     57  asyncOpenCacheEntry(
     58    "http://x/",
     59    "disk",
     60    Ci.nsICacheStorage.OPEN_NORMALLY,
     61    null,
     62    new OpenCallback(NORMAL | NOTIFYBEFOREREAD, "x1m", "x1d", function (
     63      entry,
     64      beforeReading
     65    ) {
     66      if (beforeReading) {
     67        ++order;
     68        Assert.equal(order, 2);
     69      } else {
     70        mc.fired();
     71      }
     72    })
     73  );
     74 
     75  do_test_pending();
     76 }