Skip to content

Commit

Permalink
Update and complete tests for using reserved keywords as media types (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
frivoal committed Jan 18, 2022
1 parent ba48453 commit ea1821d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions css/mediaqueries/mq-invalid-media-type-001.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
@media not and {
div { background-color: red; }
}
@media and {
div { background-color: red; }
}
</style>
</head>
<body>
Expand Down
3 changes: 3 additions & 0 deletions css/mediaqueries/mq-invalid-media-type-002.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
@media not or {
div { background-color: red; }
}
@media or {
div { background-color: red; }
}
</style>
</head>
<body>
Expand Down
3 changes: 3 additions & 0 deletions css/mediaqueries/mq-invalid-media-type-003.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
@media not not {
div { background-color: red; }
}
@media not {
div { background-color: red; }
}
</style>
</head>
<body>
Expand Down
3 changes: 3 additions & 0 deletions css/mediaqueries/mq-invalid-media-type-004.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
@media not only {
div { background-color: red; }
}
@media only {
div { background-color: red; }
}
</style>
</head>
<body>
Expand Down
45 changes: 45 additions & 0 deletions css/mediaqueries/mq-invalid-media-type-005.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>Mediaqueries-3 test: parsing hanging-punctuation with invalid values</title>
<link rel="help" href="https://www.w3.org/TR/css3-mediaqueries/#error-handling">
<link rel="author" title="Florian Rivoal" href="https://florian.rivoal.net/">
<meta name="flags" content="invalid">
<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.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
@media not and {
div { background-color: red; }
}
@media and {
div { background-color: red; }
}
@media not or {
div { background-color: red; }
}
@media or {
div { background-color: red; }
}
@media not not {
div { background-color: red; }
}
@media not {
div { background-color: red; }
}
@media not only {
div { background-color: red; }
}
@media only {
div { background-color: red; }
}
</style>
<script>
var queries = document.styleSheets[0].cssRules;
test(() => {
for (const query of queries) {
assert_equals(query.conditionText, "not all");
}
assert_equals(queries.length, 8, "invalid rules must be treated as 'not all', not dropped");
}, "syntactical MQ keywords used as media types are a syntax error");
</script>

0 comments on commit ea1821d

Please sign in to comment.