1# vim: ft=cucumber fileencoding=utf-8 sts=4 sw=4 et:
2
3Feature: Tab management
4    Tests for various :tab-* commands.
5
6    Background:
7        Given I clean up open tabs
8        And I set tabs.tabs_are_windows to false
9        And I clear the log
10
11    # :tab-close
12
13    Scenario: :tab-close
14        When I open data/numbers/1.txt
15        And I open data/numbers/2.txt in a new tab
16        And I open data/numbers/3.txt in a new tab
17        And I run :tab-close
18        Then the following tabs should be open:
19            - data/numbers/1.txt
20            - data/numbers/2.txt (active)
21
22    Scenario: :tab-close with count
23        When I open data/numbers/1.txt
24        And I open data/numbers/2.txt in a new tab
25        And I open data/numbers/3.txt in a new tab
26        And I run :tab-close with count 1
27        Then the following tabs should be open:
28            - data/numbers/2.txt
29            - data/numbers/3.txt (active)
30
31    Scenario: :tab-close with invalid count
32        When I open data/numbers/1.txt
33        And I open data/numbers/2.txt in a new tab
34        And I open data/numbers/3.txt in a new tab
35        And I run :tab-close with count 23
36        Then the following tabs should be open:
37            - data/numbers/1.txt
38            - data/numbers/2.txt
39            - data/numbers/3.txt (active)
40
41    Scenario: :tab-close with tabs.select_on_remove = next
42        When I set tabs.select_on_remove to next
43        And I open data/numbers/1.txt
44        And I open data/numbers/2.txt in a new tab
45        And I open data/numbers/3.txt in a new tab
46        And I run :tab-focus 2
47        And I run :tab-close
48        Then the following tabs should be open:
49            - data/numbers/1.txt
50            - data/numbers/3.txt (active)
51
52    Scenario: :tab-close with tabs.select_on_remove = prev
53        When I set tabs.select_on_remove to prev
54        And I open data/numbers/1.txt
55        And I open data/numbers/2.txt in a new tab
56        And I open data/numbers/3.txt in a new tab
57        And I run :tab-focus 2
58        And I run :tab-close
59        Then the following tabs should be open:
60            - data/numbers/1.txt (active)
61            - data/numbers/3.txt
62
63    Scenario: :tab-close with tabs.select_on_remove = last-used
64        When I set tabs.select_on_remove to last-used
65        And I open data/numbers/1.txt
66        And I open data/numbers/2.txt in a new tab
67        And I open data/numbers/3.txt in a new tab
68        And I open data/numbers/4.txt in a new tab
69        And I run :tab-focus 2
70        And I run :tab-close
71        Then the following tabs should be open:
72            - data/numbers/1.txt
73            - data/numbers/3.txt
74            - data/numbers/4.txt (active)
75
76    Scenario: :tab-close with tabs.select_on_remove = prev and --next
77        When I set tabs.select_on_remove to prev
78        And I open data/numbers/1.txt
79        And I open data/numbers/2.txt in a new tab
80        And I open data/numbers/3.txt in a new tab
81        And I run :tab-focus 2
82        And I run :tab-close --next
83        Then the following tabs should be open:
84            - data/numbers/1.txt
85            - data/numbers/3.txt (active)
86
87    Scenario: :tab-close with tabs.select_on_remove = next and --prev
88        When I set tabs.select_on_remove to next
89        And I open data/numbers/1.txt
90        And I open data/numbers/2.txt in a new tab
91        And I open data/numbers/3.txt in a new tab
92        And I run :tab-focus 2
93        And I run :tab-close --prev
94        Then the following tabs should be open:
95            - data/numbers/1.txt (active)
96            - data/numbers/3.txt
97
98    Scenario: :tab-close with tabs.select_on_remove = prev and --opposite
99        When I set tabs.select_on_remove to prev
100        And I open data/numbers/1.txt
101        And I open data/numbers/2.txt in a new tab
102        And I open data/numbers/3.txt in a new tab
103        And I run :tab-focus 2
104        And I run :tab-close --opposite
105        Then the following tabs should be open:
106            - data/numbers/1.txt
107            - data/numbers/3.txt (active)
108
109    Scenario: :tab-close with tabs.select_on_remove = next and --opposite
110        When I set tabs.select_on_remove to next
111        And I open data/numbers/1.txt
112        And I open data/numbers/2.txt in a new tab
113        And I open data/numbers/3.txt in a new tab
114        And I run :tab-focus 2
115        And I run :tab-close --opposite
116        Then the following tabs should be open:
117            - data/numbers/1.txt (active)
118            - data/numbers/3.txt
119
120    Scenario: :tab-close with tabs.select_on_remove = last-used and --opposite
121        When I set tabs.select_on_remove to last-used
122        And I run :tab-close --opposite
123        Then the error "-o is not supported with 'tabs.select_on_remove' set to 'last-used'!" should be shown
124
125    Scenario: :tab-close should restore selection behavior
126        When I set tabs.select_on_remove to next
127        And I open data/numbers/1.txt
128        And I open data/numbers/2.txt in a new tab
129        And I open data/numbers/3.txt in a new tab
130        And I open data/numbers/4.txt in a new tab
131        And I run :tab-focus 2
132        And I run :tab-close --prev
133        And I run :tab-focus 2
134        And I run :tab-close
135        Then the following tabs should be open:
136            - data/numbers/1.txt
137            - data/numbers/4.txt (active)
138
139    # :tab-only
140
141    Scenario: :tab-only
142        When I open data/numbers/1.txt
143        And I open data/numbers/2.txt in a new tab
144        And I open data/numbers/3.txt in a new tab
145        And I run :tab-only
146        Then the following tabs should be open:
147            - data/numbers/3.txt (active)
148
149    Scenario: :tab-only with --prev
150        When I open data/numbers/1.txt
151        And I open data/numbers/2.txt in a new tab
152        And I open data/numbers/3.txt in a new tab
153        And I run :tab-focus 2
154        And I run :tab-only --prev
155        Then the following tabs should be open:
156            - data/numbers/1.txt
157            - data/numbers/2.txt (active)
158
159    Scenario: :tab-only with --next
160        When I open data/numbers/1.txt
161        And I open data/numbers/2.txt in a new tab
162        And I open data/numbers/3.txt in a new tab
163        And I run :tab-focus 2
164        And I run :tab-only --next
165        Then the following tabs should be open:
166            - data/numbers/2.txt (active)
167            - data/numbers/3.txt
168
169    Scenario: :tab-only with --prev and --next
170        When I run :tab-only --prev --next
171        Then the error "Only one of -p/-n can be given!" should be shown
172
173    # :tab-focus
174
175    Scenario: :tab-focus with invalid index
176        When I run :tab-focus foo
177        Then the error "Invalid value foo." should be shown
178
179    Scenario: :tab-focus with index
180        When I open data/numbers/1.txt
181        And I open data/numbers/2.txt in a new tab
182        And I open data/numbers/3.txt in a new tab
183        And I run :tab-focus 2
184        Then the following tabs should be open:
185            - data/numbers/1.txt
186            - data/numbers/2.txt (active)
187            - data/numbers/3.txt
188
189    Scenario: :tab-focus without index/count
190        When I open data/numbers/1.txt
191        And I open data/numbers/2.txt in a new tab
192        And I open data/numbers/3.txt in a new tab
193        And I run :tab-focus 2
194        And I run :tab-focus
195        Then the warning "Using :tab-focus without count is deprecated, use :tab-next instead." should be shown
196        And the following tabs should be open:
197            - data/numbers/1.txt
198            - data/numbers/2.txt
199            - data/numbers/3.txt (active)
200
201    Scenario: :tab-focus with invalid index
202        When I run :tab-focus 23
203        Then the error "There's no tab with index 23!" should be shown
204
205    Scenario: :tab-focus with very big index
206        When I run :tab-focus 99999999999999
207        Then the error "There's no tab with index 99999999999999!" should be shown
208
209    Scenario: :tab-focus with count
210        When I open data/numbers/1.txt
211        And I open data/numbers/2.txt in a new tab
212        And I open data/numbers/3.txt in a new tab
213        And I run :tab-focus with count 2
214        Then the following tabs should be open:
215            - data/numbers/1.txt
216            - data/numbers/2.txt (active)
217            - data/numbers/3.txt
218
219    Scenario: :tab-focus with count and index
220        When I open data/numbers/1.txt
221        And I open data/numbers/2.txt in a new tab
222        And I open data/numbers/3.txt in a new tab
223        And I run :tab-focus 4 with count 2
224        Then the following tabs should be open:
225            - data/numbers/1.txt
226            - data/numbers/2.txt (active)
227            - data/numbers/3.txt
228
229    Scenario: :tab-focus last
230        When I open data/numbers/1.txt
231        And I open data/numbers/2.txt in a new tab
232        And I open data/numbers/3.txt in a new tab
233        And I run :tab-focus 1
234        And I run :tab-focus 3
235        And I run :tab-focus last
236        Then the following tabs should be open:
237            - data/numbers/1.txt (active)
238            - data/numbers/2.txt
239            - data/numbers/3.txt
240
241    Scenario: :tab-focus with current tab number
242        When I open data/numbers/1.txt
243        And I open data/numbers/2.txt in a new tab
244        And I open data/numbers/3.txt in a new tab
245        And I run :tab-focus 1
246        And I run :tab-focus 3
247        And I run :tab-focus 3
248        Then the following tabs should be open:
249            - data/numbers/1.txt (active)
250            - data/numbers/2.txt
251            - data/numbers/3.txt
252
253    Scenario: :tab-focus with current tab number and --no-last
254        When I open data/numbers/1.txt
255        And I open data/numbers/2.txt in a new tab
256        And I open data/numbers/3.txt in a new tab
257        And I run :tab-focus 1
258        And I run :tab-focus 3
259        And I run :tab-focus --no-last 3
260        Then the following tabs should be open:
261            - data/numbers/1.txt
262            - data/numbers/2.txt
263            - data/numbers/3.txt (active)
264
265    Scenario: :tab-focus with -1
266        When I open data/numbers/1.txt
267        And I open data/numbers/2.txt in a new tab
268        And I open data/numbers/3.txt in a new tab
269        And I run :tab-focus 1
270        And I run :tab-focus -1
271        Then the following tabs should be open:
272            - data/numbers/1.txt
273            - data/numbers/2.txt
274            - data/numbers/3.txt (active)
275
276    Scenario: :tab-focus negative index
277        When I open data/numbers/1.txt
278        And I open data/numbers/2.txt in a new tab
279        And I open data/numbers/3.txt in a new tab
280        And I run :tab-focus -2
281        Then the following tabs should be open:
282            - data/numbers/1.txt
283            - data/numbers/2.txt (active)
284            - data/numbers/3.txt
285
286    Scenario: :tab-focus with invalid negative index
287        When I open data/numbers/1.txt
288        And I open data/numbers/2.txt in a new tab
289        And I open data/numbers/3.txt in a new tab
290        And I run :tab-focus -5
291        Then the error "There's no tab with index -1!" should be shown
292
293    Scenario: :tab-focus last with no last focused tab
294        When I run :tab-focus last
295        Then the error "Could not find requested tab!" should be shown
296
297    Scenario: :tab-focus prev stacking
298        When I open data/numbers/1.txt
299        And I open data/numbers/2.txt in a new tab
300        And I open data/numbers/3.txt in a new tab
301        And I open data/numbers/4.txt in a new tab
302        And I open data/numbers/5.txt in a new tab
303        And I run :tab-focus 1
304        And I run :tab-focus 5
305        And I run :tab-focus 2
306        And I run :tab-focus 4
307        And I run :tab-focus 3
308        And I run :repeat 2 tab-focus stack-prev
309        Then the following tabs should be open:
310            - data/numbers/1.txt
311            - data/numbers/2.txt (active)
312            - data/numbers/3.txt
313            - data/numbers/4.txt
314            - data/numbers/5.txt
315
316    Scenario: :tab-focus next stacking
317        When I open data/numbers/1.txt
318        And I open data/numbers/2.txt in a new tab
319        And I open data/numbers/3.txt in a new tab
320        And I open data/numbers/4.txt in a new tab
321        And I open data/numbers/5.txt in a new tab
322        And I run :tab-focus 1
323        And I run :tab-focus 5
324        And I run :tab-focus 2
325        And I run :tab-focus 4
326        And I run :tab-focus 3
327        And I run :repeat 3 tab-focus stack-prev
328        And I run :repeat 2 tab-focus stack-next
329        Then the following tabs should be open:
330            - data/numbers/1.txt
331            - data/numbers/2.txt
332            - data/numbers/3.txt
333            - data/numbers/4.txt (active)
334            - data/numbers/5.txt
335
336    Scenario: :tab-focus stacking limit
337        When I set tabs.focus_stack_size to 1
338        And I open data/numbers/1.txt
339        And I open data/numbers/2.txt in a new tab
340        And I open data/numbers/3.txt in a new tab
341        And I open data/numbers/4.txt in a new tab
342        And I open data/numbers/5.txt in a new tab
343        And I run :repeat 2 tab-focus stack-prev
344        And I run :tab-focus stack-next
345        And I set tabs.focus_stack_size to 10
346        And I run :tab-focus 1
347        And I run :tab-focus 5
348        And I run :tab-focus 2
349        And I run :tab-focus 4
350        And I run :tab-focus 3
351        And I run :repeat 4 tab-focus stack-prev
352        Then the error "Could not find requested tab!" should be shown
353        And the following tabs should be open:
354            - data/numbers/1.txt (active)
355            - data/numbers/2.txt
356            - data/numbers/3.txt
357            - data/numbers/4.txt
358            - data/numbers/5.txt
359
360    Scenario: :tab-focus stacking and last
361        When I open data/numbers/1.txt
362        And I open data/numbers/2.txt in a new tab
363        And I open data/numbers/3.txt in a new tab
364        And I open data/numbers/4.txt in a new tab
365        And I open data/numbers/5.txt in a new tab
366        And I run :tab-focus 1
367        And I run :tab-focus 5
368        And I run :tab-focus 2
369        And I run :tab-focus 4
370        And I run :tab-focus 3
371        And I run :repeat 2 tab-focus stack-prev
372        And I run :repeat 3 tab-focus last
373        Then the following tabs should be open:
374            - data/numbers/1.txt
375            - data/numbers/2.txt
376            - data/numbers/3.txt
377            - data/numbers/4.txt (active)
378            - data/numbers/5.txt
379
380
381    Scenario: :tab-focus last after moving current tab
382        When I open data/numbers/1.txt
383        And I open data/numbers/2.txt in a new tab
384        And I open data/numbers/3.txt in a new tab
385        And I run :tab-move 2
386        And I run :tab-focus last
387        Then the following tabs should be open:
388            - data/numbers/1.txt
389            - data/numbers/3.txt
390            - data/numbers/2.txt (active)
391
392    Scenario: :tab-focus last after closing a lower number tab
393        When I open data/numbers/1.txt
394        And I open data/numbers/2.txt in a new tab
395        And I open data/numbers/3.txt in a new tab
396        And I run :tab-close with count 1
397        And I run :tab-focus last
398        Then the following tabs should be open:
399            - data/numbers/2.txt (active)
400            - data/numbers/3.txt
401
402    # tab-prev/tab-next
403
404    Scenario: :tab-prev
405        When I open data/numbers/1.txt
406        And I open data/numbers/2.txt in a new tab
407        And I run :tab-prev
408        Then the following tabs should be open:
409            - data/numbers/1.txt (active)
410            - data/numbers/2.txt
411
412    Scenario: :tab-next
413        When I open data/numbers/1.txt
414        And I open data/numbers/2.txt in a new tab
415        And I run :tab-focus 1
416        And I run :tab-next
417        Then the following tabs should be open:
418            - data/numbers/1.txt
419            - data/numbers/2.txt (active)
420
421    Scenario: :tab-prev with count
422        When I open data/numbers/1.txt
423        And I open data/numbers/2.txt in a new tab
424        And I open data/numbers/3.txt in a new tab
425        And I run :tab-prev with count 2
426        Then the following tabs should be open:
427            - data/numbers/1.txt (active)
428            - data/numbers/2.txt
429            - data/numbers/3.txt
430
431    Scenario: :tab-next with count
432        When I open data/numbers/1.txt
433        And I open data/numbers/2.txt in a new tab
434        And I open data/numbers/3.txt in a new tab
435        And I run :tab-focus 1
436        And I run :tab-next with count 2
437        Then the following tabs should be open:
438            - data/numbers/1.txt
439            - data/numbers/2.txt
440            - data/numbers/3.txt (active)
441
442    Scenario: :tab-prev on first tab without wrap
443        When I set tabs.wrap to false
444        And I open data/numbers/1.txt
445        And I run :tab-prev
446        Then "First tab" should be logged
447
448    Scenario: :tab-next with last tab without wrap
449        When I set tabs.wrap to false
450        And I open data/numbers/1.txt
451        And I run :tab-next
452        Then "Last tab" should be logged
453
454    Scenario: :tab-prev on first tab with wrap
455        When I set tabs.wrap to true
456        And I open data/numbers/1.txt
457        And I open data/numbers/2.txt in a new tab
458        And I open data/numbers/3.txt in a new tab
459        And I run :tab-focus 1
460        And I run :tab-prev
461        Then the following tabs should be open:
462            - data/numbers/1.txt
463            - data/numbers/2.txt
464            - data/numbers/3.txt (active)
465
466    Scenario: :tab-next with last tab with wrap
467        When I set tabs.wrap to true
468        And I open data/numbers/1.txt
469        And I open data/numbers/2.txt in a new tab
470        And I open data/numbers/3.txt in a new tab
471        And I run :tab-next
472        Then the following tabs should be open:
473            - data/numbers/1.txt (active)
474            - data/numbers/2.txt
475            - data/numbers/3.txt
476
477    Scenario: :tab-next with last tab, wrap and count
478        When I set tabs.wrap to true
479        And I open data/numbers/1.txt
480        And I open data/numbers/2.txt in a new tab
481        And I open data/numbers/3.txt in a new tab
482        And I run :tab-next with count 2
483        Then the following tabs should be open:
484            - data/numbers/1.txt
485            - data/numbers/2.txt (active)
486            - data/numbers/3.txt
487
488    # :tab-move
489
490    Scenario: :tab-move with absolute position.
491        When I open data/numbers/1.txt
492        And I open data/numbers/2.txt in a new tab
493        And I open data/numbers/3.txt in a new tab
494        And I run :tab-move
495        Then the following tabs should be open:
496            - data/numbers/3.txt (active)
497            - data/numbers/1.txt
498            - data/numbers/2.txt
499
500    Scenario: :tab-move with absolute position and count.
501        When I open data/numbers/1.txt
502        And I open data/numbers/2.txt in a new tab
503        And I open data/numbers/3.txt in a new tab
504        And I run :tab-move with count 2
505        Then the following tabs should be open:
506            - data/numbers/1.txt
507            - data/numbers/3.txt (active)
508            - data/numbers/2.txt
509
510    Scenario: :tab-move with absolute position and invalid count.
511        When I open data/numbers/1.txt
512        And I open data/numbers/2.txt in a new tab
513        And I open data/numbers/3.txt in a new tab
514        And I run :tab-move with count 23
515        Then the error "Can't move tab to position 23!" should be shown.
516        And the following tabs should be open:
517            - data/numbers/1.txt
518            - data/numbers/2.txt
519            - data/numbers/3.txt (active)
520
521    Scenario: :tab-move with index.
522        When I open data/numbers/1.txt
523        And I open data/numbers/2.txt in a new tab
524        And I open data/numbers/3.txt in a new tab
525        And I run :tab-move 2
526        Then the following tabs should be open:
527            - data/numbers/1.txt
528            - data/numbers/3.txt (active)
529            - data/numbers/2.txt
530
531    Scenario: :tab-move with negative index.
532        When I open data/numbers/1.txt
533        And I open data/numbers/2.txt in a new tab
534        And I open data/numbers/3.txt in a new tab
535        And I run :tab-move -3
536        Then the following tabs should be open:
537            - data/numbers/3.txt (active)
538            - data/numbers/1.txt
539            - data/numbers/2.txt
540
541    Scenario: :tab-move with invalid index.
542        When I open data/numbers/1.txt
543        And I open data/numbers/2.txt in a new tab
544        And I open data/numbers/3.txt in a new tab
545        And I run :tab-move -5
546        Then the error "Can't move tab to position -1!" should be shown.
547        And the following tabs should be open:
548            - data/numbers/1.txt
549            - data/numbers/2.txt
550            - data/numbers/3.txt (active)
551
552    Scenario: :tab-move with index and count.
553        When I open data/numbers/1.txt
554        And I open data/numbers/2.txt in a new tab
555        And I open data/numbers/3.txt in a new tab
556        And I run :tab-move 1 with count 2
557        Then the following tabs should be open:
558            - data/numbers/1.txt
559            - data/numbers/3.txt (active)
560            - data/numbers/2.txt
561
562    Scenario: :tab-move with index and invalid count.
563        When I open data/numbers/1.txt
564        And I open data/numbers/2.txt in a new tab
565        And I open data/numbers/3.txt in a new tab
566        And I run :tab-move -2 with count 4
567        Then the error "Can't move tab to position 4!" should be shown.
568        And the following tabs should be open:
569            - data/numbers/1.txt
570            - data/numbers/2.txt
571            - data/numbers/3.txt (active)
572
573    Scenario: :tab-move with relative position (negative).
574        When I open data/numbers/1.txt
575        And I open data/numbers/2.txt in a new tab
576        And I open data/numbers/3.txt in a new tab
577        And I run :tab-move -
578        Then the following tabs should be open:
579            - data/numbers/1.txt
580            - data/numbers/3.txt (active)
581            - data/numbers/2.txt
582
583    Scenario: :tab-move with relative position (positive).
584        When I open data/numbers/1.txt
585        And I open data/numbers/2.txt in a new tab
586        And I open data/numbers/3.txt in a new tab
587        And I run :tab-focus 1
588        And I run :tab-move +
589        Then the following tabs should be open:
590            - data/numbers/2.txt
591            - data/numbers/1.txt (active)
592            - data/numbers/3.txt
593
594    Scenario: :tab-move with relative position (negative) and count.
595        When I open data/numbers/1.txt
596        And I open data/numbers/2.txt in a new tab
597        And I open data/numbers/3.txt in a new tab
598        And I run :tab-move - with count 2
599        Then the following tabs should be open:
600            - data/numbers/3.txt (active)
601            - data/numbers/1.txt
602            - data/numbers/2.txt
603
604    Scenario: :tab-move with relative position and too big count.
605        When I set tabs.wrap to false
606        And I open data/numbers/1.txt
607        And I open data/numbers/2.txt in a new tab
608        And I open data/numbers/3.txt in a new tab
609        And I run :tab-focus 1
610        And I run :tab-move + with count 3
611        Then the error "Can't move tab to position 4!" should be shown
612
613    Scenario: :tab-move with relative position (positive) and wrap
614        When I set tabs.wrap to true
615        And I open data/numbers/1.txt
616        And I open data/numbers/2.txt in a new tab
617        And I open data/numbers/3.txt in a new tab
618        And I run :tab-move +
619        Then the following tabs should be open:
620            - data/numbers/3.txt (active)
621            - data/numbers/1.txt
622            - data/numbers/2.txt
623
624    Scenario: :tab-move with relative position (negative), wrap and count
625        When I set tabs.wrap to true
626        And I open data/numbers/1.txt
627        And I open data/numbers/2.txt in a new tab
628        And I open data/numbers/3.txt in a new tab
629        And I run :tab-focus 1
630        And I run :tab-move - with count 8
631        Then the following tabs should be open:
632            - data/numbers/2.txt
633            - data/numbers/1.txt (active)
634            - data/numbers/3.txt
635
636    Scenario: Make sure :tab-move retains metadata
637        When I open data/title.html
638        And I open data/hello.txt in a new tab
639        And I run :tab-focus 1
640        And I run :tab-move +
641        Then the session should look like:
642            windows:
643            - tabs:
644              - history:
645                - url: http://localhost:*/data/hello.txt
646              - active: true
647                history:
648                - url: about:blank
649                - url: http://localhost:*/data/title.html
650                  title: Test title
651
652    # :tab-clone
653
654    Scenario: :tab-clone with -b and -w
655        When I run :tab-clone -b -w
656        Then the error "Only one of -b/-w/-p can be given!" should be shown.
657
658    Scenario: Cloning a tab with history and title
659        When I open data/title.html
660        And I run :tab-clone
661        And I wait until data/title.html is loaded
662        Then the session should look like:
663            windows:
664            - tabs:
665              - history:
666                - url: about:blank
667                - url: http://localhost:*/data/title.html
668                  title: Test title
669              - active: true
670                history:
671                - url: about:blank
672                - url: http://localhost:*/data/title.html
673                  title: Test title
674
675    Scenario: Cloning zoom value
676        When I open data/hello.txt
677        And I run :zoom 120
678        And I run :tab-clone
679        And I wait until data/hello.txt is loaded
680        Then the session should look like:
681            windows:
682            - tabs:
683              - history:
684                - url: about:blank
685                - url: http://localhost:*/data/hello.txt
686                  zoom: 1.2
687              - active: true
688                history:
689                - url: about:blank
690                - url: http://localhost:*/data/hello.txt
691                  zoom: 1.2
692
693    Scenario: Cloning to background tab
694        When I open data/hello2.txt
695        And I run :tab-clone -b
696        And I wait until data/hello2.txt is loaded
697        Then the following tabs should be open:
698            - data/hello2.txt (active)
699            - data/hello2.txt
700
701    Scenario: Cloning to new window
702        When I open data/title.html
703        And I run :tab-clone -w
704        And I wait until data/title.html is loaded
705        Then the session should look like:
706            windows:
707            - tabs:
708              - active: true
709                history:
710                - url: about:blank
711                - url: http://localhost:*/data/title.html
712                  title: Test title
713            - tabs:
714              - active: true
715                history:
716                - url: about:blank
717                - url: http://localhost:*/data/title.html
718                  title: Test title
719
720    Scenario: Cloning with tabs_are_windows = true
721        When I open data/title.html
722        And I set tabs.tabs_are_windows to true
723        And I run :tab-clone
724        And I wait until data/title.html is loaded
725        Then the session should look like:
726            windows:
727            - tabs:
728              - active: true
729                history:
730                - url: about:blank
731                - url: http://localhost:*/data/title.html
732                  title: Test title
733            - tabs:
734              - active: true
735                history:
736                - url: about:blank
737                - url: http://localhost:*/data/title.html
738                  title: Test title
739
740    Scenario: Cloning to private window
741        When I open data/title.html
742        And I run :tab-clone -p
743        And I wait until data/title.html is loaded
744        Then the session should look like:
745            windows:
746            - tabs:
747              - active: true
748                history:
749                - url: about:blank
750                - url: http://localhost:*/data/title.html
751                  title: Test title
752            - private: true
753              tabs:
754              - active: true
755                history:
756                - url: about:blank
757                - url: http://localhost:*/data/title.html
758                  title: Test title
759
760    # https://github.com/qutebrowser/qutebrowser/issues/2289
761
762    @qtwebkit_skip
763    Scenario: Cloning a tab with a special URL
764        When I open chrome://gpu
765        And I run :tab-clone
766        Then no crash should happen
767
768    # :undo
769
770    Scenario: Undo without any closed tabs
771        Given I have a fresh instance
772        When I run :undo
773        Then the error "Nothing to undo (use :undo --window to reopen a closed window)" should be shown
774
775    Scenario: Undo closing a tab
776        When I open data/numbers/1.txt
777        And I run :tab-only
778        And I open data/numbers/2.txt in a new tab
779        And I open data/numbers/3.txt
780        And I run :tab-close
781        And I run :undo
782        And I wait until data/numbers/3.txt is loaded
783        Then the session should look like:
784            windows:
785            - tabs:
786              - history:
787                - url: about:blank
788                - url: http://localhost:*/data/numbers/1.txt
789              - active: true
790                history:
791                - url: http://localhost:*/data/numbers/2.txt
792                - url: http://localhost:*/data/numbers/3.txt
793
794    @qtwebengine_flaky
795    Scenario: Undo with auto-created last tab
796        When I open data/hello.txt
797        And I run :tab-only
798        And I set tabs.last_close to blank
799        And I run :tab-close
800        And I wait until about:blank is loaded
801        And I run :undo
802        And I wait until data/hello.txt is loaded
803        Then the following tabs should be open:
804            - data/hello.txt (active)
805
806    @qtwebengine_flaky
807    Scenario: Undo with auto-created last tab, with history
808        When I open data/hello.txt
809        And I open data/hello2.txt
810        And I run :tab-only
811        And I set tabs.last_close to blank
812        And I run :tab-close
813        And I wait until about:blank is loaded
814        And I run :undo
815        And I wait until data/hello2.txt is loaded
816        Then the following tabs should be open:
817            - data/hello2.txt (active)
818
819    Scenario: Undo with auto-created last tab (startpage)
820        When I open data/hello.txt
821        And I run :tab-only
822        And I set tabs.last_close to startpage
823        And I set url.start_pages to ["http://localhost:(port)/data/numbers/4.txt"]
824        And I run :tab-close
825        And I wait until data/numbers/4.txt is loaded
826        And I run :undo
827        And I wait until data/hello.txt is loaded
828        Then the following tabs should be open:
829            - data/hello.txt (active)
830
831    Scenario: Undo with auto-created last tab (default-page)
832        When I open data/hello.txt
833        And I run :tab-only
834        And I set tabs.last_close to default-page
835        And I set url.default_page to http://localhost:(port)/data/numbers/6.txt
836        And I run :tab-close
837        And I wait until data/numbers/6.txt is loaded
838        And I run :undo
839        And I wait until data/hello.txt is loaded
840        Then the following tabs should be open:
841            - data/hello.txt (active)
842
843    @skip  # Too flaky
844    Scenario: Double-undo with single tab on tabs.last_close default page
845        Given I have a fresh instance
846        When I open about:blank
847        And I set tabs.last_close to default-page
848        And I set url.default_page to about:blank
849        And I run :undo
850        And I run :undo
851        Then the error "Nothing to undo (use :undo --window to reopen a closed window)" should be shown
852        And the error "Nothing to undo (use :undo --window to reopen a closed window)" should be shown
853
854    Scenario: Undo a tab closed by index
855        When I open data/numbers/1.txt
856        And I open data/numbers/2.txt in a new tab
857        And I open data/numbers/3.txt in a new tab
858        And I run :tab-close with count 1
859        And I run :undo
860        Then the following tabs should be open:
861            - data/numbers/1.txt (active)
862            - data/numbers/2.txt
863            - data/numbers/3.txt
864
865    Scenario: Undo a tab closed after switching tabs
866        When I open data/numbers/1.txt
867        And I open data/numbers/2.txt in a new tab
868        And I open data/numbers/3.txt in a new tab
869        And I run :tab-close with count 1
870        And I run :tab-focus 2
871        And I run :undo
872        Then the following tabs should be open:
873            - data/numbers/1.txt (active)
874            - data/numbers/2.txt
875            - data/numbers/3.txt
876
877    Scenario: Undo a tab closed after rearranging tabs
878        When I open data/numbers/1.txt
879        And I open data/numbers/2.txt in a new tab
880        And I open data/numbers/3.txt in a new tab
881        And I run :tab-close with count 1
882        And I run :tab-move with count 1
883        And I run :undo
884        Then the following tabs should be open:
885            - data/numbers/1.txt (active)
886            - data/numbers/3.txt
887            - data/numbers/2.txt
888
889    @flaky
890    Scenario: Undo a tab closed after new tab opened
891        When I open data/numbers/1.txt
892        And I open data/numbers/2.txt in a new tab
893        And I run :tab-close with count 1
894        And I open data/numbers/3.txt in a new tab
895        And I run :undo
896        And I wait until data/numbers/1.txt is loaded
897        Then the following tabs should be open:
898            - data/numbers/1.txt (active)
899            - data/numbers/2.txt
900            - data/numbers/3.txt
901
902    Scenario: Undo the closing of tabs using :tab-only
903        When I open data/numbers/1.txt
904        And I open data/numbers/2.txt in a new tab
905        And I open data/numbers/3.txt in a new tab
906        And I run :tab-focus 2
907        And I run :tab-only
908        And I run :undo
909        Then the following tabs should be open:
910            - data/numbers/1.txt (active)
911            - data/numbers/2.txt
912            - data/numbers/3.txt
913
914    # :undo --window
915
916    Scenario: Undo the closing of a window
917        Given I clear the log
918        When I open data/numbers/1.txt
919        And I open data/numbers/2.txt in a new window
920        And I run :close
921        And I wait for "removed: tabbed-browser" in the log
922        And I run :undo -w
923        And I wait for "Focus object changed: *" in the log
924        Then the session should look like:
925            windows:
926            - tabs:
927              - active: true
928                history:
929                - url: about:blank
930                - url: http://localhost:*/data/numbers/1.txt
931            - active: true
932              tabs:
933              - active: true
934                history:
935                - url: http://localhost:*/data/numbers/2.txt
936
937    Scenario: Undo the closing of a window with multiple tabs
938        Given I clear the log
939        When I open data/numbers/1.txt
940        And I open data/numbers/2.txt in a new window
941        And I open data/numbers/3.txt in a new tab
942        And I run :close
943        And I wait for "removed: tabbed-browser" in the log
944        And I run :undo -w
945        And I wait for "Focus object changed: *" in the log
946        Then the session should look like:
947            windows:
948            - tabs:
949              - active: true
950                history:
951                - url: about:blank
952                - url: http://localhost:*/data/numbers/1.txt
953            - active: true
954              tabs:
955              - history:
956                - url: http://localhost:*/data/numbers/2.txt
957              - active: true
958                history:
959                - url: http://localhost:*/data/numbers/3.txt
960
961    Scenario: Undo the closing of a window with multiple tabs with undo stack
962        Given I clear the log
963        When I open data/numbers/1.txt
964        And I open data/numbers/2.txt in a new window
965        And I open data/numbers/3.txt in a new tab
966        And I run :tab-close
967        And I run :close
968        And I wait for "removed: tabbed-browser" in the log
969        And I run :undo -w
970        And I run :undo
971        And I wait for "Focus object changed: *" in the log
972        Then the session should look like:
973            windows:
974            - tabs:
975              - active: true
976                history:
977                - url: about:blank
978                - url: http://localhost:*/data/numbers/1.txt
979            - active: true
980              tabs:
981              - history:
982                - url: http://localhost:*/data/numbers/2.txt
983              - active: true
984                history:
985                - url: http://localhost:*/data/numbers/3.txt
986
987    Scenario: Undo the closing of a window with tabs are windows
988        Given I clear the log
989        When I set tabs.last_close to close
990        And I set tabs.tabs_are_windows to true
991        And I open data/numbers/1.txt
992        And I open data/numbers/2.txt in a new tab
993        And I run :tab-close
994        And I wait for "removed: tabbed-browser" in the log
995        And I run :undo -w
996        And I wait for "Focus object changed: *" in the log
997        Then the session should look like:
998            windows:
999            - tabs:
1000              - active: true
1001                history:
1002                - url: about:blank
1003                - url: http://localhost:*/data/numbers/1.txt
1004            - tabs:
1005              - active: true
1006                history:
1007                - url: http://localhost:*/data/numbers/2.txt
1008
1009    # :undo with count
1010
1011    Scenario: Undo the second to last closed tab
1012        When I open data/numbers/1.txt
1013        And I open data/numbers/2.txt in a new tab
1014        And I open data/numbers/3.txt in a new tab
1015        And I run :tab-close
1016        And I run :tab-close
1017        And I run :undo with count 2
1018        Then the following tabs should be open:
1019            - data/numbers/1.txt
1020            - data/numbers/3.txt (active)
1021
1022    Scenario: Undo with a too-high count
1023        When I open data/numbers/1.txt
1024        And I open data/numbers/2.txt in a new tab
1025        And I run :tab-close
1026        And I run :undo with count 100
1027        Then the error "Nothing to undo" should be shown
1028
1029    Scenario: Undo with --window and count
1030        When I run :undo --window with count 2
1031        Then the error ":undo --window does not support a count/depth" should be shown
1032
1033    Scenario: Undo with --window and depth
1034        When I run :undo --window 1
1035        Then the error ":undo --window does not support a count/depth" should be shown
1036
1037    # tabs.last_close
1038
1039    # FIXME:qtwebengine
1040    @qtwebengine_skip: Waits for an earlier about:blank and fails
1041    Scenario: tabs.last_close = blank
1042        When I open data/hello.txt
1043        And I set tabs.last_close to blank
1044        And I run :tab-only
1045        And I run :tab-close
1046        And I wait until about:blank is loaded
1047        Then the following tabs should be open:
1048            - about:blank (active)
1049
1050    Scenario: tabs.last_close = startpage
1051        When I set url.start_pages to ["http://localhost:(port)/data/numbers/7.txt", "http://localhost:(port)/data/numbers/8.txt"]
1052        And I set tabs.last_close to startpage
1053        And I open data/hello.txt
1054        And I run :tab-only
1055        And I run :tab-close
1056        And I wait until data/numbers/7.txt is loaded
1057        And I wait until data/numbers/8.txt is loaded
1058        Then the following tabs should be open:
1059            - data/numbers/7.txt
1060            - data/numbers/8.txt (active)
1061
1062    Scenario: tabs.last_close = default-page
1063        When I set url.default_page to http://localhost:(port)/data/numbers/9.txt
1064        And I set tabs.last_close to default-page
1065        And I open data/hello.txt
1066        And I run :tab-only
1067        And I run :tab-close
1068        And I wait until data/numbers/9.txt is loaded
1069        Then the following tabs should be open:
1070            - data/numbers/9.txt (active)
1071
1072    Scenario: tabs.last_close = close
1073        When I open data/hello.txt
1074        And I set tabs.last_close to close
1075        And I run :tab-only
1076        And I run :tab-close
1077        Then qutebrowser should quit
1078
1079    # tab settings
1080
1081    Scenario: opening links with tabs.background true
1082        When I set tabs.background to true
1083        And I open data/hints/html/simple.html
1084        And I hint with args "all tab" and follow a
1085        And I wait until data/hello.txt is loaded
1086        Then the following tabs should be open:
1087            - data/hints/html/simple.html (active)
1088            - data/hello.txt
1089
1090    Scenario: opening tab with tabs.new_position.related prev
1091        When I set tabs.new_position.related to prev
1092        And I set tabs.background to false
1093        And I open about:blank
1094        And I open data/hints/html/simple.html in a new tab
1095        And I run :click-element id link --target=tab
1096        And I wait until data/hello.txt is loaded
1097        Then the following tabs should be open:
1098            - about:blank
1099            - data/hello.txt (active)
1100            - data/hints/html/simple.html
1101
1102    Scenario: opening tab with tabs.new_position.related next
1103        When I set tabs.new_position.related to next
1104        And I set tabs.background to false
1105        And I open about:blank
1106        And I open data/hints/html/simple.html in a new tab
1107        And I run :click-element id link --target=tab
1108        And I wait until data/hello.txt is loaded
1109        Then the following tabs should be open:
1110            - about:blank
1111            - data/hints/html/simple.html
1112            - data/hello.txt (active)
1113
1114    Scenario: opening tab with tabs.new_position.related first
1115        When I set tabs.new_position.related to first
1116        And I set tabs.background to false
1117        And I open about:blank
1118        And I open data/hints/html/simple.html in a new tab
1119        And I run :click-element id link --target=tab
1120        And I wait until data/hello.txt is loaded
1121        Then the following tabs should be open:
1122            - data/hello.txt (active)
1123            - about:blank
1124            - data/hints/html/simple.html
1125
1126    Scenario: opening tab with tabs.new_position.related last
1127        When I set tabs.new_position.related to last
1128        And I set tabs.background to false
1129        And I open data/hints/html/simple.html
1130        And I open about:blank in a new tab
1131        And I run :tab-focus last
1132        And I run :click-element id link --target=tab
1133        And I wait until data/hello.txt is loaded
1134        Then the following tabs should be open:
1135            - data/hints/html/simple.html
1136            - about:blank
1137            - data/hello.txt (active)
1138
1139    # stacking tabs
1140    Scenario: stacking tabs opening tab with tabs.new_position.related next
1141        When I set tabs.new_position.related to next
1142        And I set tabs.new_position.stacking to true
1143        And I set tabs.background to true
1144        And I open about:blank
1145        And I open data/navigate/index.html in a new tab
1146        And I hint with args "all tab-bg" and follow a
1147        And I hint with args "all tab-bg" and follow s
1148        And I wait until data/navigate/prev.html is loaded
1149        And I wait until data/navigate/next.html is loaded
1150        Then the following tabs should be open:
1151            - about:blank
1152            - data/navigate/index.html (active)
1153            - data/navigate/prev.html
1154            - data/navigate/next.html
1155
1156    Scenario: stacking tabs opening tab with tabs.new_position.related prev
1157        When I set tabs.new_position.related to prev
1158        And I set tabs.new_position.stacking to true
1159        And I set tabs.background to true
1160        And I open about:blank
1161        And I open data/navigate/index.html in a new tab
1162        And I hint with args "all tab-bg" and follow a
1163        And I hint with args "all tab-bg" and follow s
1164        And I wait until data/navigate/prev.html is loaded
1165        And I wait until data/navigate/next.html is loaded
1166        Then the following tabs should be open:
1167            - about:blank
1168            - data/navigate/next.html
1169            - data/navigate/prev.html
1170            - data/navigate/index.html (active)
1171
1172    Scenario: no stacking tabs opening tab with tabs.new_position.related next
1173        When I set tabs.new_position.related to next
1174        And I set tabs.new_position.stacking to false
1175        And I set tabs.background to true
1176        And I open about:blank
1177        And I open data/navigate/index.html in a new tab
1178        And I hint with args "all tab-bg" and follow a
1179        And I hint with args "all tab-bg" and follow s
1180        And I wait until data/navigate/prev.html is loaded
1181        And I wait until data/navigate/next.html is loaded
1182        Then the following tabs should be open:
1183            - about:blank
1184            - data/navigate/index.html (active)
1185            - data/navigate/next.html
1186            - data/navigate/prev.html
1187
1188    Scenario: no stacking tabs opening tab with tabs.new_position.related prev
1189        When I set tabs.new_position.related to prev
1190        And I set tabs.new_position.stacking to false
1191        And I set tabs.background to true
1192        And I open about:blank
1193        And I open data/navigate/index.html in a new tab
1194        And I hint with args "all tab-bg" and follow a
1195        And I hint with args "all tab-bg" and follow s
1196        And I wait until data/navigate/prev.html is loaded
1197        And I wait until data/navigate/next.html is loaded
1198        Then the following tabs should be open:
1199            - about:blank
1200            - data/navigate/prev.html
1201            - data/navigate/next.html
1202            - data/navigate/index.html (active)
1203
1204    # :tab-select
1205
1206    Scenario: :tab-select without args or count
1207        When I run :tab-select
1208        Then qute://tabs should be loaded
1209
1210    Scenario: :tab-select with a matching title
1211        When I open data/title.html
1212        And I open data/search.html in a new tab
1213        And I open data/scroll/simple.html in a new tab
1214        And I run :tab-select Searching text
1215        And I wait for "Current tab changed, focusing <qutebrowser.browser.* tab_id=* url='http://localhost:*/data/search.html'>" in the log
1216        Then the following tabs should be open:
1217            - data/title.html
1218            - data/search.html (active)
1219            - data/scroll/simple.html
1220
1221    Scenario: :tab-select with no matching title
1222        When I run :tab-select invalid title
1223        Then the error "No matching tab for: invalid title" should be shown
1224
1225    @flaky
1226    Scenario: :tab-select with matching title and two windows
1227        When I open data/title.html
1228        And I open data/search.html in a new tab
1229        And I open data/scroll/simple.html in a new tab
1230        And I open data/caret.html in a new window
1231        And I open data/paste_primary.html in a new tab
1232        And I run :tab-select Scrolling
1233        And I wait for "Focus object changed: *" in the log
1234        Then the session should look like:
1235            windows:
1236            - active: true
1237              tabs:
1238              - history:
1239                - url: about:blank
1240                - url: http://localhost:*/data/title.html
1241              - history:
1242                - url: http://localhost:*/data/search.html
1243              - active: true
1244                history:
1245                - url: http://localhost:*/data/scroll/simple.html
1246            - tabs:
1247              - history:
1248                - url: http://localhost:*/data/caret.html
1249              - active: true
1250                history:
1251                - url: http://localhost:*/data/paste_primary.html
1252
1253    Scenario: :tab-select with no matching index
1254        When I open data/title.html
1255        And I run :tab-select 666
1256        Then the error "There's no tab with index 666!" should be shown
1257
1258    Scenario: :tab-select with no matching window index
1259        When I open data/title.html
1260        And I run :tab-select 99/1
1261        Then the error "There's no window with id 99!" should be shown
1262
1263    @skip   # Too flaky
1264    Scenario: :tab-select with matching window index
1265        Given I have a fresh instance
1266        When I open data/title.html
1267        And I open data/search.html in a new tab
1268        And I open data/scroll/simple.html in a new tab
1269        And I run :open -w http://localhost:(port)/data/caret.html
1270        And I open data/paste_primary.html in a new tab
1271        And I wait until data/caret.html is loaded
1272        And I run :tab-select 0/2
1273        And I wait for "Focus object changed: *" in the log
1274        Then the session should look like:
1275            windows:
1276            - active: true
1277              tabs:
1278              - history:
1279                - url: about:blank
1280                - url: http://localhost:*/data/title.html
1281              - active: true
1282                history:
1283                - url: http://localhost:*/data/search.html
1284              - history:
1285                - url: http://localhost:*/data/scroll/simple.html
1286            - tabs:
1287              - history:
1288                - url: http://localhost:*/data/caret.html
1289              - active: true
1290                history:
1291                - url: http://localhost:*/data/paste_primary.html
1292
1293    Scenario: :tab-select with wrong argument (-1)
1294        When I open data/title.html
1295        And I run :tab-select -1
1296        Then the error "There's no tab with index -1!" should be shown
1297
1298    Scenario: :tab-select with wrong argument (/)
1299        When I open data/title.html
1300        And I run :tab-select /
1301        Then the following tabs should be open:
1302            - data/title.html (active)
1303
1304    Scenario: :tab-select with wrong argument (//)
1305        When I open data/title.html
1306        And I run :tab-select //
1307        Then the following tabs should be open:
1308            - data/title.html (active)
1309
1310    Scenario: :tab-select with wrong argument (0/x)
1311        When I open data/title.html
1312        And I run :tab-select 0/x
1313        Then the error "No matching tab for: 0/x" should be shown
1314
1315    Scenario: :tab-select with wrong argument (1/2/3)
1316        When I open data/title.html
1317        And I run :tab-select 1/2/3
1318        Then the error "No matching tab for: 1/2/3" should be shown
1319
1320    # :tab-take
1321
1322    @xfail_norun  # Needs qutewm
1323    Scenario: Take a tab from another window
1324        Given I have a fresh instance
1325        When I open data/numbers/1.txt
1326        And I open data/numbers/2.txt in a new window
1327        And I run :tab-take 0/1
1328        Then the session should look like:
1329            windows:
1330            - tabs:
1331              - history:
1332                - url: about:blank
1333            - tabs:
1334              - history:
1335                - url: http://localhost:*/data/numbers/2.txt
1336              - history:
1337                - url: http://localhost:*/data/numbers/1.txt
1338
1339    Scenario: Take a tab from the same window
1340        Given I have a fresh instance
1341        When I open data/numbers/1.txt
1342        And I run :tab-take 0/1
1343        Then the error "Can't take a tab from the same window" should be shown
1344
1345    Scenario: Take a tab while using tabs_are_windows
1346        When I open data/numbers/1.txt
1347        And I open data/numbers/2.txt in a new window
1348        And I set tabs.tabs_are_windows to true
1349        And I run :tab-take 0/1
1350        Then the error "Can't take tabs when using windows as tabs" should be shown
1351
1352    # :tab-give
1353
1354    @xfail_norun  # Needs qutewm
1355    Scenario: Give a tab to another window
1356        Given I have a fresh instance
1357        When I open data/numbers/1.txt
1358        And I open data/numbers/2.txt in a new window
1359        And I run :tab-give 0
1360        Then the session should look like:
1361            windows:
1362            - tabs:
1363              - history:
1364                - url: http://localhost:*/data/numbers/1.txt
1365              - history:
1366                - url: http://localhost:*/data/numbers/2.txt
1367            - tabs:
1368              - history:
1369                - url: about:blank
1370
1371    Scenario: Give a tab to the same window
1372        Given I have a fresh instance
1373        When I open data/numbers/1.txt
1374        And I run :tab-give 0
1375        Then the error "Can't give a tab to the same window" should be shown
1376
1377    Scenario: Give a tab to a new window
1378        When I open data/numbers/1.txt
1379        And I open data/numbers/2.txt in a new tab
1380        And I run :tab-give
1381        And I wait until data/numbers/2.txt is loaded
1382        Then the session should look like:
1383            windows:
1384            - tabs:
1385              - history:
1386                - url: about:blank
1387                - url: http://localhost:*/data/numbers/1.txt
1388            - tabs:
1389              - history:
1390                - url: http://localhost:*/data/numbers/2.txt
1391
1392    Scenario: Give a tab from window with only one tab
1393        When I open data/hello.txt
1394        And I run :tab-give
1395        Then the error "Cannot detach from a window with only one tab" should be shown
1396
1397    Scenario: Give a tab to a window ID that does not exist
1398        When I open data/hello.txt
1399        And I run :tab-give 99
1400        Then the error "There's no window with id 99!" should be shown
1401
1402    Scenario: Give a tab while using tabs_are_windows
1403        When I open data/numbers/1.txt
1404        And I open data/numbers/2.txt in a new window
1405        And I set tabs.tabs_are_windows to true
1406        And I run :tab-give 0
1407        Then the error "Can't give tabs when using windows as tabs" should be shown
1408
1409    # Other
1410
1411    Scenario: Using :tab-next after closing last tab (#1448)
1412        When I set tabs.last_close to close
1413        And I run :tab-only
1414        And I run :tab-close ;; tab-next
1415        Then qutebrowser should quit
1416        And no crash should happen
1417
1418    Scenario: Using :tab-prev after closing last tab (#1448)
1419        When I set tabs.last_close to close
1420        And I run :tab-only
1421        And I run :tab-close ;; tab-prev
1422        Then qutebrowser should quit
1423        And no crash should happen
1424
1425    Scenario: Opening link with tabs_are_windows set (#2162)
1426        When I set tabs.tabs_are_windows to true
1427        And I open data/hints/html/simple.html
1428        And I hint with args "all tab-fg" and follow a
1429        And I wait until data/hello.txt is loaded
1430        Then the session should look like:
1431            windows:
1432            - tabs:
1433              - history:
1434                - url: about:blank
1435                - url: http://localhost:*/data/hints/html/simple.html
1436            - tabs:
1437              - history:
1438                - url: http://localhost:*/data/hello.txt
1439
1440    Scenario: Closing tab with tabs_are_windows
1441        When I set tabs.tabs_are_windows to true
1442        And I set tabs.last_close to ignore
1443        And I open data/numbers/1.txt
1444        And I open data/numbers/2.txt in a new tab
1445        And I run :tab-close
1446        And I wait for "removed: tabbed-browser" in the log
1447        Then the session should look like:
1448            windows:
1449            - tabs:
1450              - active: true
1451                history:
1452                - url: about:blank
1453                - url: http://localhost:*/data/numbers/1.txt
1454
1455    # :tab-pin
1456
1457    Scenario: :tab-pin command
1458        When I open data/numbers/1.txt
1459        And I open data/numbers/2.txt in a new tab
1460        And I open data/numbers/3.txt in a new tab
1461        And I run :tab-pin
1462        Then the following tabs should be open:
1463            - data/numbers/1.txt
1464            - data/numbers/2.txt
1465            - data/numbers/3.txt (active) (pinned)
1466
1467    Scenario: :tab-pin unpin
1468        When I open data/numbers/1.txt
1469        And I run :tab-pin
1470        And I open data/numbers/2.txt in a new tab
1471        And I open data/numbers/3.txt in a new tab
1472        And I run :tab-pin
1473        And I run :tab-pin
1474        Then the following tabs should be open:
1475            - data/numbers/1.txt (pinned)
1476            - data/numbers/2.txt
1477            - data/numbers/3.txt (active)
1478
1479    Scenario: :tab-pin to index 2
1480        When I open data/numbers/1.txt
1481        And I open data/numbers/2.txt in a new tab
1482        And I open data/numbers/3.txt in a new tab
1483        And I run :tab-pin with count 2
1484        Then the following tabs should be open:
1485            - data/numbers/1.txt
1486            - data/numbers/2.txt (pinned)
1487            - data/numbers/3.txt (active)
1488
1489    Scenario: :tab-pin with an invalid count
1490        When I open data/numbers/1.txt
1491        And I open data/numbers/2.txt in a new tab
1492        And I open data/numbers/3.txt in a new tab
1493        And I run :tab-pin with count 23
1494        Then the following tabs should be open:
1495            - data/numbers/1.txt
1496            - data/numbers/2.txt
1497            - data/numbers/3.txt (active)
1498
1499    Scenario: Pinned :tab-close prompt yes
1500        When I open data/numbers/1.txt
1501        And I run :tab-pin
1502        And I open data/numbers/2.txt in a new tab
1503        And I run :tab-pin
1504        And I run :tab-close
1505        And I wait for "*want to close a pinned tab*" in the log
1506        And I run :prompt-accept yes
1507        Then the following tabs should be open:
1508            - data/numbers/1.txt (active) (pinned)
1509
1510    Scenario: Pinned :tab-close prompt no
1511        When I open data/numbers/1.txt
1512        And I run :tab-pin
1513        And I open data/numbers/2.txt in a new tab
1514        And I run :tab-pin
1515        And I run :tab-close
1516        And I wait for "*want to close a pinned tab*" in the log
1517        And I run :prompt-accept no
1518        Then the following tabs should be open:
1519            - data/numbers/1.txt (pinned)
1520            - data/numbers/2.txt (active) (pinned)
1521
1522    Scenario: Pinned :tab-only prompt yes
1523        When I open data/numbers/1.txt
1524        And I run :tab-pin
1525        And I open data/numbers/2.txt in a new tab
1526        And I run :tab-pin
1527        And I run :tab-next
1528        And I run :tab-only
1529        And I wait for "*want to close pinned tabs*" in the log
1530        And I run :prompt-accept yes
1531        Then the following tabs should be open:
1532            - data/numbers/1.txt (active) (pinned)
1533
1534    Scenario: Pinned :tab-only prompt no
1535        When I open data/numbers/1.txt
1536        And I run :tab-pin
1537        And I open data/numbers/2.txt in a new tab
1538        And I run :tab-pin
1539        And I run :tab-next
1540        And I run :tab-only
1541        And I wait for "*want to close pinned tabs*" in the log
1542        And I run :prompt-accept no
1543        Then the following tabs should be open:
1544            - data/numbers/1.txt (active) (pinned)
1545            - data/numbers/2.txt (pinned)
1546
1547    Scenario: Pinned :tab-only close all but pinned tab
1548        When I open data/numbers/1.txt
1549        And I open data/numbers/2.txt in a new tab
1550        And I run :tab-pin
1551        And I run :tab-only
1552        Then the following tabs should be open:
1553            - data/numbers/2.txt (active) (pinned)
1554
1555    Scenario: Pinned :tab-only --pinned close
1556        When I open data/numbers/1.txt
1557        And I run :tab-pin
1558        And I open data/numbers/2.txt in a new tab
1559        And I run :tab-pin
1560        And I run :tab-next
1561        And I run :tab-only --pinned close
1562        Then the following tabs should be open:
1563            - data/numbers/1.txt (active) (pinned)
1564
1565    Scenario: Pinned :tab-only --pinned keep
1566        When I open data/numbers/1.txt
1567        And I run :tab-pin
1568        And I open data/numbers/2.txt in a new tab
1569        And I run :tab-pin
1570        And I run :tab-next
1571        And I run :tab-only --pinned keep
1572        Then the following tabs should be open:
1573            - data/numbers/1.txt (active) (pinned)
1574            - data/numbers/2.txt (pinned)
1575
1576    Scenario: Pinned :tab-only --pinned prompt
1577        When I open data/numbers/1.txt
1578        And I run :tab-pin
1579        And I open data/numbers/2.txt in a new tab
1580        And I run :tab-pin
1581        And I run :tab-next
1582        And I run :tab-only --pinned prompt
1583        Then "*want to close pinned tabs*" should be logged
1584
1585    Scenario: :tab-pin open url
1586        When I open data/numbers/1.txt
1587        And I run :tab-pin
1588        And I open data/numbers/2.txt
1589        Then the message "Tab is pinned! Opening in new tab." should be shown
1590        And the following tabs should be open:
1591            - data/numbers/1.txt (active) (pinned)
1592            - data/numbers/2.txt
1593
1594    Scenario: :tab-pin open url with tabs.pinned.frozen = false
1595        When I set tabs.pinned.frozen to false
1596        And I open data/numbers/1.txt
1597        And I run :tab-pin
1598        And I open data/numbers/2.txt
1599        Then the following tabs should be open:
1600            - data/numbers/2.txt (active) (pinned)
1601
1602    Scenario: :home on a pinned tab
1603        When I open data/numbers/1.txt
1604        And I run :tab-pin
1605        And I run :home
1606        Then the message "Tab is pinned!" should be shown
1607        And the following tabs should be open:
1608            - data/numbers/1.txt (active) (pinned)
1609
1610    Scenario: :home on a pinned tab with tabs.pinned.frozen = false
1611        When I set url.start_pages to ["http://localhost:(port)/data/numbers/2.txt"]
1612        And I set tabs.pinned.frozen to false
1613        And I open data/numbers/1.txt
1614        And I run :tab-pin
1615        And I run :home
1616        Then data/numbers/2.txt should be loaded
1617        And the following tabs should be open:
1618            - data/numbers/2.txt (active) (pinned)
1619
1620    Scenario: Cloning a pinned tab
1621        When I open data/numbers/1.txt
1622        And I run :tab-pin
1623        And I run :tab-clone
1624        And I wait until data/numbers/1.txt is loaded
1625        Then the following tabs should be open:
1626            - data/numbers/1.txt (pinned)
1627            - data/numbers/1.txt (pinned) (active)
1628
1629    Scenario: Undo a pinned tab
1630        When I open data/numbers/1.txt
1631        And I open data/numbers/2.txt in a new tab
1632        And I run :tab-pin
1633        And I run :tab-close --force
1634        And I run :undo
1635        And I wait until data/numbers/2.txt is loaded
1636        Then the following tabs should be open:
1637            - data/numbers/1.txt
1638            - data/numbers/2.txt (pinned) (active)
1639
1640
1641    Scenario: Focused webview after clicking link in bg
1642        When I open data/hints/link_input.html
1643        And I run :click-element id qute-input-existing
1644        And I wait for "Entering mode KeyMode.insert *" in the log
1645        And I run :mode-leave
1646        And I hint with args "all tab-bg" and follow a
1647        And I wait until data/hello.txt is loaded
1648        And I run :mode-enter insert
1649        And I run :fake-key -g new
1650        Then the javascript message "contents: existingnew" should be logged
1651
1652    Scenario: Focused webview after opening link in bg
1653        When I open data/hints/link_input.html
1654        And I run :click-element id qute-input-existing
1655        And I wait for "Entering mode KeyMode.insert *" in the log
1656        And I run :mode-leave
1657        And I open data/hello.txt in a new background tab
1658        And I run :mode-enter insert
1659        And I run :fake-key -g new
1660        Then the javascript message "contents: existingnew" should be logged
1661
1662    @skip  # Too flaky
1663    Scenario: Focused prompt after opening link in bg
1664        When I open data/hints/link_input.html
1665        When I run :set-cmd-text -s :message-info
1666        And I open data/hello.txt in a new background tab
1667        And I run :fake-key -g hello-world<enter>
1668        Then the message "hello-world" should be shown
1669
1670    @skip  # Too flaky
1671    Scenario: Focused prompt after opening link in fg
1672        When I open data/hints/link_input.html
1673        When I run :set-cmd-text -s :message-info
1674        And I open data/hello.txt in a new tab
1675        And I run :fake-key -g hello-world<enter>
1676        Then the message "hello-world" should be shown
1677
1678    Scenario: Undo after changing tabs_are_windows
1679        When I open data/hello.txt
1680        And I open data/hello.txt in a new tab
1681        And I set tabs.tabs_are_windows to true
1682        And I run :tab-close
1683        And I run :undo
1684        And I run :message-info "Still alive!"
1685        Then the message "Still alive!" should be shown
1686