tor-browser

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

status.any.js (1477B)


      1 // META: global=window,worker
      2 // META: title=HTTP Cache - Status Codes
      3 // META: timeout=long
      4 // META: script=/common/utils.js
      5 // META: script=/common/get-host-info.sub.js
      6 // META: script=http-cache.js
      7 
      8 var tests = [];
      9 function check_status(status) {
     10  var code = status[0];
     11  var phrase = status[1];
     12  var body = status[2];
     13  if (body === undefined) {
     14    body = http_content(code);
     15  }
     16  tests.push({
     17    name: "HTTP cache goes to the network if it has a stale " + code + " response",
     18    requests: [
     19      {
     20        template: "stale",
     21        response_status: [code, phrase],
     22        response_body: body
     23      }, {
     24        expected_type: "not_cached",
     25        response_status: [code, phrase],
     26        response_body: body
     27      }
     28    ]
     29  })
     30  tests.push({
     31    name: "HTTP cache avoids going to the network if it has a fresh " + code + " response",
     32    requests: [
     33      {
     34        template: "fresh",
     35        response_status: [code, phrase],
     36        response_body: body
     37      }, {
     38        expected_type: "cached",
     39        response_status: [code, phrase],
     40        response_body: body
     41      }
     42    ]
     43  })
     44 }
     45 [
     46  [200, "OK"],
     47  [203, "Non-Authoritative Information"],
     48  [204, "No Content", null],
     49  [299, "Whatever"],
     50  [400, "Bad Request"],
     51  [404, "Not Found"],
     52  [410, "Gone"],
     53  [499, "Whatever"],
     54  [500, "Internal Server Error"],
     55  [502, "Bad Gateway"],
     56  [503, "Service Unavailable"],
     57  [504, "Gateway Timeout"],
     58  [599, "Whatever"]
     59 ].forEach(check_status);
     60 run_tests(tests);