summaryrefslogtreecommitdiff
path: root/tests/integration/features/yankpaste.feature
blob: 58ae304b0234d59e6273a2b41b4eed4f7b963c2e (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
Feature: Yanking and pasting.
    :yank and :paste can be used to copy/paste the URL or title from/to the
    clipboard and primary selection.

    Background:
        Given I run :tab-only

    #### :yank

    Scenario: Yanking URLs to clipboard
        When I open data/title.html
        And I run :yank
        Then the message "Yanked URL to clipboard: http://localhost:(port)/data/title.html" should be shown
        And the clipboard should contain "http://localhost:(port)/data/title.html"

    Scenario: Yanking URLs to primary selection
        When selection is supported
        And I open data/title.html
        And I run :yank --sel
        Then the message "Yanked URL to primary selection: http://localhost:(port)/data/title.html" should be shown
        And the primary selection should contain "http://localhost:(port)/data/title.html"

    Scenario: Yanking title to clipboard
        When I open data/title.html
        And I wait for regex "Changing title for idx \d to 'Test title'" in the log
        And I run :yank --title
        Then the message "Yanked title to clipboard: Test title" should be shown
        And the clipboard should contain "Test title"

    Scenario: Yanking domain to clipboard
        When I open data/title.html
        And I run :yank --domain
        Then the message "Yanked domain to clipboard: http://localhost:(port)" should be shown
        And the clipboard should contain "http://localhost:(port)"

    Scenario: Yanking fully encoded URL
        When I open data/title with spaces.html
        And I run :yank
        Then the message "Yanked URL to clipboard: http://localhost:(port)/data/title%20with%20spaces.html" should be shown
        And the clipboard should contain "http://localhost:(port)/data/title%20with%20spaces.html"

    Scenario: Yanking pretty decoded URL
        When I open data/title with spaces.html
        And I run :yank --pretty
        Then the message "Yanked URL to clipboard: http://localhost:(port)/data/title with spaces.html" should be shown
        And the clipboard should contain "http://localhost:(port)/data/title with spaces.html"

    #### :paste

    Scenario: Pasting an URL
        When I put "http://localhost:(port)/data/hello.txt" into the clipboard
        And I run :paste
        And I wait until data/hello.txt is loaded
        Then the requests should be:
            data/hello.txt

    Scenario: Pasting an URL from primary selection
        When selection is supported
        And I put "http://localhost:(port)/data/hello2.txt" into the primary selection
        And I run :paste --sel
        And I wait until data/hello2.txt is loaded
        Then the requests should be:
            data/hello2.txt

    Scenario: Pasting with empty clipboard
        When I put "" into the clipboard
        And I run :paste
        Then the error "Clipboard is empty." should be shown

    Scenario: Pasting with empty selection
        When selection is supported
        And I put "" into the primary selection
        And I run :paste --sel
        Then the error "Primary selection is empty." should be shown

    Scenario: Pasting with a space in clipboard
        When I put " " into the clipboard
        And I run :paste
        Then the error "Clipboard is empty." should be shown

    Scenario: Pasting in a new tab
        Given I open about:blank
        When I run :tab-only
        And I put "http://localhost:(port)/data/hello.txt" into the clipboard
        And I run :paste -t
        And I wait until data/hello.txt is loaded
        Then the following tabs should be open:
            - about:blank
            - data/hello.txt (active)

    Scenario: Pasting in a background tab
        Given I open about:blank
        When I run :tab-only
        And I put "http://localhost:(port)/data/hello.txt" into the clipboard
        And I run :paste -b
        And I wait until data/hello.txt is loaded
        Then the following tabs should be open:
            - about:blank (active)
            - data/hello.txt

    Scenario: Pasting in a new window
        Given I have a fresh instance
        When I put "http://localhost:(port)/data/hello.txt" into the clipboard
        And I run :paste -w
        And I wait until data/hello.txt is loaded
        Then the session should look like:
            windows:
            - tabs:
              - active: true
                history:
                - active: true
                  url: about:blank
            - tabs:
              - active: true
                history:
                - active: true
                  url: http://localhost:*/data/hello.txt

    Scenario: Pasting an invalid URL
        When I set general -> auto-search to false
        And I put "foo bar" into the clipboard
        And I run :paste
        Then the error "Invalid URL" should be shown

    Scenario: Pasting multiple urls in a new tab
        Given I have a fresh instance
        When I put the following lines into the clipboard:
            http://localhost:(port)/data/hello.txt
            http://localhost:(port)/data/hello2.txt
            http://localhost:(port)/data/hello3.txt
        And I run :paste -t
        And I wait until data/hello.txt is loaded
        And I wait until data/hello2.txt is loaded
        And I wait until data/hello3.txt is loaded
        Then the following tabs should be open:
            - about:blank
            - data/hello.txt (active)
            - data/hello2.txt
            - data/hello3.txt

    Scenario: Pasting multiline text
        Given I have a fresh instance
        When I set searchengines -> DEFAULT to http://localhost:(port)/data/hello.txt?q={}
        And I put the following lines into the clipboard:
            this url:
            http://qutebrowser.org
            should not open
        And I run :paste -t
        And I wait until data/hello.txt?q=this%20url%3A%0Ahttp%3A//qutebrowser.org%0Ashould%20not%20open is loaded
        Then the following tabs should be open:
            - about:blank
            - data/hello.txt?q=this%20url%3A%0Ahttp%3A//qutebrowser.org%0Ashould%20not%20open (active)

    Scenario: Pasting multiple urls in a background tab
        Given I open about:blank
        When I run :tab-only
        And I put the following lines into the clipboard:
            http://localhost:(port)/data/hello.txt
            http://localhost:(port)/data/hello2.txt
            http://localhost:(port)/data/hello3.txt
        And I run :paste -b
        And I wait until data/hello.txt is loaded
        And I wait until data/hello2.txt is loaded
        And I wait until data/hello3.txt is loaded
        Then the following tabs should be open:
            - about:blank (active)
            - data/hello.txt
            - data/hello2.txt
            - data/hello3.txt

    Scenario: Pasting multiple urls in new windows
        Given I have a fresh instance
        When I put the following lines into the clipboard:
            http://localhost:(port)/data/hello.txt
            http://localhost:(port)/data/hello2.txt
            http://localhost:(port)/data/hello3.txt
        And I run :paste -w
        And I wait until data/hello.txt is loaded
        And I wait until data/hello2.txt is loaded
        And I wait until data/hello3.txt is loaded
        Then the session should look like:
            windows:
            - tabs:
              - active: true
                history:
                - active: true
                  url: about:blank
            - tabs:
              - active: true
                history:
                - active: true
                  url: http://localhost:*/data/hello.txt
            - tabs:
              - active: true
                history:
                - active: true
                  url: http://localhost:*/data/hello2.txt
            - tabs:
              - active: true
                history:
                - active: true
                  url: http://localhost:*/data/hello3.txt

    Scenario: Pasting multiple urls with an empty one
        When I open about:blank
        And I put "http://localhost:(port)/data/hello.txt\n\nhttp://localhost:(port)/data/hello2.txt" into the clipboard
        And I run :paste -t
        Then no crash should happen

    Scenario: Pasting multiple urls with an almost empty one
        When I open about:blank
        And I put "http://localhost:(port)/data/hello.txt\n \nhttp://localhost:(port)/data/hello2.txt" into the clipboard
        And I run :paste -t
        Then no crash should happen

    #### :paste-primary

    Scenario: Pasting the primary selection into an empty text field
        When selection is supported
        And I open data/paste_primary.html
        And I put "Hello world" into the primary selection
        # Click the text field
        And I run :hint all
        And I run :follow-hint a
        And I run :paste-primary
        # Compare
        Then the text field should contain "Hello world"

    Scenario: Pasting the primary selection into a text field at specific position
        When selection is supported
        And I open data/paste_primary.html
        And I set the text field to "one two three four"
        And I put " Hello world" into the primary selection
        # Click the text field
        And I run :hint all
        And I run :follow-hint a
        # Move to the beginning and two words to the right
        And I press the keys "<Home>"
        And I press the key "<Ctrl+Right>"
        And I press the key "<Ctrl+Right>"
        And I run :paste-primary
        # Compare
        Then the text field should contain "one two Hello world three four"

    Scenario: Pasting the primary selection into a text field with undo
        When selection is supported
        And I open data/paste_primary.html
        # Click the text field
        And I run :hint all
        And I run :follow-hint a
        # Paste and undo
        And I put "This text should be undone" into the primary selection
        And I run :paste-primary
        And I press the key "<Ctrl+z>"
        # Paste final text
        And I put "This text should stay" into the primary selection
        And I run :paste-primary
        # Compare
        Then the text field should contain "This text should stay"

    Scenario: Pasting the primary selection without a focused field
        When selection is supported
        And I open data/paste_primary.html
        And I put "test" into the primary selection
        And I run :enter-mode insert
        And I run :paste-primary
        Then the error "No element focused!" should be shown

    Scenario: Pasting the primary selection with a read-only field
        When selection is supported
        And I open data/paste_primary.html
        # Click the text field
        And I run :hint all
        And I run :follow-hint s
        And I put "test" into the primary selection
        And I run :enter-mode insert
        And I run :paste-primary
        Then the error "Focused element is not editable!" should be shown