-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wdspec] Add wdspec tests for invalid calls to network.addIntercept
Depends on D185454 Differential Revision: https://phabricator.services.mozilla.com/D185455 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1826192 gecko-commit: ca49a99264a1cb632bcdc8cb7014f6413a5aa317 gecko-reviewers: webdriver-reviewers, whimboo
- Loading branch information
1 parent
021ab91
commit bb6cf97
Showing
2 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
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,171 @@ | ||
import pytest | ||
import webdriver.bidi.error as error | ||
|
||
pytestmark = pytest.mark.asyncio | ||
|
||
|
||
@pytest.mark.parametrize("value", [None, "foo", False, 42, {}]) | ||
async def test_params_phases_invalid_type(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept(phases=value) | ||
|
||
|
||
async def test_params_phases_invalid_value_empty_array(bidi_session): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept(phases=[]) | ||
|
||
|
||
@pytest.mark.parametrize("value", [None, False, 42, {}, []]) | ||
async def test_params_phases_entry_invalid_type(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept(phases=[value]) | ||
|
||
|
||
@pytest.mark.parametrize("value", ["foo", "responseCompleted"]) | ||
async def test_params_phases_entry_invalid_value(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept(phases=[value]) | ||
|
||
|
||
@pytest.mark.parametrize("value", ["foo", False, 42, {}]) | ||
async def test_params_url_patterns_invalid_type(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], url_patterns=value | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("value", [None, "foo", False, 42, []]) | ||
async def test_params_url_patterns_entry_invalid_type(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], url_patterns=[value] | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("value", [{}, {"type": "foo"}]) | ||
async def test_params_url_patterns_entry_invalid_value(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], url_patterns=[value] | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("value", [None, False, 42, [], {}]) | ||
async def test_params_url_patterns_string_pattern_invalid_type(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], | ||
url_patterns=[{"type": "string", "pattern": value}], | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"value", | ||
[ | ||
"foo", | ||
"*", | ||
"(", | ||
")", | ||
"{", | ||
"}", | ||
"http\\{s\\}://example.com", | ||
"https://example.com:port/", | ||
], | ||
) | ||
async def test_params_url_patterns_string_pattern_invalid_value(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], | ||
url_patterns=[{"type": "string", "pattern": value}], | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"property", ["protocol", "hostname", "port", "pathname", "search"] | ||
) | ||
@pytest.mark.parametrize("value", [False, 42, [], {}]) | ||
async def test_params_url_patterns_pattern_property_invalid_type( | ||
bidi_session, property, value | ||
): | ||
with pytest.raises(error.InvalidArgumentException): | ||
url_pattern = {"type": "pattern"} | ||
url_pattern[property] = value | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], | ||
url_patterns=[url_pattern], | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"property", ["protocol", "hostname", "port", "pathname", "search"] | ||
) | ||
@pytest.mark.parametrize("value", ["*", "(", ")", "{", "}"]) | ||
async def test_params_url_patterns_pattern_property_unescaped_character( | ||
bidi_session, property, value | ||
): | ||
with pytest.raises(error.InvalidArgumentException): | ||
url_pattern = {"type": "pattern"} | ||
url_pattern[property] = value | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], | ||
url_patterns=[url_pattern], | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"value", | ||
[ | ||
"http/", | ||
"http\\*", | ||
"http\\(", | ||
"http\\)", | ||
"http\\{", | ||
"http\\}", | ||
"http#", | ||
"http@", | ||
"http%", | ||
], | ||
) | ||
async def test_params_url_patterns_pattern_protocol_invalid_value(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], | ||
url_patterns=[{"type": "pattern", "protocol": value}], | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("value", ["abc/com/", "abc?com", "abc#com", "abc:com", "::1"]) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
async def test_params_url_patterns_pattern_hostname_invalid_value(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], | ||
url_patterns=[{"type": "pattern", "hostname": value}], | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("value", ["abcd", "-1", "80 ", "1.3", ":80", "65536"]) | ||
async def test_params_url_patterns_pattern_port_invalid_value(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], | ||
url_patterns=[{"type": "pattern", "port": value}], | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("value", ["path?", "path#"]) | ||
async def test_params_url_patterns_pattern_pathname_invalid_value(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], | ||
url_patterns=[{"type": "pattern", "pathname": value}], | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("value", ["search#"]) | ||
async def test_params_url_patterns_pattern_search_invalid_value(bidi_session, value): | ||
with pytest.raises(error.InvalidArgumentException): | ||
await bidi_session.network.add_intercept( | ||
phases=["beforeRequestSent"], | ||
url_patterns=[{"type": "pattern", "search": value}], | ||
) |
FYI @juliandescottes this
::1
string doesn't play well with WPT expectations metadata: