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

css mediaqueries : add tests for negated conditions #36911

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
40 changes: 40 additions & 0 deletions css/mediaqueries/negation-001.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!doctype html>
<html>
<head>
<title>Test: support for negated conditions in Media Queries</title>
<link rel="author" title="Romain Menke" href="https://github.com/romainmenke">
<link rel="help" href="https://www.w3.org/TR/mediaqueries-4/#media-conditions">
<link rel="match" href="../reference/ref-filled-green-100px-square.xht">
<meta name="assert" content="Test passes if negated conditions are correctly evaluated.">
<style>
div {
background-color: red;
height: 20px;
width: 100px;
}
@media not print {
.test1 { background: green; }
}
@media not (monochrome) {
.test2 { background: green; }
}
@media (not (monochrome)) {
.test3 { background: green; }
}
@media not (not (color)) {
.test4 { background: green; }
}
@media not ((unknown) or (monochrome)) {
.test5 { background: green; }
}
</style>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div class="test1"></div>
<div class="test2"></div>
<div class="test3"></div>
<div class="test4"></div>
<div class="test5"></div>
</body>
</html>
44 changes: 44 additions & 0 deletions css/mediaqueries/negation-002.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!doctype html>
<html>
<head>
<title>Test: It is invalid to mix "and" and "or" and "not" at the same level of a media query.</title>
<link rel="author" title="Romain Menke" href="https://github.com/romainmenke">
<link rel="help" href="https://www.w3.org/TR/mediaqueries-4/#media-conditions">
<link rel="match" href="../reference/ref-filled-green-100px-square.xht">
<meta name="assert" content="Test passes if invalid combinations with 'not' do not apply.">
<style>
div {
background-color: red;
height: 25px;
width: 100px;
}

@media ((color) and (color)) {
/* Only green when the browser supports the general syntax */
div {
background-color: green;
}
}

@media (not (monochrome) and (color)) {
.test1 { background: red; }
}
@media (not (monochrome) or (color)) {
.test2 { background: red; }
}
@media ((color) and not (monochrome)) {
.test3 { background: red; }
}
@media ((color) or not (monochrome)) {
.test4 { background: red; }
}
</style>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div class="test1"></div>
<div class="test2"></div>
<div class="test3"></div>
<div class="test4"></div>
</body>
</html>