Skip to content

Commit 0503a27

Browse files
committed
remove unnecessary tests and methods
1 parent df37262 commit 0503a27

File tree

3 files changed

+7
-75
lines changed

3 files changed

+7
-75
lines changed

infrastructure/testdriver/bidi/speculation/prefetch_status_updated.https.html

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,11 @@
1919
const receivedEvents = [];
2020
const expectedEvents = ['pending', 'ready'];
2121

22-
// Create target url with unique id to ensure events are from this test
23-
const uuid = self.crypto.randomUUID();
24-
const targetUrl = window.location.origin + "/infrastructure/testdriver/bidi/speculation/resources/target.html?" + uuid;
22+
const targetUrl = window.location.origin + "/infrastructure/testdriver/bidi/speculation/resources/target.html";
2523

2624
// Create a promise that resolves when we receive the 'ready' event
2725
const readyEventPromise = new Promise((resolve, reject) => {
2826
const removeHandler = test_driver.bidi.speculation.prefetch_status_updated.on((event) => {
29-
// Ignore events from other tests that could be running in parallel.
30-
if (event.url !== targetUrl) {
31-
return;
32-
}
3327
receivedEvents.push(event);
3428

3529
// When we receive the ready event, clean up and resolve
@@ -41,7 +35,6 @@
4135

4236
});
4337

44-
4538
// Create prefetch rules for our target page in resources
4639
const speculationRules = {
4740
prefetch: [{
@@ -71,17 +64,12 @@
7164
const expectedEvents = ['pending', 'ready', 'success'];
7265
let newWindow = null;
7366

74-
// Create target url with unique id to ensure events are from this test
75-
const uuid = self.crypto.randomUUID();
76-
const targetUrl = window.location.origin + "/infrastructure/testdriver/bidi/speculation/resources/target.html?" + uuid;
67+
// Create prefetch rules for our target page in resources (different URL to avoid caching)
68+
const targetUrl = window.location.origin + "/infrastructure/testdriver/bidi/speculation/resources/target.html?test=2";
7769

7870
// Create a promise that resolves when we receive the 'success' event
7971
const successEventPromise = new Promise((resolve, reject) => {
8072
const removeHandler = test_driver.bidi.speculation.prefetch_status_updated.on((event) => {
81-
// Ignore events from other tests that could be running in parallel.
82-
if (event.url !== targetUrl) {
83-
return;
84-
}
8573
receivedEvents.push(event);
8674

8775
// When we receive the ready event, navigate to trigger success
@@ -125,21 +113,14 @@
125113
}, "prefetch_status_updated event with navigation to success");
126114

127115
promise_test(async t => {
128-
129116
const receivedEvents = [];
130117
const expectedEvents = ['pending', 'failure'];
131118

132-
// Create prefetch rules for a non-existent page that should fail with 404
133-
const uuid = self.crypto.randomUUID();
134-
const errorUrl = window.location.origin + "/infrastructure/testdriver/bidi/speculation/resources/nonexistent-404-page.html?" + uuid;
119+
const errorUrl = window.location.origin + "/infrastructure/testdriver/bidi/speculation/resources/nonexistent-404-page.html";
135120

136121
// Create a promise that resolves when we receive the 'failure' event
137122
const failureEventPromise = new Promise((resolve, reject) => {
138123
const removeHandler = test_driver.bidi.speculation.prefetch_status_updated.on((event) => {
139-
// Ignore events from other tests that could be running in parallel.
140-
if (event.url !== errorUrl) {
141-
return;
142-
}
143124
receivedEvents.push(event);
144125

145126
// When we receive the failure event, we're done

webdriver/tests/bidi/external/speculation/conftest.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,6 @@ async def add_speculation_rules(context: Mapping[str, Any], rules: str):
2323

2424
return add_speculation_rules
2525

26-
27-
@pytest.fixture
28-
def add_prefetch_link(bidi_session):
29-
"""Helper for adding links to the page that can be targeted by speculation rules."""
30-
31-
async def add_link(context: Mapping[str, Any], href: str, text: str = "Test Link", link_id: str = "prefetch-page"):
32-
"""Add a link to the page for prefetch targeting."""
33-
await bidi_session.script.evaluate(
34-
expression=f"""
35-
const link = document.createElement('a');
36-
link.href = '{href}';
37-
link.textContent = '{text}';
38-
link.id = '{link_id}';
39-
document.body.appendChild(link);
40-
""",
41-
target={"context": context["context"]},
42-
await_promise=False
43-
)
44-
45-
return add_link
46-
47-
4826
@pytest.fixture
4927
def add_speculation_rules_and_link(bidi_session):
5028
"""Helper for adding both speculation rules and a prefetch link to a page."""

webdriver/tests/bidi/external/speculation/prefetch_status_updated/prefetch_status_updated.py

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,6 @@
33

44
pytestmark = 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
267
async 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
255233
async 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
316291
async 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

Comments
 (0)