-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wdspec] add network interception invalidation tests for all remainin…
…g methods Synced from #42667 Differential Revision: https://phabricator.services.mozilla.com/D196424 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1870032 gecko-commit: d3a29d02b3dd8d8cfbfff6fcad00d94226e102e8 gecko-reviewers: webdriver-reviewers, whimboo
- Loading branch information
1 parent
a50667f
commit 2cd1dae
Showing
11 changed files
with
486 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import pytest | ||
import webdriver.bidi.error as error | ||
|
||
from .. import PAGE_EMPTY_TEXT, RESPONSE_COMPLETED_EVENT | ||
|
||
pytestmark = pytest.mark.asyncio | ||
|
||
|
||
@pytest.mark.parametrize("value", [False, 42, {}, []]) | ||
async def test_params_method_invalid_type(setup_blocked_request, bidi_session, value): | ||
request = await setup_blocked_request("beforeRequestSent") | ||
|
||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.continue_request(request=request, method=value) | ||
|
||
|
||
@pytest.mark.parametrize("value", [None, False, 42, {}, []]) | ||
async def test_params_request_invalid_type(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.continue_request(request=value) | ||
|
||
|
||
@pytest.mark.parametrize("value", ["", "foo"]) | ||
async def test_params_request_invalid_value(bidi_session, value): | ||
with pytest.raises(error.NoSuchRequestException): | ||
await bidi_session.network.continue_request(request=value) | ||
|
||
|
||
async def test_params_request_no_such_request( | ||
bidi_session, setup_network_test, wait_for_event, fetch, url | ||
): | ||
await setup_network_test( | ||
events=[ | ||
RESPONSE_COMPLETED_EVENT, | ||
] | ||
) | ||
on_response_completed = wait_for_event(RESPONSE_COMPLETED_EVENT) | ||
|
||
text_url = url(PAGE_EMPTY_TEXT) | ||
await fetch(text_url) | ||
|
||
response_completed_event = await on_response_completed | ||
request = response_completed_event["request"]["request"] | ||
|
||
with pytest.raises(error.NoSuchRequestException): | ||
await bidi_session.network.continue_request(request=request) | ||
|
||
|
||
@pytest.mark.parametrize("value", [False, 42, {}, []]) | ||
async def test_params_url_invalid_type(setup_blocked_request, bidi_session, value): | ||
request = await setup_blocked_request("beforeRequestSent") | ||
|
||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.continue_request(request=request, url=value) | ||
|
||
|
||
@pytest.mark.parametrize("protocol", ["http", "https"]) | ||
@pytest.mark.parametrize("value", [":invalid", "#invalid"]) | ||
async def test_params_url_invalid_value( | ||
setup_blocked_request, bidi_session, protocol, value | ||
): | ||
request = await setup_blocked_request("beforeRequestSent") | ||
|
||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.continue_request( | ||
request=request, url=f"{protocol}://{value}" | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import pytest | ||
import webdriver.bidi.error as error | ||
|
||
from .. import PAGE_EMPTY_TEXT, RESPONSE_COMPLETED_EVENT | ||
|
||
pytestmark = pytest.mark.asyncio | ||
|
||
|
||
async def test_params_request_invalid_phase(setup_blocked_request, bidi_session): | ||
request = await setup_blocked_request("beforeRequestSent") | ||
|
||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.continue_response(request=request) | ||
|
||
|
||
@pytest.mark.parametrize("value", [None, False, 42, {}, []]) | ||
async def test_params_request_invalid_type(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.continue_response(request=value) | ||
|
||
|
||
@pytest.mark.parametrize("value", ["", "foo"]) | ||
async def test_params_request_invalid_value(bidi_session, value): | ||
with pytest.raises(error.NoSuchRequestException): | ||
await bidi_session.network.continue_response(request=value) | ||
|
||
|
||
async def test_params_request_no_such_request( | ||
bidi_session, setup_network_test, wait_for_event, fetch, url | ||
): | ||
await setup_network_test( | ||
events=[ | ||
RESPONSE_COMPLETED_EVENT, | ||
] | ||
) | ||
on_response_completed = wait_for_event(RESPONSE_COMPLETED_EVENT) | ||
|
||
text_url = url(PAGE_EMPTY_TEXT) | ||
await fetch(text_url) | ||
|
||
response_completed_event = await on_response_completed | ||
request = response_completed_event["request"]["request"] | ||
|
||
with pytest.raises(error.NoSuchRequestException): | ||
await bidi_session.network.continue_response(request=request) | ||
|
||
|
||
@pytest.mark.parametrize("value", [False, 42, {}, []]) | ||
async def test_params_reason_phrase_invalid_type( | ||
setup_blocked_request, bidi_session, value | ||
): | ||
request = await setup_blocked_request("responseStarted") | ||
|
||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.continue_response( | ||
request=request, reason_phrase=value | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("value", [False, "foo", {}, []]) | ||
async def test_params_status_code_invalid_type( | ||
setup_blocked_request, bidi_session, value | ||
): | ||
request = await setup_blocked_request("responseStarted") | ||
|
||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.continue_response(request=request, status_code=value) | ||
|
||
|
||
@pytest.mark.parametrize("value", [-1, 4.3]) | ||
async def test_params_status_code_invalid_value( | ||
setup_blocked_request, bidi_session, value | ||
): | ||
request = await setup_blocked_request("responseStarted") | ||
|
||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.continue_response(request=request, status_code=value) |
Empty file.
Oops, something went wrong.