Skip to content

Commit ea1821d

Browse files
authoredJan 18, 2022
Update and complete tests for using reserved keywords as media types (#32422)
1 parent ba48453 commit ea1821d

5 files changed

+57
-0
lines changed
 

‎css/mediaqueries/mq-invalid-media-type-001.html

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
@media not and {
1919
div { background-color: red; }
2020
}
21+
@media and {
22+
div { background-color: red; }
23+
}
2124
</style>
2225
</head>
2326
<body>

‎css/mediaqueries/mq-invalid-media-type-002.html

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
@media not or {
1919
div { background-color: red; }
2020
}
21+
@media or {
22+
div { background-color: red; }
23+
}
2124
</style>
2225
</head>
2326
<body>

‎css/mediaqueries/mq-invalid-media-type-003.html

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
@media not not {
1919
div { background-color: red; }
2020
}
21+
@media not {
22+
div { background-color: red; }
23+
}
2124
</style>
2225
</head>
2326
<body>

‎css/mediaqueries/mq-invalid-media-type-004.html

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
@media not only {
1919
div { background-color: red; }
2020
}
21+
@media only {
22+
div { background-color: red; }
23+
}
2124
</style>
2225
</head>
2326
<body>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<meta charset="utf-8">
4+
<title>Mediaqueries-3 test: parsing hanging-punctuation with invalid values</title>
5+
<link rel="help" href="https://www.w3.org/TR/css3-mediaqueries/#error-handling">
6+
<link rel="author" title="Florian Rivoal" href="https://florian.rivoal.net/">
7+
<meta name="flags" content="invalid">
8+
<meta name="assert" content="media types ''not'', ''and'', ''only'' and ''or'' must not be treated as unknown media types, but rather trigger the malformed query clause.">
9+
<script src="/resources/testharness.js"></script>
10+
<script src="/resources/testharnessreport.js"></script>
11+
<style>
12+
@media not and {
13+
div { background-color: red; }
14+
}
15+
@media and {
16+
div { background-color: red; }
17+
}
18+
@media not or {
19+
div { background-color: red; }
20+
}
21+
@media or {
22+
div { background-color: red; }
23+
}
24+
@media not not {
25+
div { background-color: red; }
26+
}
27+
@media not {
28+
div { background-color: red; }
29+
}
30+
@media not only {
31+
div { background-color: red; }
32+
}
33+
@media only {
34+
div { background-color: red; }
35+
}
36+
</style>
37+
<script>
38+
var queries = document.styleSheets[0].cssRules;
39+
test(() => {
40+
for (const query of queries) {
41+
assert_equals(query.conditionText, "not all");
42+
}
43+
assert_equals(queries.length, 8, "invalid rules must be treated as 'not all', not dropped");
44+
}, "syntactical MQ keywords used as media types are a syntax error");
45+
</script>

0 commit comments

Comments
 (0)