tor-browser

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

browser_suggestedIndex_10_search_5_url.js (15917B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 // This test checks row visibility during view updates when rows with suggested
      6 // indexes are added and removed. Each task performs two searches: Search 1
      7 // returns 10 results with search suggestions, and search 2 returns 5 results
      8 // with URL results.
      9 
     10 "use strict";
     11 
     12 // Search 1:
     13 //   10 results, no suggestedIndex
     14 // Search 2:
     15 //   5 results including suggestedIndex = 1
     16 // Expected visible rows during update:
     17 //   10 original rows with no changes
     18 add_suggestedIndex_task({
     19  search1: {
     20    otherCount: 10,
     21    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
     22    viewCount: 10,
     23  },
     24  search2: {
     25    otherCount: 3,
     26    otherType: UrlbarUtils.RESULT_TYPE.URL,
     27    suggestedIndex: 1,
     28    viewCount: 5,
     29  },
     30  duringUpdate: [
     31    { count: 1 },
     32    { count: 9, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
     33    {
     34      count: 1,
     35      type: UrlbarUtils.RESULT_TYPE.URL,
     36      suggestedIndex: 1,
     37      hidden: true,
     38    },
     39    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
     40  ],
     41 });
     42 
     43 // Search 1:
     44 //   10 results, no suggestedIndex
     45 // Search 2:
     46 //   5 results including suggestedIndex = 2
     47 // Expected visible rows during update:
     48 //   10 original rows with no changes
     49 add_suggestedIndex_task({
     50  search1: {
     51    otherCount: 10,
     52    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
     53    viewCount: 10,
     54  },
     55  search2: {
     56    otherCount: 3,
     57    otherType: UrlbarUtils.RESULT_TYPE.URL,
     58    suggestedIndex: 2,
     59    viewCount: 5,
     60  },
     61  duringUpdate: [
     62    { count: 1 },
     63    { count: 9, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
     64    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
     65    {
     66      count: 1,
     67      type: UrlbarUtils.RESULT_TYPE.URL,
     68      suggestedIndex: 2,
     69      hidden: true,
     70    },
     71    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
     72  ],
     73 });
     74 
     75 // Search 1:
     76 //   10 results, no suggestedIndex
     77 // Search 2:
     78 //   5 results including suggestedIndex = 9
     79 // Expected visible rows during update:
     80 //   10 original rows with no changes
     81 add_suggestedIndex_task({
     82  search1: {
     83    otherCount: 10,
     84    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
     85    viewCount: 10,
     86  },
     87  search2: {
     88    otherCount: 3,
     89    otherType: UrlbarUtils.RESULT_TYPE.URL,
     90    suggestedIndex: 9,
     91    viewCount: 5,
     92  },
     93  duringUpdate: [
     94    { count: 1 },
     95    { count: 9, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
     96    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
     97    {
     98      count: 1,
     99      type: UrlbarUtils.RESULT_TYPE.URL,
    100      suggestedIndex: 9,
    101      hidden: true,
    102    },
    103  ],
    104 });
    105 
    106 // Search 1:
    107 //   10 results, no suggestedIndex
    108 // Search 2:
    109 //   5 results including suggestedIndex = -1
    110 // Expected visible rows during update:
    111 //   10 original rows with no changes
    112 add_suggestedIndex_task({
    113  search1: {
    114    otherCount: 10,
    115    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    116    viewCount: 10,
    117  },
    118  search2: {
    119    otherCount: 3,
    120    otherType: UrlbarUtils.RESULT_TYPE.URL,
    121    suggestedIndex: -1,
    122    viewCount: 5,
    123  },
    124  duringUpdate: [
    125    { count: 1 },
    126    { count: 9, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    127    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    128    {
    129      count: 1,
    130      type: UrlbarUtils.RESULT_TYPE.URL,
    131      suggestedIndex: -1,
    132      hidden: true,
    133    },
    134  ],
    135 });
    136 
    137 // Search 1:
    138 //   10 results, no suggestedIndex
    139 // Search 2:
    140 //   5 results including suggestedIndex = -2
    141 // Expected visible rows during update:
    142 //   10 original rows with no changes
    143 add_suggestedIndex_task({
    144  search1: {
    145    otherCount: 10,
    146    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    147    viewCount: 10,
    148  },
    149  search2: {
    150    otherCount: 3,
    151    otherType: UrlbarUtils.RESULT_TYPE.URL,
    152    suggestedIndex: -2,
    153    viewCount: 5,
    154  },
    155  duringUpdate: [
    156    { count: 1 },
    157    { count: 9, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    158    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    159    {
    160      count: 1,
    161      type: UrlbarUtils.RESULT_TYPE.URL,
    162      suggestedIndex: -2,
    163      hidden: true,
    164    },
    165    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    166  ],
    167 });
    168 
    169 // Search 1:
    170 //   10 results including suggestedIndex = 1
    171 // Search 2:
    172 //   5 results including suggestedIndex = 1
    173 // Expected visible rows during update:
    174 //   10 original rows with no changes
    175 add_suggestedIndex_task({
    176  search1: {
    177    otherCount: 10,
    178    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    179    suggestedIndex: 1,
    180    viewCount: 10,
    181  },
    182  search2: {
    183    otherCount: 3,
    184    otherType: UrlbarUtils.RESULT_TYPE.URL,
    185    suggestedIndex: 1,
    186    viewCount: 5,
    187  },
    188  duringUpdate: [
    189    { count: 1 },
    190    {
    191      count: 1,
    192      type: UrlbarUtils.RESULT_TYPE.URL,
    193      suggestedIndex: 1,
    194    },
    195    { count: 8, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    196    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    197  ],
    198 });
    199 
    200 // Search 1:
    201 //   10 results including suggestedIndex = 1
    202 // Search 2:
    203 //   5 results including suggestedIndex = 9
    204 // Expected visible rows during update:
    205 //   10 original rows with no changes
    206 add_suggestedIndex_task({
    207  search1: {
    208    otherCount: 10,
    209    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    210    suggestedIndex: 1,
    211    viewCount: 10,
    212  },
    213  search2: {
    214    otherCount: 3,
    215    otherType: UrlbarUtils.RESULT_TYPE.URL,
    216    suggestedIndex: 9,
    217    viewCount: 5,
    218  },
    219  duringUpdate: [
    220    { count: 1 },
    221    {
    222      count: 1,
    223      type: UrlbarUtils.RESULT_TYPE.URL,
    224      suggestedIndex: 1,
    225      stale: true,
    226    },
    227    { count: 8, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    228    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    229    {
    230      count: 1,
    231      type: UrlbarUtils.RESULT_TYPE.URL,
    232      suggestedIndex: 9,
    233      hidden: true,
    234    },
    235  ],
    236 });
    237 
    238 // Search 1:
    239 //   10 results including suggestedIndex = 1
    240 // Search 2:
    241 //   5 results including suggestedIndex = -1
    242 // Expected visible rows during update:
    243 //   10 original rows with no changes
    244 add_suggestedIndex_task({
    245  search1: {
    246    otherCount: 10,
    247    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    248    suggestedIndex: 1,
    249    viewCount: 10,
    250  },
    251  search2: {
    252    otherCount: 3,
    253    otherType: UrlbarUtils.RESULT_TYPE.URL,
    254    suggestedIndex: -1,
    255    viewCount: 5,
    256  },
    257  duringUpdate: [
    258    { count: 1 },
    259    {
    260      count: 1,
    261      type: UrlbarUtils.RESULT_TYPE.URL,
    262      suggestedIndex: 1,
    263      stale: true,
    264    },
    265    { count: 8, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    266    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    267    {
    268      count: 1,
    269      type: UrlbarUtils.RESULT_TYPE.URL,
    270      suggestedIndex: -1,
    271      hidden: true,
    272    },
    273  ],
    274 });
    275 
    276 // Search 1:
    277 //   10 results including suggestedIndex = 1
    278 // Search 2:
    279 //   5 results including suggestedIndex = -3
    280 // Expected visible rows during update:
    281 //   10 original rows with no changes
    282 add_suggestedIndex_task({
    283  search1: {
    284    otherCount: 10,
    285    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    286    suggestedIndex: 1,
    287    viewCount: 10,
    288  },
    289  search2: {
    290    otherCount: 3,
    291    otherType: UrlbarUtils.RESULT_TYPE.URL,
    292    suggestedIndex: -3,
    293    viewCount: 5,
    294  },
    295  duringUpdate: [
    296    { count: 1 },
    297    {
    298      count: 1,
    299      type: UrlbarUtils.RESULT_TYPE.URL,
    300      suggestedIndex: 1,
    301      stale: true,
    302    },
    303    { count: 8, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    304    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    305    {
    306      count: 1,
    307      type: UrlbarUtils.RESULT_TYPE.URL,
    308      suggestedIndex: -3,
    309      hidden: true,
    310    },
    311    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    312  ],
    313 });
    314 
    315 // Search 1:
    316 //   10 results including suggestedIndex = 9
    317 // Search 2:
    318 //   5 results including suggestedIndex = 1
    319 // Expected visible rows during update:
    320 //   10 original rows with no changes
    321 add_suggestedIndex_task({
    322  search1: {
    323    otherCount: 10,
    324    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    325    suggestedIndex: 9,
    326    viewCount: 10,
    327  },
    328  search2: {
    329    otherCount: 3,
    330    otherType: UrlbarUtils.RESULT_TYPE.URL,
    331    suggestedIndex: 1,
    332    viewCount: 5,
    333  },
    334  duringUpdate: [
    335    { count: 1 },
    336    { count: 8, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    337    {
    338      count: 1,
    339      type: UrlbarUtils.RESULT_TYPE.URL,
    340      suggestedIndex: 9,
    341      stale: true,
    342    },
    343    {
    344      count: 1,
    345      type: UrlbarUtils.RESULT_TYPE.URL,
    346      suggestedIndex: 1,
    347      hidden: true,
    348    },
    349    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    350  ],
    351 });
    352 
    353 // Search 1:
    354 //   10 results including suggestedIndex = 9
    355 // Search 2:
    356 //   5 results including suggestedIndex = 9
    357 // Expected visible rows during update:
    358 //   10 original rows with no changes
    359 add_suggestedIndex_task({
    360  search1: {
    361    otherCount: 10,
    362    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    363    suggestedIndex: 9,
    364    viewCount: 10,
    365  },
    366  search2: {
    367    otherCount: 3,
    368    otherType: UrlbarUtils.RESULT_TYPE.URL,
    369    suggestedIndex: 9,
    370    viewCount: 5,
    371  },
    372  duringUpdate: [
    373    { count: 1 },
    374    { count: 8, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    375    {
    376      count: 1,
    377      type: UrlbarUtils.RESULT_TYPE.URL,
    378      suggestedIndex: 9,
    379      stale: true,
    380    },
    381    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    382    {
    383      count: 1,
    384      type: UrlbarUtils.RESULT_TYPE.URL,
    385      suggestedIndex: 9,
    386      hidden: true,
    387    },
    388  ],
    389 });
    390 
    391 // Search 1:
    392 //   10 results including suggestedIndex = -1
    393 // Search 2:
    394 //   5 results including suggestedIndex = 1
    395 // Expected visible rows during update:
    396 //   10 original rows with no changes
    397 add_suggestedIndex_task({
    398  search1: {
    399    otherCount: 10,
    400    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    401    suggestedIndex: -1,
    402    viewCount: 10,
    403  },
    404  search2: {
    405    otherCount: 3,
    406    otherType: UrlbarUtils.RESULT_TYPE.URL,
    407    suggestedIndex: 1,
    408    viewCount: 5,
    409  },
    410  duringUpdate: [
    411    { count: 1 },
    412    { count: 8, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    413    {
    414      count: 1,
    415      type: UrlbarUtils.RESULT_TYPE.URL,
    416      suggestedIndex: -1,
    417      stale: true,
    418    },
    419    {
    420      count: 1,
    421      type: UrlbarUtils.RESULT_TYPE.URL,
    422      suggestedIndex: 1,
    423      hidden: true,
    424    },
    425    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    426  ],
    427 });
    428 
    429 // Search 1:
    430 //   10 results including suggestedIndex = -1
    431 // Search 2:
    432 //   5 results including suggestedIndex = 9
    433 // Expected visible rows during update:
    434 //   10 original rows with no changes
    435 add_suggestedIndex_task({
    436  search1: {
    437    otherCount: 10,
    438    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    439    suggestedIndex: -1,
    440    viewCount: 10,
    441  },
    442  search2: {
    443    otherCount: 3,
    444    otherType: UrlbarUtils.RESULT_TYPE.URL,
    445    suggestedIndex: 9,
    446    viewCount: 5,
    447  },
    448  duringUpdate: [
    449    { count: 1 },
    450    { count: 8, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    451    {
    452      count: 1,
    453      type: UrlbarUtils.RESULT_TYPE.URL,
    454      suggestedIndex: -1,
    455      stale: true,
    456    },
    457    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    458    {
    459      count: 1,
    460      type: UrlbarUtils.RESULT_TYPE.URL,
    461      suggestedIndex: 9,
    462      hidden: true,
    463    },
    464  ],
    465 });
    466 
    467 // Search 1:
    468 //   10 results including suggestedIndex = -1
    469 // Search 2:
    470 //   5 results including suggestedIndex = -1
    471 // Expected visible rows during update:
    472 //   10 original rows with no changes
    473 add_suggestedIndex_task({
    474  search1: {
    475    otherCount: 10,
    476    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    477    suggestedIndex: -1,
    478    viewCount: 10,
    479  },
    480  search2: {
    481    otherCount: 3,
    482    otherType: UrlbarUtils.RESULT_TYPE.URL,
    483    suggestedIndex: -1,
    484    viewCount: 5,
    485  },
    486  duringUpdate: [
    487    { count: 1 },
    488    { count: 8, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    489    {
    490      count: 1,
    491      type: UrlbarUtils.RESULT_TYPE.URL,
    492      suggestedIndex: -1,
    493      stale: true,
    494    },
    495    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    496    {
    497      count: 1,
    498      type: UrlbarUtils.RESULT_TYPE.URL,
    499      suggestedIndex: -1,
    500      hidden: true,
    501    },
    502  ],
    503 });
    504 
    505 // Search 1:
    506 //   10 results, no suggestedIndex
    507 // Search 2:
    508 //   5 results including suggestedIndex = 1 and suggestedIndex = -1
    509 // Expected visible rows during update:
    510 //   10 original rows with no changes
    511 add_suggestedIndex_task({
    512  search1: {
    513    otherCount: 10,
    514    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    515    viewCount: 10,
    516  },
    517  search2: {
    518    otherCount: 2,
    519    otherType: UrlbarUtils.RESULT_TYPE.URL,
    520    suggestedIndexes: [1, -1],
    521    viewCount: 5,
    522  },
    523  duringUpdate: [
    524    { count: 1 },
    525    { count: 9, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    526    {
    527      count: 1,
    528      type: UrlbarUtils.RESULT_TYPE.URL,
    529      suggestedIndex: 1,
    530      hidden: true,
    531    },
    532    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    533    {
    534      count: 1,
    535      type: UrlbarUtils.RESULT_TYPE.URL,
    536      suggestedIndex: -1,
    537      hidden: true,
    538    },
    539  ],
    540 });
    541 
    542 // Search 1:
    543 //   10 results including suggestedIndex = 1
    544 // Search 2:
    545 //   5 results including suggestedIndex = 1 and suggestedIndex = -1
    546 // Expected visible rows during update:
    547 //   10 original rows with no changes
    548 add_suggestedIndex_task({
    549  search1: {
    550    otherCount: 10,
    551    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    552    suggestedIndex: 1,
    553    viewCount: 10,
    554  },
    555  search2: {
    556    otherCount: 2,
    557    otherType: UrlbarUtils.RESULT_TYPE.URL,
    558    suggestedIndexes: [1, -1],
    559    viewCount: 5,
    560  },
    561  duringUpdate: [
    562    { count: 1 },
    563    {
    564      count: 1,
    565      type: UrlbarUtils.RESULT_TYPE.URL,
    566      suggestedIndex: 1,
    567    },
    568    { count: 8, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    569    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    570    {
    571      count: 1,
    572      type: UrlbarUtils.RESULT_TYPE.URL,
    573      suggestedIndex: -1,
    574      hidden: true,
    575    },
    576  ],
    577 });
    578 
    579 // Search 1:
    580 //   10 results including suggestedIndex = -1
    581 // Search 2:
    582 //   5 results including suggestedIndex = 1 and suggestedIndex = -1
    583 // Expected visible rows during update:
    584 //   10 original rows with no changes
    585 add_suggestedIndex_task({
    586  search1: {
    587    otherCount: 10,
    588    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    589    suggestedIndex: -1,
    590    viewCount: 10,
    591  },
    592  search2: {
    593    otherCount: 2,
    594    otherType: UrlbarUtils.RESULT_TYPE.URL,
    595    suggestedIndexes: [1, -1],
    596    viewCount: 5,
    597  },
    598  duringUpdate: [
    599    { count: 1 },
    600    { count: 8, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    601    {
    602      count: 1,
    603      type: UrlbarUtils.RESULT_TYPE.URL,
    604      suggestedIndex: -1,
    605      stale: true,
    606    },
    607    {
    608      count: 1,
    609      type: UrlbarUtils.RESULT_TYPE.URL,
    610      suggestedIndex: 1,
    611      hidden: true,
    612    },
    613    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    614    {
    615      count: 1,
    616      type: UrlbarUtils.RESULT_TYPE.URL,
    617      suggestedIndex: -1,
    618      hidden: true,
    619    },
    620  ],
    621 });
    622 
    623 // Search 1:
    624 //   9 results including suggestedIndex = 1 with resultSpan = 2
    625 // Search 2:
    626 //   5 results including:
    627 //     suggestedIndex = 1 with resultSpan = 2
    628 //     suggestedIndex = -1
    629 // Expected visible rows during update:
    630 //   9 original rows with no changes
    631 add_suggestedIndex_task({
    632  search1: {
    633    otherCount: 10,
    634    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    635    suggestedIndexes: [[1, 2]],
    636    viewCount: 9,
    637  },
    638  search2: {
    639    otherCount: 2,
    640    otherType: UrlbarUtils.RESULT_TYPE.URL,
    641    suggestedIndexes: [[1, 2], -1],
    642    viewCount: 5,
    643  },
    644  duringUpdate: [
    645    { count: 1 },
    646    {
    647      count: 1,
    648      type: UrlbarUtils.RESULT_TYPE.URL,
    649      suggestedIndex: 1,
    650      resultSpan: 2,
    651    },
    652    { count: 7, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    653    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    654    {
    655      count: 1,
    656      type: UrlbarUtils.RESULT_TYPE.URL,
    657      suggestedIndex: -1,
    658      hidden: true,
    659    },
    660  ],
    661 });