tor-browser

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

request-cache-default-conditional.any.js (7374B)


      1 // META: global=window,worker
      2 // META: title=Request cache - default with conditional requests
      3 // META: timeout=long
      4 // META: script=/common/utils.js
      5 // META: script=/common/get-host-info.sub.js
      6 // META: script=request-cache.js
      7 
      8 var tests = [
      9  {
     10    name: 'RequestCache "default" mode with an If-Modified-Since header (following a request without additional headers) is treated similarly to "no-store"',
     11    state: "stale",
     12    request_cache: ["default", "default"],
     13    request_headers: [{}, {"If-Modified-Since": now.toGMTString()}],
     14    expected_validation_headers: [false, false],
     15    expected_no_cache_headers: [false, true],
     16  },
     17  {
     18    name: 'RequestCache "default" mode with an If-Modified-Since header (following a request without additional headers) is treated similarly to "no-store"',
     19    state: "fresh",
     20    request_cache: ["default", "default"],
     21    request_headers: [{}, {"If-Modified-Since": now.toGMTString()}],
     22    expected_validation_headers: [false, false],
     23    expected_no_cache_headers: [false, true],
     24  },
     25  {
     26    name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
     27    state: "stale",
     28    request_cache: ["default", "default"],
     29    request_headers: [{"If-Modified-Since": now.toGMTString()}, {}],
     30    expected_validation_headers: [false, false],
     31    expected_no_cache_headers: [true, false],
     32  },
     33  {
     34    name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
     35    state: "fresh",
     36    request_cache: ["default", "default"],
     37    request_headers: [{"If-Modified-Since": now.toGMTString()}, {}],
     38    expected_validation_headers: [false, false],
     39    expected_no_cache_headers: [true, false],
     40  },
     41  {
     42    name: 'RequestCache "default" mode with an If-None-Match header (following a request without additional headers) is treated similarly to "no-store"',
     43    state: "stale",
     44    request_cache: ["default", "default"],
     45    request_headers: [{}, {"If-None-Match": '"foo"'}],
     46    expected_validation_headers: [false, false],
     47    expected_no_cache_headers: [false, true],
     48  },
     49  {
     50    name: 'RequestCache "default" mode with an If-None-Match header (following a request without additional headers) is treated similarly to "no-store"',
     51    state: "fresh",
     52    request_cache: ["default", "default"],
     53    request_headers: [{}, {"If-None-Match": '"foo"'}],
     54    expected_validation_headers: [false, false],
     55    expected_no_cache_headers: [false, true],
     56  },
     57  {
     58    name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
     59    state: "stale",
     60    request_cache: ["default", "default"],
     61    request_headers: [{"If-None-Match": '"foo"'}, {}],
     62    expected_validation_headers: [false, false],
     63    expected_no_cache_headers: [true, false],
     64  },
     65  {
     66    name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
     67    state: "fresh",
     68    request_cache: ["default", "default"],
     69    request_headers: [{"If-None-Match": '"foo"'}, {}],
     70    expected_validation_headers: [false, false],
     71    expected_no_cache_headers: [true, false],
     72  },
     73  {
     74    name: 'RequestCache "default" mode with an If-Unmodified-Since header (following a request without additional headers) is treated similarly to "no-store"',
     75    state: "stale",
     76    request_cache: ["default", "default"],
     77    request_headers: [{}, {"If-Unmodified-Since": now.toGMTString()}],
     78    expected_validation_headers: [false, false],
     79    expected_no_cache_headers: [false, true],
     80  },
     81  {
     82    name: 'RequestCache "default" mode with an If-Unmodified-Since header (following a request without additional headers) is treated similarly to "no-store"',
     83    state: "fresh",
     84    request_cache: ["default", "default"],
     85    request_headers: [{}, {"If-Unmodified-Since": now.toGMTString()}],
     86    expected_validation_headers: [false, false],
     87    expected_no_cache_headers: [false, true],
     88  },
     89  {
     90    name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
     91    state: "stale",
     92    request_cache: ["default", "default"],
     93    request_headers: [{"If-Unmodified-Since": now.toGMTString()}, {}],
     94    expected_validation_headers: [false, false],
     95    expected_no_cache_headers: [true, false],
     96  },
     97  {
     98    name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
     99    state: "fresh",
    100    request_cache: ["default", "default"],
    101    request_headers: [{"If-Unmodified-Since": now.toGMTString()}, {}],
    102    expected_validation_headers: [false, false],
    103    expected_no_cache_headers: [true, false],
    104  },
    105  {
    106    name: 'RequestCache "default" mode with an If-Match header (following a request without additional headers) is treated similarly to "no-store"',
    107    state: "stale",
    108    request_cache: ["default", "default"],
    109    request_headers: [{}, {"If-Match": '"foo"'}],
    110    expected_validation_headers: [false, false],
    111    expected_no_cache_headers: [false, true],
    112  },
    113  {
    114    name: 'RequestCache "default" mode with an If-Match header (following a request without additional headers) is treated similarly to "no-store"',
    115    state: "fresh",
    116    request_cache: ["default", "default"],
    117    request_headers: [{}, {"If-Match": '"foo"'}],
    118    expected_validation_headers: [false, false],
    119    expected_no_cache_headers: [false, true],
    120  },
    121  {
    122    name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
    123    state: "stale",
    124    request_cache: ["default", "default"],
    125    request_headers: [{"If-Match": '"foo"'}, {}],
    126    expected_validation_headers: [false, false],
    127    expected_no_cache_headers: [true, false],
    128  },
    129  {
    130    name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
    131    state: "fresh",
    132    request_cache: ["default", "default"],
    133    request_headers: [{"If-Match": '"foo"'}, {}],
    134    expected_validation_headers: [false, false],
    135    expected_no_cache_headers: [true, false],
    136  },
    137  {
    138    name: 'RequestCache "default" mode with an If-Range header (following a request without additional headers) is treated similarly to "no-store"',
    139    state: "stale",
    140    request_cache: ["default", "default"],
    141    request_headers: [{}, {"If-Range": '"foo"'}],
    142    expected_validation_headers: [false, false],
    143    expected_no_cache_headers: [false, true],
    144  },
    145  {
    146    name: 'RequestCache "default" mode with an If-Range header (following a request without additional headers) is treated similarly to "no-store"',
    147    state: "fresh",
    148    request_cache: ["default", "default"],
    149    request_headers: [{}, {"If-Range": '"foo"'}],
    150    expected_validation_headers: [false, false],
    151    expected_no_cache_headers: [false, true],
    152  },
    153  {
    154    name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
    155    state: "stale",
    156    request_cache: ["default", "default"],
    157    request_headers: [{"If-Range": '"foo"'}, {}],
    158    expected_validation_headers: [false, false],
    159    expected_no_cache_headers: [true, false],
    160  },
    161  {
    162    name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
    163    state: "fresh",
    164    request_cache: ["default", "default"],
    165    request_headers: [{"If-Range": '"foo"'}, {}],
    166    expected_validation_headers: [false, false],
    167    expected_no_cache_headers: [true, false],
    168  },
    169 ];
    170 run_tests(tests);