Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/4033.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Some WebView intermittent failures in testbed from the WebView navigation handler PR has been fixed.
15 changes: 9 additions & 6 deletions testbed/tests/widgets/test_webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,18 +389,20 @@ async def test_retrieve_cookies(widget, probe, on_load):
assert cookie.expires is None


@pytest.mark.flaky(retries=5, delay=1)
async def test_on_navigation_starting_sync_no_handler(widget, probe, on_load):
# This test is required for full coverage because on android, setting
# the URL does not trigger shouldOverrideUrlLoading()
await widget.evaluate_javascript('window.location.assign("https://beeware.org/")')
await asyncio.sleep(2)
await asyncio.sleep(5)
await widget.evaluate_javascript(
'window.location.assign("https://beeware.org/docs/")'
)
await asyncio.sleep(2)
await asyncio.sleep(5)
assert widget.url == "https://beeware.org/docs/"


@pytest.mark.flaky(retries=5, delay=1)
async def test_on_navigation_starting_sync(widget, probe, on_load):
if not getattr(widget._impl, "SUPPORTS_ON_NAVIGATION_STARTING", True):
pytest.skip("Platform doesn't support on_navigation_starting")
Expand Down Expand Up @@ -441,17 +443,18 @@ def handler(widget, url, **kwargs):
await widget.evaluate_javascript(
'window.location.assign("https://github.com/beeware/toga/")'
)
await probe.redraw("Attempt to navigate to forbidden URL", delay=1)
await probe.redraw("Attempt to navigate to forbidden URL", delay=5)

assert widget.url == "https://github.com/beeware/"
# simulate browser navigation to allowed url
await widget.evaluate_javascript(
'window.location.assign("https://beeware.org/docs/")'
)
await probe.redraw("Attempt to navigate to allowed URL", delay=1)
await probe.redraw("Attempt to navigate to allowed URL", delay=5)
assert widget.url == "https://beeware.org/docs/"


@pytest.mark.flaky(retries=5, delay=1)
async def test_on_navigation_starting_async(widget, probe, on_load):
if not getattr(widget._impl, "SUPPORTS_ON_NAVIGATION_STARTING", True):
pytest.skip("Platform doesn't support on_navigation_starting")
Expand Down Expand Up @@ -492,12 +495,12 @@ async def handler(widget, url, **kwargs):
await widget.evaluate_javascript(
'window.location.assign("https://github.com/beeware/toga/")'
)
await probe.redraw("Attempt to navigate to denied URL", delay=1)
await probe.redraw("Attempt to navigate to denied URL", delay=5)
assert widget.url == "https://github.com/beeware/"

# simulate browser navigation to allowed url
await widget.evaluate_javascript(
'window.location.assign("https://beeware.org/docs/")'
)
await probe.redraw("Attempt to navigate to allowed URL", delay=1)
await probe.redraw("Attempt to navigate to allowed URL", delay=5)
assert widget.url == "https://beeware.org/docs/"