summaryrefslogtreecommitdiff
path: root/tests/end2end/features/search.feature
blob: 305b4569010d1fe8e1c4db2aa62e64f691b71315 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# vim: ft=cucumber fileencoding=utf-8 sts=4 sw=4 et:

Feature: Searching on a page
    Searching text on the page (like /foo) with different options.

    Background:
        Given I open data/search.html
        And I run :tab-only

    ## searching

    Scenario: Searching text
        When I run :search foo
        And I wait for "search found foo" in the log
        Then "foo" should be found

    Scenario: Searching twice
        When I run :search foo
        And I wait for "search found foo" in the log
        And I run :search bar
        And I wait for "search found bar" in the log
        Then "Bar" should be found

    Scenario: Searching with --reverse
        When I set search.ignore_case to always
        And I run :search -r foo
        And I wait for "search found foo with flags FindBackward" in the log
        Then "Foo" should be found

    Scenario: Searching without matches
        When I run :search doesnotmatch
        And I wait for "search didn't find doesnotmatch" in the log
        Then the warning "Text 'doesnotmatch' not found on page!" should be shown

    @xfail_norun
    Scenario: Searching with / and spaces at the end (issue 874)
        When I run :set-cmd-text -s /space
        And I run :command-accept
        And I wait for "search found space " in the log
        Then "space " should be found

    Scenario: Searching with / and slash in search term (issue 507)
        When I run :set-cmd-text //slash
        And I run :command-accept
        And I wait for "search found /slash" in the log
        Then "/slash" should be found

    Scenario: Searching with arguments at start of search term
        When I run :set-cmd-text /-r reversed
        And I run :command-accept
        And I wait for "search found -r reversed" in the log
        Then "-r reversed" should be found

    Scenario: Searching with semicolons in search term
        When I run :set-cmd-text /;
        And I run :fake-key -g ;
        And I run :fake-key -g <space>
        And I run :fake-key -g semi
        And I run :command-accept
        And I wait for "search found ;; semi" in the log
        Then ";; semi" should be found

    # This doesn't work because this is QtWebKit behavior.
    @xfail_norun
    Scenario: Searching text with umlauts
        When I run :search blub
        And I wait for "search didn't find blub" in the log
        Then the warning "Text 'blub' not found on page!" should be shown

    Scenario: Searching text duplicates
        When I run :search foo
        And I wait for "search found foo" in the log
        And I run :search foo
        Then "Ignoring duplicate search request for foo, but resetting flags" should be logged

    Scenario: Reset search direction on duplicate search, forward-to-back
        When I run :search baz
        And I wait for "search found baz" in the log
        And I run :search -r baz
        And I wait for "Ignoring duplicate search request for baz, but resetting flags" in the log
        And I run :search-next
        And I wait for "next_result found baz with flags FindBackward" in the log
        Then "BAZ" should be found

    Scenario: Reset search direction on duplicate search, back-to-forward
        When I run :search -r baz
        And I wait for "search found baz with flags FindBackward" in the log
        And I run :search baz
        And I wait for "Ignoring duplicate search request for baz, but resetting flags" in the log
        And I run :search-next
        And I wait for "next_result found baz" in the log
        Then "baz" should be found

    ## search.ignore_case

    Scenario: Searching text with search.ignore_case = always
        When I set search.ignore_case to always
        And I run :search bar
        And I wait for "search found bar" in the log
        Then "Bar" should be found

    Scenario: Searching text with search.ignore_case = never
        When I set search.ignore_case to never
        And I run :search bar
        And I wait for "search found bar with flags FindCaseSensitively" in the log
        Then "bar" should be found

    Scenario: Searching text with search.ignore_case = smart (lower-case)
        When I set search.ignore_case to smart
        And I run :search bar
        And I wait for "search found bar" in the log
        Then "Bar" should be found

    Scenario: Searching text with search.ignore_case = smart (upper-case)
        When I set search.ignore_case to smart
        And I run :search Foo
        And I wait for "search found Foo with flags FindCaseSensitively" in the log
        Then "Foo" should be found  # even though foo was first

    ## :search-next

    Scenario: Jumping to next match
        When I set search.ignore_case to always
        And I run :search foo
        And I wait for "search found foo" in the log
        And I run :search-next
        And I wait for "next_result found foo" in the log
        Then "Foo" should be found

    Scenario: Jumping to next match with count
        When I set search.ignore_case to always
        And I run :search baz
        And I wait for "search found baz" in the log
        And I run :search-next with count 2
        And I wait for "next_result found baz" in the log
        Then "BAZ" should be found

    Scenario: Jumping to next match with --reverse
        When I set search.ignore_case to always
        And I run :search --reverse foo
        And I wait for "search found foo with flags FindBackward" in the log
        And I run :search-next
        And I wait for "next_result found foo with flags FindBackward" in the log
        Then "foo" should be found

    Scenario: Jumping to next match without search
        # Make sure there was no search in the same window before
        When I open data/search.html in a new window
        And I run :search-next
        Then the error "No search done yet." should be shown

    Scenario: Repeating search in a second tab (issue #940)
        When I open data/search.html in a new tab
        And I run :search foo
        And I wait for "search found foo" in the log
        And I run :tab-prev
        And I run :search-next
        And I wait for "search found foo" in the log
        Then "foo" should be found

    # https://github.com/qutebrowser/qutebrowser/issues/2438
    Scenario: Jumping to next match after clearing
        When I set search.ignore_case to always
        And I run :search foo
        And I wait for "search found foo" in the log
        And I run :search
        And I run :search-next
        And I wait for "next_result found foo" in the log
        Then "foo" should be found

    ## :search-prev

    Scenario: Jumping to previous match
        When I set search.ignore_case to always
        And I run :search foo
        And I wait for "search found foo" in the log
        And I run :search-next
        And I wait for "next_result found foo" in the log
        And I run :search-prev
        And I wait for "prev_result found foo with flags FindBackward" in the log
        Then "foo" should be found

    Scenario: Jumping to previous match with count
        When I set search.ignore_case to always
        And I run :search baz
        And I wait for "search found baz" in the log
        And I run :search-next
        And I wait for "next_result found baz" in the log
        And I run :search-next
        And I wait for "next_result found baz" in the log
        And I run :search-prev with count 2
        And I wait for "prev_result found baz with flags FindBackward" in the log
        Then "baz" should be found

    Scenario: Jumping to previous match with --reverse
        When I set search.ignore_case to always
        And I run :search --reverse foo
        And I wait for "search found foo with flags FindBackward" in the log
        And I run :search-next
        And I wait for "next_result found foo with flags FindBackward" in the log
        And I run :search-prev
        And I wait for "prev_result found foo" in the log
        Then "Foo" should be found

    Scenario: Jumping to previous match without search
        # Make sure there was no search in the same window before
        When I open data/search.html in a new window
        And I run :search-prev
        Then the error "No search done yet." should be shown

    ## wrapping

    Scenario: Wrapping around page
        When I run :search foo
        And I wait for "search found foo" in the log
        And I run :search-next
        And I wait for "next_result found foo" in the log
        And I run :search-next
        And I wait for "next_result found foo" in the log
        Then "foo" should be found

    Scenario: Wrapping around page with --reverse
        When I run :search --reverse foo
        And I wait for "search found foo with flags FindBackward" in the log
        And I run :search-next
        And I wait for "next_result found foo with flags FindBackward" in the log
        And I run :search-next
        And I wait for "next_result found foo with flags FindBackward" in the log
        Then "Foo" should be found

    # TODO: wrapping message with scrolling
    # TODO: wrapping message without scrolling

    ## wrapping prevented

    @qtwebkit_skip @qt>=5.14
    Scenario: Preventing wrapping at the top of the page with QtWebEngine
        When I set search.ignore_case to always
        And I set search.wrap to false
        And I run :search --reverse foo
        And I wait for "search found foo with flags FindBackward" in the log
        And I run :search-next
        And I wait for "next_result found foo with flags FindBackward" in the log
        And I run :search-next
        And I wait for "Search hit TOP" in the log
        Then "foo" should be found

    @qtwebkit_skip @qt>=5.14
    Scenario: Preventing wrapping at the bottom of the page with QtWebEngine
        When I set search.ignore_case to always
        And I set search.wrap to false
        And I run :search foo
        And I wait for "search found foo" in the log
        And I run :search-next
        And I wait for "next_result found foo" in the log
        And I run :search-next
        And I wait for "Search hit BOTTOM" in the log
        Then "Foo" should be found

    @qtwebengine_skip
    Scenario: Preventing wrapping at the top of the page with QtWebKit
        When I set search.ignore_case to always
        And I set search.wrap to false
        And I run :search --reverse foo
        And I wait for "search found foo with flags FindBackward" in the log
        And I run :search-next
        And I wait for "next_result found foo with flags FindBackward" in the log
        And I run :search-next
        And I wait for "next_result didn't find foo with flags FindBackward" in the log
        Then the warning "Text 'foo' not found on page!" should be shown

    @qtwebengine_skip
    Scenario: Preventing wrapping at the bottom of the page with QtWebKit
        When I set search.ignore_case to always
        And I set search.wrap to false
        And I run :search foo
        And I wait for "search found foo" in the log
        And I run :search-next
        And I wait for "next_result found foo" in the log
        And I run :search-next
        And I wait for "next_result didn't find foo" in the log
        Then the warning "Text 'foo' not found on page!" should be shown

    ## follow searched links
    @skip  # Too flaky
    Scenario: Follow a searched link
        When I run :search follow
        And I wait for "search found follow" in the log
        And I wait 0.5s
        And I run :selection-follow
        Then data/hello.txt should be loaded

    @skip  # Too flaky
    Scenario: Follow a searched link in a new tab
        When I run :window-only
        And I run :search follow
        And I wait for "search found follow" in the log
        And I wait 0.5s
        And I run :selection-follow -t
        And I wait until data/hello.txt is loaded
        Then the following tabs should be open:
            - data/search.html
            - data/hello.txt (active)

    Scenario: Don't follow searched text
        When I run :window-only
        And I run :search foo
        And I wait for "search found foo" in the log
        And I run :selection-follow
        Then the following tabs should be open:
            - data/search.html (active)

    Scenario: Don't follow searched text in a new tab
        When I run :window-only
        And I run :search foo
        And I wait for "search found foo" in the log
        And I run :selection-follow -t
        Then the following tabs should be open:
            - data/search.html (active)

    Scenario: Follow a manually selected link
        When I run :jseval --file (testdata)/search_select.js
        And I run :selection-follow
        Then data/hello.txt should be loaded

    Scenario: Follow a manually selected link in a new tab
        When I run :window-only
        And I run :jseval --file (testdata)/search_select.js
        And I run :selection-follow -t
        And I wait until data/hello.txt is loaded
        Then the following tabs should be open:
            - data/search.html
            - data/hello.txt (active)

    # Too flaky
    @qtwebkit_skip: Not supported in qtwebkit @skip
    Scenario: Follow a searched link in an iframe
        When I open data/iframe_search.html
        And I run :tab-only
        And I run :search follow
        And I wait for "search found follow" in the log
        And I run :selection-follow
        Then "navigation request: url http://localhost:*/data/hello.txt, type Type.link_clicked, is_main_frame False" should be logged

    # Too flaky
    @qtwebkit_skip: Not supported in qtwebkit @skip
    Scenario: Follow a tabbed searched link in an iframe
        When I open data/iframe_search.html
        And I run :tab-only
        And I run :search follow
        And I wait for "search found follow" in the log
        And I run :selection-follow -t
        And I wait until data/hello.txt is loaded
        Then the following tabs should be open:
            - data/iframe_search.html
            - data/hello.txt (active)

    Scenario: Closing a tab during a search
        When I run :open -b about:blank
        And I run :search a
        And I run :tab-close
        Then no crash should happen