DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
<!-- Any copyright is dedicated to the Public Domain.
   - http://creativecommons.org/publicdomain/zero/1.0/ -->
<!DOCTYPE HTML>
<html>
<head>
  <title>Test Cache with QuotaManager Restart</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script class="testbody" type="text/javascript">
function setupTestIframe() {
  return new Promise(function(resolve) {
    var iframe = document.createElement("iframe");
    iframe.src = "empty.html";
    iframe.onload = function() {
      window.caches = iframe.contentWindow.caches;
      resolve();
    };
    document.body.appendChild(iframe);
  });
}

function resetStorage() {
  return new Promise(function(resolve, reject) {
    var qms = SpecialPowers.Services.qms;
    var request = qms.reset();
    var cb = SpecialPowers.wrapCallback(resolve);
    request.callback = cb;
  });
}

SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
  "set": [["dom.caches.enabled", true],
          ["dom.caches.testing.enabled", true],
          ["dom.quotaManager.testing", true]],
}, function() {
  var name = "foo";
  var url = "./test_cache_add.js";
  var cache;
  setupTestIframe().then(function() {
    return caches.open(name);
  }).then(function(c) {
    cache = c;
    return cache.add(url);
  }).then(function() {
    return resetStorage();
  }).then(function() {
    return cache.match(url).then(function(resp) {
      ok(false, "old cache reference should not work after reset");
    }).catch(function(err) {
      ok(true, "old cache reference should not work after reset");
    });
  }).then(function() {
    return caches.open(name);
  }).then(function(c) {
    cache = c;
    return cache.match(url);
  }).then(function(resp) {
    ok(!!resp, "cache should work after QM reset");
    return caches.delete(name);
  }).then(function(success) {
    ok(success, "cache should be deleted");
    SimpleTest.finish();
  });
});
</script>
</body>
</html>