summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/media/matchmedium-query-api.html
blob: c91f57e5636c782541f9225a8cb266f5e91aeed2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<html>
<head>
<title>Test CSSOM View module: Media interface</title>
<style type="text/css">

</style>
<script type="text/javascript" charset="utf-8">
  if (window.testRunner)
    testRunner.dumpAsText();
  
  function log(m)
  {
    var results = document.getElementById('results');
    results.innerHTML += m + '<br>';
  }
  
  function testQuery(query, expected)
  {
    var isTrue = window.styleMedia.matchMedium(query);

    var message = '\"' + query + '\" evaluates to ' + (isTrue ? 'true' : 'false');
    message += (isTrue == expected) ? ': PASS' : ': FAIL';
    log(message);
  }
  
  function runTests()
  {
    testQuery('screen', true);
    testQuery('projection', false);

    testQuery('all and (color)', true);
    testQuery('not projection and (color)', true);
    testQuery('(color)', true);
    testQuery('(color', true);
    testQuery('color', false);

    testQuery('garbage', false);

    testQuery('(min-device-width: 100px)', true);
    testQuery('(min-device-width: 50000px)', false);
  }

</script>
</head>
<body onload="runTests()">
  <p>Test the media interface: <a href="http://dev.w3.org/csswg/cssom-view/#the-media-interface" title="CSSOM View Module">http://dev.w3.org/csswg/cssom-view/#the-media-interface</a>.</p>
  <div id="results">
    
  </div>
</body>
</html>