no-vary-search.tentative.any.js (2593B)
1 // META: global=window,worker 2 // META: title=NoVarySearch HTTP Cache 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 NOTE for testing No-Vary-Search-Header: 9 - If `params` is set to true, `expect=("dispatch" "uuid")` must be specified. 10 Otherwise: 11 - The same HTTP Cache will be used by other tests, which are supposed 12 to be distinguished by uuid. 13 - The test utility cannot get the server's states because UA will use the HTTP 14 Cache instead of sending a new request to server to ask for the latest state. 15 - Do not test not_cached cases and cached cases within one test. Test infra 16 checks the number of requests and responses without considering if the 17 previous responses should be served from cache or not. 18 */ 19 var tests = [ 20 { 21 name: "When params is set to true, URL differs only by their parameters (other than `dispatch` and `uuid`) should not be cached as different entries.", 22 requests: [ 23 { 24 url_params: "a=1&b=2", 25 response_headers: [ 26 ["Cache-Control", "max-age=10000"], 27 ["No-Vary-Search", "params, except=(\"dispatch\" \"uuid\")"], 28 ], 29 }, 30 { 31 expected_type: "cached" 32 } 33 ] 34 }, 35 { 36 name: "Ground truth: When key-order is not set, URLs should be compared in an order-sensitive way.", 37 requests: [ 38 { 39 url_params: "a=1&b=2", 40 response_headers: [ 41 ["Cache-Control", "max-age=10000"], 42 ], 43 }, 44 { 45 url_params: "b=2&a=1", 46 expected_type: "not_cached" 47 } 48 ] 49 }, 50 { 51 name: "When key-order is set , URLs should be compared in an order-insensitive way. Matched cases:", 52 requests: [ 53 { 54 url_params: "a=1&b=2", 55 response_headers: [ 56 ["Cache-Control", "max-age=10000"], 57 ["No-Vary-Search", "key-order"], 58 ], 59 }, 60 { 61 url_params: "b=2&a=1", 62 expected_type: "cached" 63 } 64 ] 65 }, 66 { 67 name: "When key-order is set , URLs should be compared in an order-insensitive way. Not matched cases", 68 requests: [ 69 { 70 url_params: "a=1&b=2", 71 response_headers: [ 72 ["Cache-Control", "max-age=10000"], 73 ["No-Vary-Search", "key-order"], 74 ], 75 }, 76 { 77 url_params: "b=2", 78 expected_type: "not_cached" 79 }, 80 { 81 url_params: "a=2&b=2", 82 expected_type: "not_cached" 83 }, 84 { 85 url_params: "a=1&b=2&c=3", 86 expected_type: "not_cached" 87 } 88 ] 89 } 90 ]; 91 run_tests(tests);