tor-browser

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

browser_suggestedIndex_5_search_5_url.js (27555B)


      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 5 results with search suggestions, and search 2 returns 5 results
      8 // with URL results.
      9 
     10 "use strict";
     11 
     12 // Search 1:
     13 //   5 results, no suggestedIndex
     14 // Search 2:
     15 //   5 results including suggestedIndex = 1
     16 // Expected visible rows during update:
     17 //   5 original rows with no changes
     18 add_suggestedIndex_task({
     19  search1: {
     20    otherCount: 4,
     21    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
     22    viewCount: 5,
     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: 4, 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 //   5 results, no suggestedIndex
     45 // Search 2:
     46 //   5 results including suggestedIndex = 2
     47 // Expected visible rows during update:
     48 //   5 search-1 rows + 1 search-2 row (the one before the suggestedIndex row)
     49 add_suggestedIndex_task({
     50  search1: {
     51    otherCount: 4,
     52    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
     53    viewCount: 5,
     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: 4, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
     64    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL },
     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 //   5 results, no suggestedIndex
     77 // Search 2:
     78 //   5 results including suggestedIndex = 9
     79 // Expected visible rows during update:
     80 //   5 search-1 rows + 3 search-2 rows (the ones before the suggestedIndex)
     81 add_suggestedIndex_task({
     82  search1: {
     83    otherCount: 4,
     84    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
     85    viewCount: 5,
     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: 4, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
     96    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL },
     97    {
     98      count: 1,
     99      type: UrlbarUtils.RESULT_TYPE.URL,
    100      suggestedIndex: 9,
    101      hidden: true,
    102    },
    103  ],
    104 });
    105 
    106 // Search 1:
    107 //   5 results, no suggestedIndex
    108 // Search 2:
    109 //   5 results including suggestedIndex = -1
    110 // Expected visible rows during update:
    111 //   5 search-1 rows + 3 search-2 rows (the ones before the suggestedIndex row)
    112 add_suggestedIndex_task({
    113  search1: {
    114    otherCount: 4,
    115    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    116    viewCount: 5,
    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: 4, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    127    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL },
    128    {
    129      count: 1,
    130      type: UrlbarUtils.RESULT_TYPE.URL,
    131      suggestedIndex: -1,
    132      hidden: true,
    133    },
    134  ],
    135 });
    136 
    137 // Search 1:
    138 //   5 results, no suggestedIndex
    139 // Search 2:
    140 //   5 results including suggestedIndex = -2
    141 // Expected visible rows during update:
    142 //   5 search-1 rows + 2 search-2 rows (the one before the suggestedIndex row)
    143 add_suggestedIndex_task({
    144  search1: {
    145    otherCount: 4,
    146    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    147    viewCount: 5,
    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: 4, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    158    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL },
    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 //   5 results including suggestedIndex = 1
    171 // Search 2:
    172 //   5 results including suggestedIndex = 1
    173 // Expected visible rows during update:
    174 //   5 search-1 rows + 3 search-2 rows (i.e., all rows from both searches)
    175 add_suggestedIndex_task({
    176  search1: {
    177    otherCount: 3,
    178    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    179    suggestedIndex: 1,
    180    viewCount: 5,
    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: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    196    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL },
    197  ],
    198 });
    199 
    200 // Search 1:
    201 //   5 results including suggestedIndex = 1
    202 // Search 2:
    203 //   5 results including suggestedIndex = 2
    204 // Expected visible rows during update:
    205 //   5 original rows with no changes
    206 add_suggestedIndex_task({
    207  search1: {
    208    otherCount: 3,
    209    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    210    suggestedIndex: 1,
    211    viewCount: 5,
    212  },
    213  search2: {
    214    otherCount: 3,
    215    otherType: UrlbarUtils.RESULT_TYPE.URL,
    216    suggestedIndex: 2,
    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: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    228    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    229    {
    230      count: 1,
    231      type: UrlbarUtils.RESULT_TYPE.URL,
    232      suggestedIndex: 2,
    233      hidden: true,
    234    },
    235    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    236  ],
    237 });
    238 
    239 // Search 1:
    240 //   5 results including suggestedIndex = 1
    241 // Search 2:
    242 //   5 results including suggestedIndex = 9
    243 // Expected visible rows during update:
    244 //   5 original rows with no changes
    245 add_suggestedIndex_task({
    246  search1: {
    247    otherCount: 3,
    248    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    249    suggestedIndex: 1,
    250    viewCount: 5,
    251  },
    252  search2: {
    253    otherCount: 3,
    254    otherType: UrlbarUtils.RESULT_TYPE.URL,
    255    suggestedIndex: 9,
    256    viewCount: 5,
    257  },
    258  duringUpdate: [
    259    { count: 1 },
    260    {
    261      count: 1,
    262      type: UrlbarUtils.RESULT_TYPE.URL,
    263      suggestedIndex: 1,
    264      stale: true,
    265    },
    266    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    267    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    268    {
    269      count: 1,
    270      type: UrlbarUtils.RESULT_TYPE.URL,
    271      suggestedIndex: 9,
    272      hidden: true,
    273    },
    274  ],
    275 });
    276 
    277 // Search 1:
    278 //   5 results including suggestedIndex = 1
    279 // Search 2:
    280 //   5 results including suggestedIndex = -1
    281 // Expected visible rows during update:
    282 //   5 original rows with no changes
    283 add_suggestedIndex_task({
    284  search1: {
    285    otherCount: 3,
    286    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    287    suggestedIndex: 1,
    288    viewCount: 5,
    289  },
    290  search2: {
    291    otherCount: 3,
    292    otherType: UrlbarUtils.RESULT_TYPE.URL,
    293    suggestedIndex: -1,
    294    viewCount: 5,
    295  },
    296  duringUpdate: [
    297    { count: 1 },
    298    {
    299      count: 1,
    300      type: UrlbarUtils.RESULT_TYPE.URL,
    301      suggestedIndex: 1,
    302      stale: true,
    303    },
    304    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    305    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    306    {
    307      count: 1,
    308      type: UrlbarUtils.RESULT_TYPE.URL,
    309      suggestedIndex: -1,
    310      hidden: true,
    311    },
    312  ],
    313 });
    314 
    315 // Search 1:
    316 //   5 results including suggestedIndex = 1
    317 // Search 2:
    318 //   5 results including suggestedIndex = -2
    319 // Expected visible rows during update:
    320 //   5 original rows with no changes
    321 add_suggestedIndex_task({
    322  search1: {
    323    otherCount: 3,
    324    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    325    suggestedIndex: 1,
    326    viewCount: 5,
    327  },
    328  search2: {
    329    otherCount: 3,
    330    otherType: UrlbarUtils.RESULT_TYPE.URL,
    331    suggestedIndex: -2,
    332    viewCount: 5,
    333  },
    334  duringUpdate: [
    335    { count: 1 },
    336    {
    337      count: 1,
    338      type: UrlbarUtils.RESULT_TYPE.URL,
    339      suggestedIndex: 1,
    340      stale: true,
    341    },
    342    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    343    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    344    {
    345      count: 1,
    346      type: UrlbarUtils.RESULT_TYPE.URL,
    347      suggestedIndex: -2,
    348      hidden: true,
    349    },
    350    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    351  ],
    352 });
    353 
    354 // Search 1:
    355 //   5 results including suggestedIndex = 1
    356 // Search 2:
    357 //   5 results including suggestedIndex = -3
    358 // Expected visible rows during update:
    359 //   5 original rows with no changes
    360 add_suggestedIndex_task({
    361  search1: {
    362    otherCount: 3,
    363    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    364    suggestedIndex: 1,
    365    viewCount: 5,
    366  },
    367  search2: {
    368    otherCount: 3,
    369    otherType: UrlbarUtils.RESULT_TYPE.URL,
    370    suggestedIndex: -3,
    371    viewCount: 5,
    372  },
    373  duringUpdate: [
    374    { count: 1 },
    375    {
    376      count: 1,
    377      type: UrlbarUtils.RESULT_TYPE.URL,
    378      suggestedIndex: 1,
    379      stale: true,
    380    },
    381    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    382    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    383    {
    384      count: 1,
    385      type: UrlbarUtils.RESULT_TYPE.URL,
    386      suggestedIndex: -3,
    387      hidden: true,
    388    },
    389    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    390  ],
    391 });
    392 
    393 // Search 1:
    394 //   5 results including suggestedIndex = 9
    395 // Search 2:
    396 //   5 results including suggestedIndex = 1
    397 // Expected visible rows during update:
    398 //   5 original rows with no changes
    399 add_suggestedIndex_task({
    400  search1: {
    401    otherCount: 3,
    402    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    403    suggestedIndex: 9,
    404    viewCount: 5,
    405  },
    406  search2: {
    407    otherCount: 3,
    408    otherType: UrlbarUtils.RESULT_TYPE.URL,
    409    suggestedIndex: 1,
    410    viewCount: 5,
    411  },
    412  duringUpdate: [
    413    { count: 1 },
    414    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    415    {
    416      count: 1,
    417      type: UrlbarUtils.RESULT_TYPE.URL,
    418      suggestedIndex: 9,
    419      stale: true,
    420    },
    421    {
    422      count: 1,
    423      type: UrlbarUtils.RESULT_TYPE.URL,
    424      suggestedIndex: 1,
    425      hidden: true,
    426    },
    427    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    428  ],
    429 });
    430 
    431 // Search 1:
    432 //   5 results including suggestedIndex = 9
    433 // Search 2:
    434 //   5 results including suggestedIndex = 2
    435 // Expected visible rows during update:
    436 //   5 original rows with no changes
    437 add_suggestedIndex_task({
    438  search1: {
    439    otherCount: 3,
    440    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    441    suggestedIndex: 9,
    442    viewCount: 5,
    443  },
    444  search2: {
    445    otherCount: 3,
    446    otherType: UrlbarUtils.RESULT_TYPE.URL,
    447    suggestedIndex: 2,
    448    viewCount: 5,
    449  },
    450  duringUpdate: [
    451    { count: 1 },
    452    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    453    {
    454      count: 1,
    455      type: UrlbarUtils.RESULT_TYPE.URL,
    456      suggestedIndex: 9,
    457      stale: true,
    458    },
    459    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    460    {
    461      count: 1,
    462      type: UrlbarUtils.RESULT_TYPE.URL,
    463      suggestedIndex: 2,
    464      hidden: true,
    465    },
    466    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    467  ],
    468 });
    469 
    470 // Search 1:
    471 //   5 results including suggestedIndex = 9
    472 // Search 2:
    473 //   5 results including suggestedIndex = 9
    474 // Expected visible rows during update:
    475 //   5 original rows with no changes (because the original search results can't
    476 //   be replaced with URL results)
    477 add_suggestedIndex_task({
    478  search1: {
    479    otherCount: 3,
    480    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    481    suggestedIndex: 9,
    482    viewCount: 5,
    483  },
    484  search2: {
    485    otherCount: 3,
    486    otherType: UrlbarUtils.RESULT_TYPE.URL,
    487    suggestedIndex: 9,
    488    viewCount: 5,
    489  },
    490  duringUpdate: [
    491    { count: 1 },
    492    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    493    {
    494      count: 1,
    495      type: UrlbarUtils.RESULT_TYPE.URL,
    496      suggestedIndex: 9,
    497      stale: true,
    498    },
    499    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    500    {
    501      count: 1,
    502      type: UrlbarUtils.RESULT_TYPE.URL,
    503      suggestedIndex: 9,
    504      hidden: true,
    505    },
    506  ],
    507 });
    508 
    509 // Search 1:
    510 //   5 results including suggestedIndex = 9
    511 // Search 2:
    512 //   5 results including suggestedIndex = -1
    513 // Expected visible rows during update:
    514 //   5 original rows with no changes
    515 add_suggestedIndex_task({
    516  search1: {
    517    otherCount: 3,
    518    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    519    suggestedIndex: 9,
    520    viewCount: 5,
    521  },
    522  search2: {
    523    otherCount: 3,
    524    otherType: UrlbarUtils.RESULT_TYPE.URL,
    525    suggestedIndex: -1,
    526    viewCount: 5,
    527  },
    528  duringUpdate: [
    529    { count: 1 },
    530    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    531    {
    532      count: 1,
    533      type: UrlbarUtils.RESULT_TYPE.URL,
    534      suggestedIndex: 9,
    535      stale: true,
    536    },
    537    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    538    {
    539      count: 1,
    540      type: UrlbarUtils.RESULT_TYPE.URL,
    541      suggestedIndex: -1,
    542      hidden: true,
    543    },
    544  ],
    545 });
    546 
    547 // Search 1:
    548 //   5 results including suggestedIndex = 9
    549 // Search 2:
    550 //   5 results including suggestedIndex = -2
    551 // Expected visible rows during update:
    552 //   5 original rows with no changes
    553 add_suggestedIndex_task({
    554  search1: {
    555    otherCount: 3,
    556    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    557    suggestedIndex: 9,
    558    viewCount: 5,
    559  },
    560  search2: {
    561    otherCount: 3,
    562    otherType: UrlbarUtils.RESULT_TYPE.URL,
    563    suggestedIndex: -2,
    564    viewCount: 5,
    565  },
    566  duringUpdate: [
    567    { count: 1 },
    568    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    569    {
    570      count: 1,
    571      type: UrlbarUtils.RESULT_TYPE.URL,
    572      suggestedIndex: 9,
    573      stale: true,
    574    },
    575    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    576    {
    577      count: 1,
    578      type: UrlbarUtils.RESULT_TYPE.URL,
    579      suggestedIndex: -2,
    580      hidden: true,
    581    },
    582    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    583  ],
    584 });
    585 
    586 // Search 1:
    587 //   5 results including suggestedIndex = 9
    588 // Search 2:
    589 //   5 results including suggestedIndex = -3
    590 // Expected visible rows during update:
    591 //   5 original rows with no changes
    592 add_suggestedIndex_task({
    593  search1: {
    594    otherCount: 3,
    595    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    596    suggestedIndex: 9,
    597    viewCount: 5,
    598  },
    599  search2: {
    600    otherCount: 3,
    601    otherType: UrlbarUtils.RESULT_TYPE.URL,
    602    suggestedIndex: -3,
    603    viewCount: 5,
    604  },
    605  duringUpdate: [
    606    { count: 1 },
    607    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    608    {
    609      count: 1,
    610      type: UrlbarUtils.RESULT_TYPE.URL,
    611      suggestedIndex: 9,
    612      stale: true,
    613    },
    614    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    615    {
    616      count: 1,
    617      type: UrlbarUtils.RESULT_TYPE.URL,
    618      suggestedIndex: -3,
    619      hidden: true,
    620    },
    621    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    622  ],
    623 });
    624 
    625 // Search 1:
    626 //   5 results including suggestedIndex = -1
    627 // Search 2:
    628 //   5 results including suggestedIndex = 1
    629 // Expected visible rows during update:
    630 //   5 original rows with no changes
    631 add_suggestedIndex_task({
    632  search1: {
    633    otherCount: 3,
    634    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    635    suggestedIndex: -1,
    636    viewCount: 5,
    637  },
    638  search2: {
    639    otherCount: 3,
    640    otherType: UrlbarUtils.RESULT_TYPE.URL,
    641    suggestedIndex: 1,
    642    viewCount: 5,
    643  },
    644  duringUpdate: [
    645    { count: 1 },
    646    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    647    {
    648      count: 1,
    649      type: UrlbarUtils.RESULT_TYPE.URL,
    650      suggestedIndex: -1,
    651      stale: true,
    652    },
    653    {
    654      count: 1,
    655      type: UrlbarUtils.RESULT_TYPE.URL,
    656      suggestedIndex: 1,
    657      hidden: true,
    658    },
    659    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    660  ],
    661 });
    662 
    663 // Search 1:
    664 //   5 results including suggestedIndex = -1
    665 // Search 2:
    666 //   5 results including suggestedIndex = 2
    667 // Expected visible rows during update:
    668 //   5 original rows with no changes
    669 add_suggestedIndex_task({
    670  search1: {
    671    otherCount: 3,
    672    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    673    suggestedIndex: -1,
    674    viewCount: 5,
    675  },
    676  search2: {
    677    otherCount: 3,
    678    otherType: UrlbarUtils.RESULT_TYPE.URL,
    679    suggestedIndex: 2,
    680    viewCount: 5,
    681  },
    682  duringUpdate: [
    683    { count: 1 },
    684    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    685    {
    686      count: 1,
    687      type: UrlbarUtils.RESULT_TYPE.URL,
    688      suggestedIndex: -1,
    689      stale: true,
    690    },
    691    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    692    {
    693      count: 1,
    694      type: UrlbarUtils.RESULT_TYPE.URL,
    695      suggestedIndex: 2,
    696      hidden: true,
    697    },
    698    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    699  ],
    700 });
    701 
    702 // Search 1:
    703 //   5 results including suggestedIndex = -1
    704 // Search 2:
    705 //   5 results including suggestedIndex = 9
    706 // Expected visible rows during update:
    707 //   5 original rows with no changes
    708 add_suggestedIndex_task({
    709  search1: {
    710    otherCount: 3,
    711    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    712    suggestedIndex: -1,
    713    viewCount: 5,
    714  },
    715  search2: {
    716    otherCount: 3,
    717    otherType: UrlbarUtils.RESULT_TYPE.URL,
    718    suggestedIndex: 9,
    719    viewCount: 5,
    720  },
    721  duringUpdate: [
    722    { count: 1 },
    723    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    724    {
    725      count: 1,
    726      type: UrlbarUtils.RESULT_TYPE.URL,
    727      suggestedIndex: -1,
    728      stale: true,
    729    },
    730    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    731    {
    732      count: 1,
    733      type: UrlbarUtils.RESULT_TYPE.URL,
    734      suggestedIndex: 9,
    735      hidden: true,
    736    },
    737  ],
    738 });
    739 
    740 // Search 1:
    741 //   5 results including suggestedIndex = -1
    742 // Search 2:
    743 //   5 results including suggestedIndex = -1
    744 // Expected visible rows during update:
    745 //   5 original rows with no changes
    746 add_suggestedIndex_task({
    747  search1: {
    748    otherCount: 3,
    749    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    750    suggestedIndex: -1,
    751    viewCount: 5,
    752  },
    753  search2: {
    754    otherCount: 3,
    755    otherType: UrlbarUtils.RESULT_TYPE.URL,
    756    suggestedIndex: -1,
    757    viewCount: 5,
    758  },
    759  duringUpdate: [
    760    { count: 1 },
    761    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    762    {
    763      count: 1,
    764      type: UrlbarUtils.RESULT_TYPE.URL,
    765      suggestedIndex: -1,
    766      stale: true,
    767    },
    768    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    769    {
    770      count: 1,
    771      type: UrlbarUtils.RESULT_TYPE.URL,
    772      suggestedIndex: -1,
    773      hidden: true,
    774    },
    775  ],
    776 });
    777 
    778 // Search 1:
    779 //   5 results including suggestedIndex = -1
    780 // Search 2:
    781 //   5 results including suggestedIndex = -2
    782 // Expected visible rows during update:
    783 //   5 original rows with no changes
    784 add_suggestedIndex_task({
    785  search1: {
    786    otherCount: 3,
    787    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    788    suggestedIndex: -1,
    789    viewCount: 5,
    790  },
    791  search2: {
    792    otherCount: 3,
    793    otherType: UrlbarUtils.RESULT_TYPE.URL,
    794    suggestedIndex: -2,
    795    viewCount: 5,
    796  },
    797  duringUpdate: [
    798    { count: 1 },
    799    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    800    {
    801      count: 1,
    802      type: UrlbarUtils.RESULT_TYPE.URL,
    803      suggestedIndex: -1,
    804      stale: true,
    805    },
    806    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    807    {
    808      count: 1,
    809      type: UrlbarUtils.RESULT_TYPE.URL,
    810      suggestedIndex: -2,
    811      hidden: true,
    812    },
    813    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    814  ],
    815 });
    816 
    817 // Search 1:
    818 //   5 results including suggestedIndex = -2
    819 // Search 2:
    820 //   5 results including suggestedIndex = 1
    821 // Expected visible rows during update:
    822 //   5 original rows with no changes
    823 add_suggestedIndex_task({
    824  search1: {
    825    otherCount: 3,
    826    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    827    suggestedIndex: -2,
    828    viewCount: 5,
    829  },
    830  search2: {
    831    otherCount: 3,
    832    otherType: UrlbarUtils.RESULT_TYPE.URL,
    833    suggestedIndex: 1,
    834    viewCount: 5,
    835  },
    836  duringUpdate: [
    837    { count: 1 },
    838    { count: 2, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    839    {
    840      count: 1,
    841      type: UrlbarUtils.RESULT_TYPE.URL,
    842      suggestedIndex: -2,
    843      stale: true,
    844    },
    845    { count: 1, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    846    {
    847      count: 1,
    848      type: UrlbarUtils.RESULT_TYPE.URL,
    849      suggestedIndex: 1,
    850      hidden: true,
    851    },
    852    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    853  ],
    854 });
    855 
    856 // Search 1:
    857 //   5 results including suggestedIndex = -2
    858 // Search 2:
    859 //   5 results including suggestedIndex = 2
    860 // Expected visible rows during update:
    861 //   5 original rows with no changes
    862 add_suggestedIndex_task({
    863  search1: {
    864    otherCount: 3,
    865    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    866    suggestedIndex: -2,
    867    viewCount: 5,
    868  },
    869  search2: {
    870    otherCount: 3,
    871    otherType: UrlbarUtils.RESULT_TYPE.URL,
    872    suggestedIndex: 2,
    873    viewCount: 5,
    874  },
    875  duringUpdate: [
    876    { count: 1 },
    877    { count: 2, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    878    {
    879      count: 1,
    880      type: UrlbarUtils.RESULT_TYPE.URL,
    881      suggestedIndex: -2,
    882      stale: true,
    883    },
    884    { count: 1, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    885    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    886    {
    887      count: 1,
    888      type: UrlbarUtils.RESULT_TYPE.URL,
    889      suggestedIndex: 2,
    890      hidden: true,
    891    },
    892    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    893  ],
    894 });
    895 
    896 // Search 1:
    897 //   5 results including suggestedIndex = -2
    898 // Search 2:
    899 //   5 results including suggestedIndex = 9
    900 // Expected visible rows during update:
    901 //   5 original rows with no changes
    902 add_suggestedIndex_task({
    903  search1: {
    904    otherCount: 3,
    905    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    906    suggestedIndex: -2,
    907    viewCount: 5,
    908  },
    909  search2: {
    910    otherCount: 3,
    911    otherType: UrlbarUtils.RESULT_TYPE.URL,
    912    suggestedIndex: 9,
    913    viewCount: 5,
    914  },
    915  duringUpdate: [
    916    { count: 1 },
    917    { count: 2, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    918    {
    919      count: 1,
    920      type: UrlbarUtils.RESULT_TYPE.URL,
    921      suggestedIndex: -2,
    922      stale: true,
    923    },
    924    { count: 1, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    925    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    926    {
    927      count: 1,
    928      type: UrlbarUtils.RESULT_TYPE.URL,
    929      suggestedIndex: 9,
    930      hidden: true,
    931    },
    932  ],
    933 });
    934 
    935 // Search 1:
    936 //   5 results including suggestedIndex = -2
    937 // Search 2:
    938 //   5 results including suggestedIndex = -1
    939 // Expected visible rows during update:
    940 //   5 original rows with no changes
    941 add_suggestedIndex_task({
    942  search1: {
    943    otherCount: 3,
    944    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    945    suggestedIndex: -2,
    946    viewCount: 5,
    947  },
    948  search2: {
    949    otherCount: 3,
    950    otherType: UrlbarUtils.RESULT_TYPE.URL,
    951    suggestedIndex: -1,
    952    viewCount: 5,
    953  },
    954  duringUpdate: [
    955    { count: 1 },
    956    { count: 2, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    957    {
    958      count: 1,
    959      type: UrlbarUtils.RESULT_TYPE.URL,
    960      suggestedIndex: -2,
    961      stale: true,
    962    },
    963    { count: 1, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    964    { count: 3, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
    965    {
    966      count: 1,
    967      type: UrlbarUtils.RESULT_TYPE.URL,
    968      suggestedIndex: -1,
    969      hidden: true,
    970    },
    971  ],
    972 });
    973 
    974 // Search 1:
    975 //   5 results including suggestedIndex = -2
    976 // Search 2:
    977 //   5 results including suggestedIndex = -2
    978 // Expected visible rows during update:
    979 //   5 original rows with no changes (because the original search results can't
    980 //   be replaced with URL results)
    981 add_suggestedIndex_task({
    982  search1: {
    983    otherCount: 3,
    984    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
    985    suggestedIndex: -2,
    986    viewCount: 5,
    987  },
    988  search2: {
    989    otherCount: 3,
    990    otherType: UrlbarUtils.RESULT_TYPE.URL,
    991    suggestedIndex: -2,
    992    viewCount: 5,
    993  },
    994  duringUpdate: [
    995    { count: 1 },
    996    { count: 2, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
    997    {
    998      count: 1,
    999      type: UrlbarUtils.RESULT_TYPE.URL,
   1000      suggestedIndex: -2,
   1001      stale: true,
   1002    },
   1003    { count: 1, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
   1004    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
   1005    {
   1006      count: 1,
   1007      type: UrlbarUtils.RESULT_TYPE.URL,
   1008      suggestedIndex: -2,
   1009      hidden: true,
   1010    },
   1011    { count: 1, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
   1012  ],
   1013 });
   1014 
   1015 // Search 1:
   1016 //   5 results, no suggestedIndex
   1017 // Search 2:
   1018 //   5 results including suggestedIndex = 1 and suggestedIndex = -1
   1019 // Expected visible rows during update:
   1020 //   5 original rows with no changes
   1021 add_suggestedIndex_task({
   1022  search1: {
   1023    otherCount: 4,
   1024    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
   1025    viewCount: 5,
   1026  },
   1027  search2: {
   1028    otherCount: 2,
   1029    otherType: UrlbarUtils.RESULT_TYPE.URL,
   1030    suggestedIndexes: [1, -1],
   1031    viewCount: 5,
   1032  },
   1033  duringUpdate: [
   1034    { count: 1 },
   1035    { count: 4, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
   1036    {
   1037      count: 1,
   1038      type: UrlbarUtils.RESULT_TYPE.URL,
   1039      suggestedIndex: 1,
   1040      hidden: true,
   1041    },
   1042    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
   1043    {
   1044      count: 1,
   1045      type: UrlbarUtils.RESULT_TYPE.URL,
   1046      suggestedIndex: -1,
   1047      hidden: true,
   1048    },
   1049  ],
   1050 });
   1051 
   1052 // Search 1:
   1053 //   5 results including suggestedIndex = 1
   1054 // Search 2:
   1055 //   5 results including suggestedIndex = 1 and suggestedIndex = -1
   1056 // Expected visible rows during update:
   1057 //   5 search-1 rows + 2 search-2 rows (the ones before the suggestedIndex row)
   1058 add_suggestedIndex_task({
   1059  search1: {
   1060    otherCount: 3,
   1061    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
   1062    suggestedIndex: 1,
   1063    viewCount: 5,
   1064  },
   1065  search2: {
   1066    otherCount: 2,
   1067    otherType: UrlbarUtils.RESULT_TYPE.URL,
   1068    suggestedIndexes: [1, -1],
   1069    viewCount: 5,
   1070  },
   1071  duringUpdate: [
   1072    { count: 1 },
   1073    {
   1074      count: 1,
   1075      type: UrlbarUtils.RESULT_TYPE.URL,
   1076      suggestedIndex: 1,
   1077    },
   1078    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
   1079    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL },
   1080    {
   1081      count: 1,
   1082      type: UrlbarUtils.RESULT_TYPE.URL,
   1083      suggestedIndex: -1,
   1084      hidden: true,
   1085    },
   1086  ],
   1087 });
   1088 
   1089 // Search 1:
   1090 //   5 results including suggestedIndex = -1
   1091 // Search 2:
   1092 //   5 results including suggestedIndex = 1 and suggestedIndex = -1
   1093 // Expected visible rows during update:
   1094 //   5 original rows with no changes
   1095 add_suggestedIndex_task({
   1096  search1: {
   1097    otherCount: 3,
   1098    otherType: UrlbarUtils.RESULT_TYPE.SEARCH,
   1099    suggestedIndex: -1,
   1100    viewCount: 5,
   1101  },
   1102  search2: {
   1103    otherCount: 2,
   1104    otherType: UrlbarUtils.RESULT_TYPE.URL,
   1105    suggestedIndexes: [1, -1],
   1106    viewCount: 5,
   1107  },
   1108  duringUpdate: [
   1109    { count: 1 },
   1110    { count: 3, type: UrlbarUtils.RESULT_TYPE.SEARCH, stale: true },
   1111    {
   1112      count: 1,
   1113      type: UrlbarUtils.RESULT_TYPE.URL,
   1114      suggestedIndex: -1,
   1115      stale: true,
   1116    },
   1117    {
   1118      count: 1,
   1119      type: UrlbarUtils.RESULT_TYPE.URL,
   1120      suggestedIndex: 1,
   1121      hidden: true,
   1122    },
   1123    { count: 2, type: UrlbarUtils.RESULT_TYPE.URL, hidden: true },
   1124    {
   1125      count: 1,
   1126      type: UrlbarUtils.RESULT_TYPE.URL,
   1127      suggestedIndex: -1,
   1128      hidden: true,
   1129    },
   1130  ],
   1131 });