Skip to content

Commit f99d1de

Browse files
update
1 parent 4750262 commit f99d1de

4 files changed

Lines changed: 167 additions & 82 deletions

File tree

Lines changed: 148 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,150 @@
1+
from tests.bidi import get_invalid_cases
2+
13
MEDIA_FEATURE_NAMES_AND_SAMPLE_VALUES = [
2-
("any-hover", "none"),
3-
("any-hover", "hover"),
4-
("any-pointer", "none"),
5-
("any-pointer", "coarse"),
6-
("any-pointer", "fine"),
7-
("color", 8),
8-
("color", 0),
9-
("color-gamut", "srgb"),
10-
("color-gamut", "p3"),
11-
("color-gamut", "rec2020"),
12-
("color-index", 0),
13-
("display-mode", "fullscreen"),
14-
("display-mode", "standalone"),
15-
("display-mode", "minimal-ui"),
16-
("display-mode", "browser"),
17-
("display-mode", "picture-in-picture"),
18-
("dynamic-range", "standard"),
19-
("dynamic-range", "high"),
20-
("environment-blending", "opaque"),
21-
("environment-blending", "additive"),
22-
("environment-blending", "subtractive"),
23-
("forced-colors", "none"),
24-
("forced-colors", "active"),
25-
("grid", 0),
26-
("grid", 1),
27-
("horizontal-viewport-segments", 1),
28-
("hover", "none"),
29-
("hover", "hover"),
30-
("inverted-colors", "none"),
31-
("inverted-colors", "inverted"),
32-
("monochrome", 0),
33-
("nav-controls", "none"),
34-
("nav-controls", "back"),
35-
("overflow-block", "none"),
36-
("overflow-block", "scroll"),
37-
("overflow-block", "optional-paged"),
38-
("overflow-block", "paged"),
39-
("overflow-inline", "none"),
40-
("overflow-inline", "scroll"),
41-
("pointer", "none"),
42-
("pointer", "coarse"),
43-
("pointer", "fine"),
44-
("prefers-color-scheme", "light"),
45-
("prefers-color-scheme", "dark"),
46-
("prefers-contrast", "no-preference"),
47-
("prefers-contrast", "more"),
48-
("prefers-contrast", "less"),
49-
("prefers-contrast", "custom"),
50-
("prefers-reduced-data", "no-preference"),
51-
("prefers-reduced-data", "reduce"),
52-
("prefers-reduced-motion", "no-preference"),
53-
("prefers-reduced-motion", "reduce"),
54-
("prefers-reduced-transparency", "no-preference"),
55-
("prefers-reduced-transparency", "reduce"),
56-
("scan", "interlace"),
57-
("scan", "progressive"),
58-
("scripting", "none"),
59-
("scripting", "initial-only"),
60-
("scripting", "enabled"),
61-
("update", "none"),
62-
("update", "slow"),
63-
("update", "fast"),
64-
("vertical-viewport-segments", 1),
65-
("video-color-gamut", "srgb"),
66-
("video-color-gamut", "p3"),
67-
("video-color-gamut", "rec2020"),
68-
("video-dynamic-range", "standard"),
69-
("video-dynamic-range", "high"),
4+
(
5+
"any-hover",
6+
["none", "hover"],
7+
["invalid value"] + get_invalid_cases("string", nullable=True),
8+
),
9+
(
10+
"any-pointer",
11+
["none", "coarse", "fine"],
12+
["invalid value"] + get_invalid_cases("string", nullable=True),
13+
),
14+
(
15+
"color",
16+
[0, 8],
17+
[-1] + get_invalid_cases("number", nullable=True),
18+
),
19+
(
20+
"color-gamut",
21+
["srgb", "p3", "rec2020"],
22+
["invalid value"] + get_invalid_cases("string", nullable=True),
23+
),
24+
(
25+
"color-index",
26+
[0, 1],
27+
[-1] + get_invalid_cases("number", nullable=True),,
28+
),
29+
(
30+
"display-mode",
31+
["fullscreen", "standalone", "minimal-ui", "browser", "picture-in-picture"],
32+
["invalid value"] + get_invalid_cases("string", nullable=True),
33+
),
34+
(
35+
"dynamic-range",
36+
["standard", "high"],
37+
["invalid value"] + get_invalid_cases("string", nullable=True),
38+
),
39+
(
40+
"environment-blending",
41+
["opaque", "additive", "subtractive"],
42+
["invalid value"] + get_invalid_cases("string", nullable=True),
43+
),
44+
(
45+
"forced-colors",
46+
["none", "active"],
47+
["invalid value"] + get_invalid_cases("string", nullable=True),
48+
),
49+
(
50+
"grid",
51+
[0, 1],
52+
[-1] + get_invalid_cases("number", nullable=True),,
53+
),
54+
(
55+
"horizontal-viewport-segments",
56+
[1, 2],
57+
[-1] + get_invalid_cases("number", nullable=True),,
58+
),
59+
(
60+
"hover",
61+
["none", "hover"],
62+
["invalid value"] + get_invalid_cases("string", nullable=True),
63+
),
64+
(
65+
"inverted-colors",
66+
["none", "inverted"],
67+
["invalid value"] + get_invalid_cases("string", nullable=True),
68+
),
69+
(
70+
"monochrome",
71+
[0, 1],
72+
[-1] + get_invalid_cases("number", nullable=True),,
73+
),
74+
(
75+
"nav-controls",
76+
["none", "back"],
77+
["invalid value"] + get_invalid_cases("string", nullable=True),
78+
),
79+
(
80+
"overflow-block",
81+
["none", "scroll", "optional-paged", "paged"],
82+
["invalid value"] + get_invalid_cases("string", nullable=True),
83+
),
84+
(
85+
"overflow-inline",
86+
["none", "scroll"],
87+
["invalid value"] + get_invalid_cases("string", nullable=True),
88+
),
89+
(
90+
"pointer",
91+
["none", "coarse", "fine"],
92+
["invalid value"] + get_invalid_cases("string", nullable=True),
93+
),
94+
(
95+
"prefers-color-scheme",
96+
["light", "dark"],
97+
["invalid value"] + get_invalid_cases("string", nullable=True),
98+
),
99+
(
100+
"prefers-contrast",
101+
["no-preference", "more", "less", "custom"],
102+
["invalid value"] + get_invalid_cases("string", nullable=True),
103+
),
104+
(
105+
"prefers-reduced-data",
106+
["no-preference", "reduce"],
107+
["invalid value"] + get_invalid_cases("string", nullable=True),
108+
),
109+
(
110+
"prefers-reduced-motion",
111+
["no-preference", "reduce"],
112+
["invalid value"] + get_invalid_cases("string", nullable=True),
113+
),
114+
(
115+
"prefers-reduced-transparency",
116+
["no-preference", "reduce"],
117+
["invalid value"] + get_invalid_cases("string", nullable=True),
118+
),
119+
(
120+
"scan",
121+
["interlace", "progressive"],
122+
["invalid value"] + get_invalid_cases("string", nullable=True),
123+
),
124+
(
125+
"scripting",
126+
["none", "initial-only", "enabled"],
127+
["invalid value"] + get_invalid_cases("string", nullable=True),
128+
),
129+
(
130+
"update",
131+
["none", "slow", "fast"],
132+
["invalid value"] + get_invalid_cases("string", nullable=True),
133+
),
134+
(
135+
"vertical-viewport-segments",
136+
[1, 2],
137+
[-1] + get_invalid_cases("number", nullable=True),,
138+
),
139+
(
140+
"video-color-gamut",
141+
["srgb", "p3", "rec2020"],
142+
["invalid value"] + get_invalid_cases("string", nullable=True),
143+
),
144+
(
145+
"video-dynamic-range",
146+
["standard", "high"],
147+
["invalid value"] + get_invalid_cases("string", nullable=True),
148+
),
70149
]
150+

webdriver/tests/bidi/emulation/set_media_features_override/contexts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,16 @@ async def test_frame(
129129
bidi_session,
130130
url,
131131
match_media,
132-
top_context,
132+
new_tab,
133133
create_iframe,
134134
domain,
135135
default_prefers_color_scheme,
136136
some_prefers_color_scheme,
137137
):
138-
iframe_id = await create_iframe(top_context, url("/", domain=domain))
138+
iframe_id = await create_iframe(new_tab, url("/", domain=domain))
139139

140140
await bidi_session.emulation.set_media_features_override(
141-
contexts=[top_context["context"]],
141+
contexts=[new_tab["context"]],
142142
features={"prefers-color-scheme": some_prefers_color_scheme},
143143
)
144144

@@ -150,7 +150,7 @@ async def test_frame(
150150
)
151151

152152
await bidi_session.emulation.set_media_features_override(
153-
contexts=[top_context["context"]],
153+
contexts=[new_tab["context"]],
154154
features=None,
155155
)
156156

webdriver/tests/bidi/emulation/set_media_features_override/invalid.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# META: timeout=long
2+
13
import pytest
24

35
import webdriver.bidi.error as error
@@ -123,19 +125,13 @@ async def test_params_features_invalid_type(bidi_session, top_context, value):
123125
)
124126

125127

126-
async def test_params_features_unknown_feature(bidi_session, top_context):
127-
with pytest.raises(error.InvalidArgumentException):
128-
await bidi_session.emulation.set_media_features_override(
129-
features={"unknown-feature": "foo"},
130-
contexts=[top_context["context"]],
131-
)
132-
133128

134129
@pytest.mark.parametrize(
135130
"feature, value",
136131
[
137-
(feature, "some invalid value")
138-
for feature, _ in MEDIA_FEATURE_NAMES_AND_SAMPLE_VALUES
132+
(feature, value)
133+
for feature, _, invalid_values in MEDIA_FEATURE_NAMES_AND_SAMPLE_VALUES
134+
for value in invalid_values
139135
],
140136
)
141137
async def test_params_features_invalid_value(

webdriver/tests/bidi/emulation/set_media_features_override/media_features.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# META: timeout=long
2+
13
import pytest
24

35
from . import MEDIA_FEATURE_NAMES_AND_SAMPLE_VALUES
@@ -6,7 +8,14 @@
68
pytestmark = pytest.mark.asyncio
79

810

9-
@pytest.mark.parametrize("feature, value", MEDIA_FEATURE_NAMES_AND_SAMPLE_VALUES)
11+
@pytest.mark.parametrize(
12+
"feature, value",
13+
[
14+
(feature, value)
15+
for feature, values, _ in MEDIA_FEATURE_NAMES_AND_SAMPLE_VALUES
16+
for value in values
17+
],
18+
)
1019
async def test_media_feature_set_override_and_reset(
1120
bidi_session, top_context, match_media, feature, value
1221
):

0 commit comments

Comments
 (0)