Merge remote-tracking branch 'origin/pr/3506'

This commit is contained in:
Florian Bruhin 2018-01-24 21:14:25 +01:00
commit e5b6ccd716
2 changed files with 24 additions and 1 deletions

View File

@ -457,7 +457,8 @@ class SessionManager(QObject):
@cmdutils.register(instance='session-manager')
@cmdutils.argument('name', completion=miscmodels.session)
def session_load(self, name, clear=False, temp=False, force=False):
def session_load(self, name, clear=False, temp=False, force=False,
delete=False):
"""Load a session.
Args:
@ -466,6 +467,7 @@ class SessionManager(QObject):
temp: Don't set the current session for :session-save.
force: Force loading internal sessions (starting with an
underline).
delete: Delete the saved session once it has loaded.
"""
if name.startswith('_') and not force:
raise cmdexc.CommandError("{} is an internal session, use --force "
@ -482,6 +484,17 @@ class SessionManager(QObject):
if clear:
for win in old_windows:
win.close()
if delete:
try:
self.delete(name)
except SessionError as e:
log.sessions.exception("Error while deleting session!")
raise cmdexc.CommandError(
"Error while deleting session: {}"
.format(e))
else:
log.sessions.debug(
"Loaded & deleted session {}.".format(name))
@cmdutils.register(instance='session-manager')
@cmdutils.argument('name', completion=miscmodels.session)

View File

@ -363,6 +363,16 @@ Feature: Saving and loading sessions
And I replace "about:blank" by "http://localhost:(port)/data/numbers/2.txt" in the "loaded_session" session file
And I run :session-load loaded_session
Then data/numbers/2.txt should be loaded
@qtwebengine_flaky
Scenario: Loading and deleting a session
When I open about:blank
And I run :session-save loaded_session
And I replace "about:blank" by "http://localhost:(port)/data/numbers/2.txt" in the "loaded_session" session file
And I run :session-load --delete loaded_session
And I wait for "Loaded & deleted session loaded_session." in the log
Then data/numbers/2.txt should be loaded
And the session loaded_session should not exist
Scenario: Loading a session which doesn't exist
When I run :session-load inexistent_session