Fix mhtml overwrite prompts

See #2101
This commit is contained in:
Florian Bruhin 2016-11-08 23:23:53 +01:00
parent baeb8653c8
commit 970e4d3e03
2 changed files with 21 additions and 4 deletions

View File

@ -19,6 +19,7 @@
"""Utils for writing an MHTML file."""
import html
import functools
import io
import os
@ -537,10 +538,10 @@ def start_download_checked(dest, tab):
q = usertypes.Question()
q.mode = usertypes.PromptMode.yesno
q.text = "{} exists. Overwrite?".format(path)
q.title = "Overwrite existing file?"
q.text = "<b>{}</b> already exists. Overwrite?".format(
html.escape(path))
q.completed.connect(q.deleteLater)
q.answered_yes.connect(functools.partial(
_start_download, path, tab=tab))
message_bridge = objreg.get('message-bridge', scope='window',
window=tab.win_id)
message_bridge.ask(q, blocking=False)
message.global_bridge.ask(q, blocking=False)

View File

@ -186,6 +186,22 @@ Feature: Downloading things from a website.
And I wait for "File successfully written." in the log
Then no crash should happen
@qtwebengine_todo: :download --mhtml is not implemented yet
Scenario: Overwriting existing mhtml file
When I set storage -> prompt-download-directory to true
And I open html
And I run :download --mhtml
And I wait for "Asking question <qutebrowser.utils.usertypes.Question default='*' mode=<PromptMode.text: 2> text='Please enter a location for <b>http://localhost:*/html</b>' title='Save file to:'>, *" in the log
And I run :prompt-accept
And I wait for "File successfully written." in the log
And I run :download --mhtml
And I wait for "Asking question <qutebrowser.utils.usertypes.Question default='*' mode=<PromptMode.text: 2> text='Please enter a location for <b>http://localhost:*/html</b>' title='Save file to:'>, *" in the log
And I run :prompt-accept
And I wait for "Asking question <qutebrowser.utils.usertypes.Question default=None mode=<PromptMode.yesno: 1> text='<b>*</b> already exists. Overwrite?' title='Overwrite existing file?'>, *" in the log
And I run :prompt-accept yes
And I wait for "File successfully written." in the log
Then no crash should happen
## :download-cancel
Scenario: Cancelling a download