Bug 1632482 - close all tabs at the end of a condprof scenario r=whimboo

This patch makes sure all tabs are closed before we close the
browser.

Differential Revision: https://phabricator.services.mozilla.com/D72158
This commit is contained in:
Tarek Ziadé 2020-04-23 21:33:47 +00:00
Родитель 7cc10f2dc5
Коммит fff1b40b7b
2 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -29,6 +29,7 @@ from arsenic import get_session
from arsenic.browsers import Firefox
from condprof.util import fresh_profile, logger, obfuscate_file, obfuscate
from condprof.helpers import close_extra_windows
from condprof.scenarii import scenarii
from condprof.client import get_profile, ProfileNotFoundError
from condprof.archiver import Archiver
@ -155,6 +156,7 @@ class ProfileCreator:
logger.info("Running the %s scenario" % scenario)
metadata.update(await scenario_func(session, options))
logger.info("%s scenario done." % scenario)
await close_extra_windows(session)
except Exception:
logger.error("%s scenario broke!" % scenario)
if step == START:

Просмотреть файл

@ -100,3 +100,12 @@ async def execute_async_script(session, script, *args):
await session._request(
url="/moz/context", method="POST", data={"context": current_context}
)
async def close_extra_windows(session):
logger.info("Closing all tabs")
handles = await session.get_window_handles()
# we're closing all tabs except the last one
for handle in handles[:-1]:
await session.switch_to_window(handle)
await session._request(url="/window", method="DELETE")