diff --git a/tests/cssmediaqueries/config.yml b/tests/cssmediaqueries/config.yml new file mode 100644 index 0000000..4552386 --- /dev/null +++ b/tests/cssmediaqueries/config.yml @@ -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" diff --git a/tests/cssmediaqueries/fixture.html b/tests/cssmediaqueries/fixture.html new file mode 100644 index 0000000..ab1b818 --- /dev/null +++ b/tests/cssmediaqueries/fixture.html @@ -0,0 +1 @@ + diff --git a/tests/cssmediaqueries/iframe.html b/tests/cssmediaqueries/iframe.html new file mode 100644 index 0000000..74c7e19 --- /dev/null +++ b/tests/cssmediaqueries/iframe.html @@ -0,0 +1,11 @@ + + + + + + +
Test Content
+ + diff --git a/tests/cssmediaqueries/test.js b/tests/cssmediaqueries/test.js new file mode 100644 index 0000000..5069995 --- /dev/null +++ b/tests/cssmediaqueries/test.js @@ -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" ); + } +});