Skip to content
Open
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
5 changes: 5 additions & 0 deletions tests/cssmediaqueries/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
r: 1
spec: "http://www.w3.org/TR/css3-mediaqueries/"
sources: [ "http://hg.csswg.org/test/file/a3eb84d8b3a8/contributors/anne/submitted/mediaqueries" ]
title: "CSS3 MediaQueries"
1 change: 1 addition & 0 deletions tests/cssmediaqueries/fixture.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe id="cssmediaqueries" src="/tests/cssmediaqueries/iframe.html"></iframe>
11 changes: 11 additions & 0 deletions tests/cssmediaqueries/iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<style type="text/css" id="style">
#test { position: relative; }
</style>
</head>
<body>
<div id="test">Test Content</div>
</body>
</html>
20 changes: 20 additions & 0 deletions tests/cssmediaqueries/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
test("Media Queries matchMedia API exists", function() {
assert( H.API( window, "matchMedia", true), "matchMedia supported" );
});

test("Media Queries matchMedia querying", function( async ) {
var iframe = document.getElementById("cssmediaqueries"),
iwindow = iframe.contentWindow,
matches = {};

if ( !iwindow.matchMedia ) {
assert( false, "matchMedia is not supported, skipping tests" );
} else {

matches.pass = iwindow.matchMedia("screen and (max-width: 500px)");
matches.fail = iwindow.matchMedia("example { body { background:red } }");

assert( matches.pass && matches.pass.matches, "matchMedia expects passing results" );
assert( matches.fail && !matches.fail.matches, "matchMedia expects failing results" );
}
});