request-cache-only-if-cached.any.js (2594B)
1 // META: global=window,dedicatedworker,sharedworker 2 // META: title=Request cache - only-if-cached 3 // META: script=/common/utils.js 4 // META: script=/common/get-host-info.sub.js 5 // META: script=request-cache.js 6 7 // FIXME: avoid mixed content requests to enable service worker global 8 var tests = [ 9 { 10 name: 'RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses', 11 state: "stale", 12 request_cache: ["default", "only-if-cached"], 13 expected_validation_headers: [false], 14 expected_no_cache_headers: [false] 15 }, 16 { 17 name: 'RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses', 18 state: "fresh", 19 request_cache: ["default", "only-if-cached"], 20 expected_validation_headers: [false], 21 expected_no_cache_headers: [false] 22 }, 23 { 24 name: 'RequestCache "only-if-cached" mode checks the cache for previously cached content and does not go to the network if a cached response is not found', 25 state: "fresh", 26 request_cache: ["only-if-cached"], 27 response: ["error"], 28 expected_validation_headers: [], 29 expected_no_cache_headers: [] 30 }, 31 { 32 name: 'RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content', 33 state: "fresh", 34 request_cache: ["default", "only-if-cached"], 35 redirect: "same-origin", 36 expected_validation_headers: [false, false], 37 expected_no_cache_headers: [false, false], 38 }, 39 { 40 name: 'RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content', 41 state: "stale", 42 request_cache: ["default", "only-if-cached"], 43 redirect: "same-origin", 44 expected_validation_headers: [false, false], 45 expected_no_cache_headers: [false, false], 46 }, 47 { 48 name: 'RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects', 49 state: "fresh", 50 request_cache: ["default", "only-if-cached"], 51 redirect: "cross-origin", 52 response: [null, "error"], 53 expected_validation_headers: [false, false], 54 expected_no_cache_headers: [false, false], 55 }, 56 { 57 name: 'RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects', 58 state: "stale", 59 request_cache: ["default", "only-if-cached"], 60 redirect: "cross-origin", 61 response: [null, "error"], 62 expected_validation_headers: [false, false], 63 expected_no_cache_headers: [false, false], 64 }, 65 ]; 66 run_tests(tests);