Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor local http server #2368

Merged
merged 3 commits into from
Jul 2, 2024
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
2 changes: 1 addition & 1 deletion tests/browsing_context/test_close.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ async def test_browsingContext_close_prompt(websocket, context_id, html,
# @pytest.mark.parametrize("accept", [True])
@pytest.mark.parametrize("accept", [True, False])
async def test_browsingContext_navigate_prompt(websocket, context_id, html,
accept, example_url):
accept):
await subscribe(websocket, ["browsingContext.userPromptOpened"])

url = html("""
Expand Down
8 changes: 4 additions & 4 deletions tests/browsing_context/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ async def test_browsingContext_createWithNestedSameOriginContexts_eventContextCr

@pytest.mark.asyncio
async def test_browsingContext_create_withUserGesture_eventsEmitted(
websocket, context_id, html, example_url, read_sorted_messages):
websocket, context_id, html, url_example, read_sorted_messages):
LINK_WITH_BLANK_TARGET = html(
f'''<a href="{example_url}" target="_blank">new tab</a>''')
f'''<a href="{url_example}" target="_blank">new tab</a>''')

await goto_url(websocket, context_id, LINK_WITH_BLANK_TARGET)

Expand Down Expand Up @@ -249,7 +249,7 @@ async def test_browsingContext_create_withUserGesture_eventsEmitted(
'context': new_context_id,
'navigation': ANY_STR,
'timestamp': ANY_TIMESTAMP,
'url': example_url
'url': url_example
}
}, {
'type': 'event',
Expand All @@ -258,7 +258,7 @@ async def test_browsingContext_create_withUserGesture_eventsEmitted(
'context': new_context_id,
'navigation': ANY_STR,
'timestamp': ANY_TIMESTAMP,
'url': example_url
'url': url_example
}
}]

Expand Down
6 changes: 3 additions & 3 deletions tests/browsing_context/test_fragment_navigated.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

@pytest.mark.asyncio
async def test_browsingContext_fragmentNavigated_event(websocket, context_id,
base_url):
url_base):
await subscribe(websocket, ["browsingContext.fragmentNavigated"])

await goto_url(websocket, context_id, base_url)
await goto_url(websocket, context_id, url_base)

await send_JSON_command(
websocket, {
Expand All @@ -44,6 +44,6 @@ async def test_browsingContext_fragmentNavigated_event(websocket, context_id,
"context": context_id,
"navigation": ANY_UUID,
"timestamp": ANY_TIMESTAMP,
"url": base_url + "#test",
"url": url_base + "#test",
}
}
8 changes: 4 additions & 4 deletions tests/browsing_context/test_get_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ async def test_browsingContext_getTreeWithRoot_contextReturned(websocket):

@pytest.mark.asyncio
async def test_browsingContext_afterNavigation_getTreeWithNestedCrossOriginContexts_contextsReturned(
websocket, context_id, html, iframe, example_url, another_example_url):
page_with_nested_iframe = html(iframe(example_url))
another_page_with_nested_iframe = html(iframe(another_example_url))
websocket, context_id, html, iframe, url_example, url_another_example):
page_with_nested_iframe = html(iframe(url_example))
another_page_with_nested_iframe = html(iframe(url_another_example))

await goto_url(websocket, context_id, page_with_nested_iframe, "complete")
await goto_url(websocket, context_id, another_page_with_nested_iframe,
Expand All @@ -78,7 +78,7 @@ async def test_browsingContext_afterNavigation_getTreeWithNestedCrossOriginConte
"context": context_id,
"children": [{
"context": ANY_STR,
"url": another_example_url,
"url": url_another_example,
"children": [],
"userContext": "default",
"originalOpener": None
Expand Down
26 changes: 13 additions & 13 deletions tests/browsing_context/test_navigate.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ async def test_navigateToPageWithHash_contextInfoUpdated(

@pytest.mark.asyncio
async def test_browsingContext_navigationStartedEvent_viaScript(
websocket, context_id, base_url):
websocket, context_id, url_base):

serialized_url = {"type": "string", "value": base_url}
serialized_url = {"type": "string", "value": url_base}

await subscribe(websocket, ["browsingContext.navigationStarted"])
await send_JSON_command(
Expand Down Expand Up @@ -396,13 +396,13 @@ async def test_browsingContext_navigationStartedEvent_viaCommand(

@pytest.mark.asyncio
async def test_browsingContext_navigationStarted_browsingContextClosedBeforeNavigationEnded_navigationFailed(
websocket, context_id, read_sorted_messages, hang_url):
websocket, context_id, read_sorted_messages, url_hang_forever):
navigate_command_id = await send_JSON_command(
websocket, {
"method": "browsingContext.navigate",
"params": {
"context": context_id,
"url": hang_url,
"url": url_hang_forever,
"wait": "complete",
}
})
Expand Down Expand Up @@ -433,7 +433,7 @@ async def test_browsingContext_navigationStarted_browsingContextClosedBeforeNavi

@pytest.mark.asyncio
async def test_browsingContext_navigationStarted_sameDocumentNavigation(
websocket, context_id, base_url):
websocket, context_id, url_base):
await subscribe(
websocket,
["browsingContext.navigationStarted", "browsingContext.load"])
Expand All @@ -443,7 +443,7 @@ async def test_browsingContext_navigationStarted_sameDocumentNavigation(
websocket, {
"method": "browsingContext.navigate",
"params": {
"url": base_url,
"url": url_base,
"context": context_id,
"wait": "none"
}
Expand All @@ -457,7 +457,7 @@ async def test_browsingContext_navigationStarted_sameDocumentNavigation(
"context": context_id,
"navigation": ANY_UUID,
"timestamp": ANY_TIMESTAMP,
"url": base_url,
"url": url_base,
}
}
navigation_id = response["params"]["navigation"]
Expand All @@ -469,7 +469,7 @@ async def test_browsingContext_navigationStarted_sameDocumentNavigation(
'id': command_id,
'result': {
'navigation': navigation_id,
'url': base_url
'url': url_base
}
})

Expand Down Expand Up @@ -505,7 +505,7 @@ async def test_browsingContext_navigationStarted_sameDocumentNavigation(
"context": context_id,
"navigation": ANY_UUID,
"timestamp": ANY_TIMESTAMP,
"url": base_url + "#test",
"url": url_base + "#test",
}
})

Expand All @@ -514,26 +514,26 @@ async def test_browsingContext_navigationStarted_sameDocumentNavigation(


@pytest.mark.asyncio
@pytest.mark.parametrize('capabilities', [{
@pytest.mark.parametrize('capabilities', [{}, {
'acceptInsecureCerts': True
}, {
'acceptInsecureCerts': False
}],
indirect=True)
async def test_browsingContext_acceptInsecureCertsCapability_respected(
websocket, context_id, bad_ssl_url, capabilities):
websocket, context_id, url_bad_ssl, capabilities):
async def navigate():
await execute_command(
websocket, {
'method': "browsingContext.navigate",
'params': {
'url': bad_ssl_url,
'url': url_bad_ssl,
'wait': 'complete',
'context': context_id
}
})

if capabilities['acceptInsecureCerts']:
if capabilities.get('acceptInsecureCerts'):
await navigate()
else:
with pytest.raises(Exception,
Expand Down
14 changes: 7 additions & 7 deletions tests/browsing_context/test_nested_browsing_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ async def test_nestedBrowsingContext_navigateSameDocumentNavigation_waitComplete

@pytest.mark.asyncio
async def test_nestedBrowsingContext_afterNavigation_getTreeWithNestedCrossOriginContexts_contextsReturned(
websocket, iframe_id, html, iframe, example_url, another_example_url):
page_with_nested_iframe = html(iframe(example_url))
another_page_with_nested_iframe = html(iframe(another_example_url))
websocket, iframe_id, html, iframe, url_example, url_another_example):
page_with_nested_iframe = html(iframe(url_example))
another_page_with_nested_iframe = html(iframe(url_another_example))

await goto_url(websocket, iframe_id, page_with_nested_iframe, "complete")
await goto_url(websocket, iframe_id, another_page_with_nested_iframe,
Expand All @@ -277,7 +277,7 @@ async def test_nestedBrowsingContext_afterNavigation_getTreeWithNestedCrossOrigi
"context": iframe_id,
"children": [{
"context": ANY_STR,
"url": another_example_url,
"url": url_another_example,
"children": [],
"userContext": "default",
"originalOpener": None
Expand Down Expand Up @@ -326,8 +326,8 @@ async def test_nestedBrowsingContext_afterNavigation_getTreeWithNestedContexts_c

@pytest.mark.asyncio
async def test_browsingContext_addAndRemoveNestedContext_contextAddedAndRemoved(
websocket, context_id, url_cross_origin, html, iframe):
page_with_nested_iframe = html(iframe(url_cross_origin))
websocket, context_id, url_all_origins, html, iframe):
page_with_nested_iframe = html(iframe(url_all_origins))
await goto_url(websocket, context_id, page_with_nested_iframe, "complete")

result = await get_tree(websocket)
Expand All @@ -337,7 +337,7 @@ async def test_browsingContext_addAndRemoveNestedContext_contextAddedAndRemoved(
"context": context_id,
"children": [{
"context": ANY_STR,
"url": url_cross_origin,
"url": url_all_origins,
"children": [],
"userContext": "default",
"originalOpener": None
Expand Down
4 changes: 2 additions & 2 deletions tests/browsing_context/test_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ async def test_browsingContext_reload_waitComplete(websocket, context_id,
@pytest.mark.asyncio
@pytest.mark.parametrize("ignore_cache", [True, False])
async def test_browsingContext_reload_ignoreCache(websocket, context_id,
ignore_cache, cacheable_url):
ignore_cache, url_cacheable):
if ignore_cache is False:
pytest.xfail(
reason= # noqa: E251. The line is too long.
Expand All @@ -205,7 +205,7 @@ async def test_browsingContext_reload_ignoreCache(websocket, context_id,
"network.responseCompleted",
])

await goto_url(websocket, context_id, cacheable_url)
await goto_url(websocket, context_id, url_cacheable)

await send_JSON_command(
websocket, {
Expand Down
Loading
Loading