-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Hi there,
it seems that there is code that is supposed to handle this condition, but it doesn't work for me - i.e. hangs indefinitely. Also, if the onbeforeunload handler is triggered in a different (background) window, it seems that this condition is not handled at all, but instead the window just gets a close event and doesn't close.
Here's my reproducer:
# https://github.com/elliterate/capybara.py
import capybara
from capybara.dsl import page
from conftest import find_firefox
HEADLESS = True
HEADLESS = False
@capybara.register_driver("selenium")
def init_selenium_driver(app):
from selenium.webdriver.firefox.options import Options
options = Options()
options.binary_location = find_firefox()
options.headless = HEADLESS
# otherwise marionette automatically disables beforeunload event handling
# still requires interaction to trigger
options.set_preference("dom.disable_beforeunload", False)
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
capabilities = DesiredCapabilities.FIREFOX.copy()
capabilities["marionette"] = True
from capybara.selenium.driver import Driver
return Driver(app, browser="firefox", options=options, desired_capabilities=capabilities,
# cannot set these after the fact, so we set them here
clear_local_storage=True,
clear_session_storage=True,
)
capybara.default_driver = "selenium"
capybara.default_max_wait_time = 5
def test_isolation(flask_uri, ask_to_leave_script):
page.visit(flask_uri)
# onbeforeunload dialog
# bug in capybara, ask to leave script is only handled in current window, other windows just get closed and then hang
# Even though it is handled in the code, that doesn't work for firefox. (?)
page.execute_script(ask_to_leave_script)
# page interaction, so onbeforeunload is actually triggered
page.fill_in('input_label', value='fnord')
# bug in capybara: background windows don't even have code to handle dialogs like onbeforeunload
with page.window(page.open_new_window()):
page.visit(flask_uri)
page.execute_script(ask_to_leave_script)
# page interaction, so onbeforeunload is actually triggered
page.fill_in('input_label', value='fnord')
page.reset() # hangs on the onbeforeunload handlers
assert len(page.windows) == 1
assert page.current_url == 'about:blank'Metadata
Metadata
Assignees
Labels
No labels