tor-browser

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

hint-test-inputs.js (9523B)


      1 // Test inputs:
      2 // - description: a description of the test.
      3 // - noVarySearch: No-Vary-Search header value for the response.
      4 // - noVarySearchHint: No-Vary-Search hint to include in prefetch
      5 //   speculation rules
      6 // - prefetchQuery: added to query part of prefetch-executor when prefetching
      7 // - navigateQuery: added to query part of prefetch-executor when navigating
      8 // - shouldUse: if the test case expects the prefetched entry to be used or not.
      9 const hint_test_inputs = [
     10  {
     11    description:
     12        'Use in-flight prefetch as query parameter b has the same value.',
     13    noVarySearch: 'params=("a")',
     14    noVarySearchHint: 'params=("a")',
     15    prefetchQuery: 'a=2&b=3',
     16    navigateQuery: 'b=3',
     17    shouldUse: true
     18  },
     19 
     20  {
     21    description:
     22        'Don\'t use in-flight prefetch as there is no No-Vary-Search hint.',
     23    noVarySearch: 'params=("a")',
     24    noVarySearchHint: '',
     25    prefetchQuery: 'a=2&b=3',
     26    navigateQuery: 'b=3',
     27    shouldUse: false
     28  },
     29 
     30  {
     31    description:
     32        'Don\'t use in-flight prefetch as the prefetched URL has the extra "a" query parameter.',
     33    noVarySearch: 'params=("b")',
     34    noVarySearchHint: 'params=("b")',
     35    prefetchQuery: 'a=2&b=3',
     36    navigateQuery: 'b=2',
     37    shouldUse: false
     38  },
     39 
     40  {
     41    description: 'Use in-flight prefetch as the URLs do not vary by a and b.',
     42    noVarySearch: 'params=("a" "b")',
     43    noVarySearchHint: 'params=("a" "b")',
     44    prefetchQuery: 'a=2&b=3',
     45    navigateQuery: 'b=2',
     46    shouldUse: true
     47  },
     48 
     49  {
     50    description: 'Do not use in-flight prefetch as the navigation URL has' +
     51        ' a different value for the "b" query parameter.',
     52    noVarySearch: 'params=("a" "b")',
     53    noVarySearchHint: 'params=("a")',
     54    prefetchQuery: 'a=2&b=3',
     55    navigateQuery: 'b=2',
     56    shouldUse: false
     57  },
     58 
     59  {
     60    description:
     61        'Use in-flight prefetch as the URLs have the same values for all keys, only differing by order.',
     62    noVarySearch: 'key-order',
     63    noVarySearchHint: 'key-order',
     64    prefetchQuery: 'b=5&a=3&a=4&d=6&c=5&b=3',
     65    navigateQuery: 'd=6&a=3&b=5&b=3&c=5&a=4',
     66    shouldUse: true
     67  },
     68 
     69  {
     70    description:
     71        'Use in-flight prefetch as the URLs have the same values for all keys, only differing by order and using ?1 for specifying a true value.',
     72    noVarySearch: 'key-order=?1',
     73    noVarySearchHint: 'key-order=?1',
     74    prefetchQuery: 'b=5&a=3&a=4&d=6&c=5&b=3',
     75    navigateQuery: 'd=6&a=3&b=5&b=3&c=5&a=4',
     76    shouldUse: true
     77  },
     78 
     79  {
     80    description:
     81        'Don\'t use in-flight prefetch as key-order is set to false and the URLs are not identical.',
     82    noVarySearch: 'key-order=?0',
     83    noVarySearchHint: 'key-order=?1',
     84    prefetchQuery: 'b=5&a=3&a=4&d=6&c=5&b=3',
     85    navigateQuery: 'd=6&a=3&b=5&b=3&c=5&a=4',
     86    shouldUse: false
     87  },
     88 
     89  {
     90    description:
     91        'Use in-flight prefetch as all query parameters except c can be ignored.',
     92    noVarySearch: 'params, except=("c")',
     93    noVarySearchHint: 'params, except=("c")',
     94    prefetchQuery: 'b=5&a=3&d=6&c=3',
     95    navigateQuery: 'a=1&b=2&c=3',
     96    shouldUse: true
     97  },
     98 
     99  {
    100    description:
    101        'Use in-flight prefetch as all query parameters except c can be ignored.' +
    102        ' Only the last except matters.',
    103    noVarySearch: 'params, except=("b"), except=("c")',
    104    noVarySearchHint: 'params, except=("b"), except=("c")',
    105    prefetchQuery: 'b=5&a=3&d=6&c=3',
    106    navigateQuery: 'a=1&b=2&c=3',
    107    shouldUse: true
    108  },
    109 
    110  {
    111    description:
    112        'Don\'t use in-flight prefetch as even though all query parameters' +
    113        ' except c can be ignored, c has different value.',
    114    noVarySearch: 'params, except=("c")',
    115    noVarySearchHint: 'params',
    116    prefetchQuery: 'b=5&a=3&d=6&c=3',
    117    navigateQuery: 'a=1&b=2&c=5',
    118    shouldUse: false
    119  },
    120 
    121  {
    122    description: 'Use in-flight prefetch as even though all query parameters' +
    123        ' except c and d can be ignored, c value matches and d value matches.',
    124    noVarySearch: 'params, except=("c" "d")',
    125    noVarySearchHint: 'params, except=("c" "d")',
    126    prefetchQuery: 'b=5&a=3&d=6&c=5',
    127    navigateQuery: 'd=6&a=1&b=2&c=5',
    128    shouldUse: true
    129  },
    130 
    131  {
    132    description:
    133        'Use in-flight prefetch as even though all query parameters except' +
    134        ' c and d can be ignored, c value matches and d value matches.' +
    135        ' Some query parameters to be ignored appear multiple times in the query.',
    136    noVarySearch: 'params, except=("c" "d")',
    137    noVarySearchHint: 'params',
    138    prefetchQuery: 'b=5&a=3&a=4&d=6&c=5',
    139    navigateQuery: 'd=6&a=1&a=2&b=2&b=3&c=5',
    140    shouldUse: true
    141  },
    142 
    143  {
    144    description:
    145        'Use in-flight prefetch as all query parameters except c can be ignored.' +
    146        ' Allow extension via parameters.',
    147    noVarySearch: 'params, except=("c";unknown)',
    148    noVarySearchHint: 'params, except=("c";unknown)',
    149    prefetchQuery: 'b=5&a=3&d=6&c=3',
    150    navigateQuery: 'a=1&b=2&c=3',
    151    shouldUse: true
    152  },
    153 
    154  {
    155    description: 'Use in-flight prefetch as query parameter c can be ignored.' +
    156        ' Allow extension via parameters.',
    157    noVarySearch: 'params=("c";unknown)',
    158    noVarySearchHint: 'params=("c";unknown)',
    159    prefetchQuery: 'a=2&b=2&c=5',
    160    navigateQuery: 'a=2&c=3&b=2',
    161    shouldUse: true
    162  },
    163 
    164  {
    165    description:
    166        'Use in-flight prefetch as the URLs have the values in different order for a.' +
    167        ' Allow extension via parameters.',
    168    noVarySearch: 'key-order;unknown',
    169    noVarySearchHint: 'key-order;unknown',
    170    prefetchQuery: 'b=5&a=3&a=4&d=6&c=5&b=3',
    171    navigateQuery: 'd=6&a=3&b=5&b=3&c=5&a=4',
    172    shouldUse: true
    173  },
    174 
    175  {
    176    description:
    177        'Use in-flight prefetch as the URLs do not vary on any query parameters.' +
    178        ' Allow extension via parameters.',
    179    noVarySearch: 'params;unknown',
    180    noVarySearchHint: 'params;unknown',
    181    prefetchQuery: '',
    182    navigateQuery: 'b=4&c=5',
    183    shouldUse: true
    184  },
    185 
    186  {
    187    description:
    188        'Use in-flight prefetch as all query parameters except c can be ignored.' +
    189        ' Allow extension via parameters.',
    190    noVarySearch: 'params;unknown, except=("c");unknown',
    191    noVarySearchHint: 'params;unknown, except=("c");unknown',
    192    prefetchQuery: 'b=5&a=3&d=6&c=3',
    193    navigateQuery: 'a=1&b=2&c=3',
    194    shouldUse: true
    195  },
    196 
    197  {
    198    description:
    199        'Don\'t use the in-flight prefetched URL. Empty No-Vary-Search means default URL variance.' +
    200        ' The prefetched and the navigated URLs have to be the same.',
    201    noVarySearch: '',
    202    noVarySearchHint: 'params',
    203    prefetchQuery: 'b=5&a=3&d=6&c=3',
    204    navigateQuery: 'a=1&b=2&c=3',
    205    shouldUse: false
    206  },
    207 
    208  {
    209    description:
    210        'Use the in-flight prefetch. Empty No-Vary-Search means default URL variance.' +
    211        ' The prefetched and the navigated URLs have to be the same.',
    212    noVarySearch: '',
    213    noVarySearchHint: '',
    214    prefetchQuery: 'b=5&a=3&d=6&c=3',
    215    navigateQuery: 'b=5&a=3&d=6&c=3',
    216    shouldUse: true
    217  },
    218 
    219  {
    220    description:
    221        'Use the in-flight prefetch. Invalid No-Vary-Search means default URL variance.' +
    222        ' The prefetched and the navigated URLs have to be the same.',
    223    noVarySearch: '',
    224    noVarySearchHint: 'params=(a)',
    225    prefetchQuery: 'b=5&a=3&d=6&c=3',
    226    navigateQuery: 'b=5&a=3&d=6&c=3',
    227    shouldUse: true
    228  },
    229 
    230  {
    231    description:
    232        'Don\'t use the in-flight prefetch. Invalid No-Vary-Search means default URL variance.' +
    233        ' The prefetched and the navigated URLs are not the same.',
    234    noVarySearch: '',
    235    noVarySearchHint: 'params=(a)',
    236    prefetchQuery: 'b=5&a=3&d=6&c=3',
    237    navigateQuery: 'b=5&a=4&d=6&c=3',
    238    shouldUse: false
    239  },
    240 
    241  {
    242    description:
    243        'No-Vary-Search hint must be a string so the speculation rule will be ignored.' +
    244        ' There is no prefetch happening.',
    245    noVarySearch: '',
    246    noVarySearchHint: 0,
    247    prefetchQuery: 'b=5&a=3&d=6&c=3',
    248    navigateQuery: 'b=5&a=3&d=6&c=3',
    249    shouldUse: false
    250  },
    251 
    252  {
    253    description:
    254        'Use the in-flight prefetch. Empty No-Vary-Search means default URL variance.' +
    255        ' The prefetched and the navigated URLs have to be the same.',
    256    noVarySearch: '',
    257    noVarySearchHint: '',
    258    prefetchQuery: '',
    259    navigateQuery: '',
    260    shouldUse: true
    261  },
    262 
    263  {
    264    description:
    265        'Use the in-flight prefetch. Non-ASCII key - 2 UTF-8 code units.' +
    266        ' Don\'t vary the response on the non-ASCII key.',
    267    noVarySearch: 'params=("%C2%A2")',
    268    noVarySearchHint: 'params=("%C2%A2")',
    269    prefetchQuery: '¢=3',
    270    navigateQuery: '¢=4',
    271    shouldUse: true
    272  },
    273 
    274  {
    275    description:
    276        'Use the in-flight prefetch. Non-ASCII key - 2 UTF-8 code units.' +
    277        ' Don\'t vary the response on the non-ASCII key.',
    278    noVarySearch: 'params=("%C2%A2")',
    279    noVarySearchHint: 'params=("%C2%A2")',
    280    prefetchQuery: 'a=2&¢=3',
    281    navigateQuery: '¢=4&a=2',
    282    shouldUse: true
    283  },
    284 
    285  {
    286    description:
    287        'Don\'t use the in-flight prefetch. Non-ASCII key - 2 UTF-8 code units.' +
    288        ' Vary the response on the non-ASCII key.',
    289    noVarySearch: 'params, except=("%C2%A2")',
    290    noVarySearchHint: 'params',
    291    prefetchQuery: '¢=3',
    292    navigateQuery: '¢=4',
    293    shouldUse: false
    294  },
    295 
    296  {
    297    description:
    298        'Use the in-flight prefetch. Non-ASCII key - 2 UTF-8 code units.' +
    299        ' Vary the response on the non-ASCII key.',
    300    noVarySearch: 'params, except=("%C2%A2")',
    301    noVarySearchHint: 'params, except=("%C2%A2")',
    302    prefetchQuery: '¢=3&a=4',
    303    navigateQuery: 'a=5&¢=3',
    304    shouldUse: true
    305  },
    306 ];