Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests for error handling of layer as a media type #33940

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions css/mediaqueries/mq-invalid-media-type-layer-001.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<title>Test: syntax error handling in Media Queries</title>
<link rel="author" title="Florian Rivoal" href="http://florian.rivoal.net/">
<link rel="help" href="https://drafts.csswg.org/mediaqueries4/#error-handling">
<link rel="match" href="../reference/ref-filled-green-100px-square.xht">
<meta name="assert" content="'layer' is an invalid media type">
<meta name="flags" content="invalid">
<style>
div {
width: 100px;
height: 100px;
}
@media all {
div { background-color: green; }
}
@media not layer {
div { background-color: red; }
}
@media layer {
div { background-color: red; }
}
</style>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div></div>
</body>
</html>

27 changes: 27 additions & 0 deletions css/mediaqueries/mq-invalid-media-type-layer-002.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!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="'layer' must not be treated as an unknown media type, but rather trigger the malformed query clause.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
@media not layer {
body { background-color: red; }
}
@media layer {
body { 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, 2, "invalid rules must be treated as 'not all', not dropped");
}, "'layer' used as media types is a syntax error");
</script>