33
44pytestmark = pytest .mark .asyncio
55
6- @pytest .mark .asyncio
7- async def test_subscribe_to_prefetch_status_updated (
8- bidi_session , subscribe_events , new_tab , url
9- ):
10- '''Test basic subscription to prefetch status updated events.'''
11-
12- # Subscribe to prefetch status updated events
13- await subscribe_events (events = ["speculation.prefetchStatusUpdated" ])
14-
15- # Navigate to a test page
16- test_url = url ("/common/blank.html" , protocol = "https" )
17- await bidi_session .browsing_context .navigate (
18- context = new_tab ["context" ],
19- url = test_url ,
20- wait = "complete" ,
21- )
22-
23- assert True
24-
256@pytest .mark .asyncio
267async def test_speculation_rules_generate_ready_events (
278 bidi_session , subscribe_events , new_tab , url , wait_for_events , add_speculation_rules_and_link
@@ -222,9 +203,6 @@ async def test_subscribe_unsubscribe_event_emission(
222203 # Wait for events to be emitted
223204 events = await waiter .get_events (lambda events : len (events ) >= 2 )
224205
225- # Assert events were emitted while subscribed
226- assert len (events ) >= 2 , f"Expected at least 2 events while subscribed, got { len (events )} "
227-
228206 # Phase 2: Unsubscribe and assert events are NOT emitted
229207 await bidi_session .session .unsubscribe (subscriptions = [subscription_id ])
230208
@@ -249,7 +227,7 @@ async def test_subscribe_unsubscribe_event_emission(
249227 await add_speculation_rules_and_link (new_tab , speculation_rules_2 , prefetch_target_2 )
250228
251229 with pytest .raises (TimeoutException ):
252- await waiter .get_events (lambda events : len (events ) >= 1 , timeout = 2 )
230+ await waiter .get_events (lambda events : len (events ) >= 1 , timeout = 0.5 )
253231
254232@pytest .mark .asyncio
255233async def test_subscribe_unsubscribe_module_subscription (
@@ -283,9 +261,6 @@ async def test_subscribe_unsubscribe_module_subscription(
283261 # Wait for events to be emitted
284262 events = await waiter .get_events (lambda events : len (events ) >= 2 )
285263
286- # Assert events were emitted while subscribed to module
287- assert len (events ) >= 2 , f"Expected at least 2 events while subscribed to module, got { len (events )} "
288-
289264 # Phase 2: Unsubscribe from module and assert events are NOT emitted
290265 await bidi_session .session .unsubscribe (subscriptions = [subscription_id ])
291266
@@ -310,7 +285,7 @@ async def test_subscribe_unsubscribe_module_subscription(
310285 await add_speculation_rules_and_link (new_tab , speculation_rules_2 , prefetch_target_2 )
311286
312287 with pytest .raises (TimeoutException ):
313- await waiter .get_events (lambda events : len (events ) >= 1 , timeout = 2 )
288+ await waiter .get_events (lambda events : len (events ) >= 1 , timeout = 0.5 )
314289
315290@pytest .mark .asyncio
316291async def test_unsubscribe_from_prefetch_status_updated (
@@ -325,6 +300,4 @@ async def test_unsubscribe_from_prefetch_status_updated(
325300 subscription_id = subscription_result ["subscription" ]
326301
327302 # Unsubscribe immediately
328- await bidi_session .session .unsubscribe (subscriptions = [subscription_id ])
329-
330- assert True
303+ await bidi_session .session .unsubscribe (subscriptions = [subscription_id ])
0 commit comments