summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/cssom/MediaList2.xhtml
blob: 73acbdec25c6fc940f4ed8df5210d8c6a608e34e (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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Test: the MediaList interface</title>
<link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com"/>
<link rel="help" href="http://www.w3.org/TR/cssom-1/#the-medialist-interface"/>
<link rel="help" href="http://dev.w3.org/2006/webapi/WebIDL/#getownproperty"/>
<style media="screen, print" id="test-style"></style>
<script src="/resources/testharness.js"/>
<script src="/resources/testharnessreport.js"/>
</head>
<body>
<div id="log"/>
<script>
test(function() {
  var ss = document.styleSheets[0];
  assert_equals(ss.ownerNode.id, "test-style", "Got the wrong style element");

  var media = ss.media;
  test(function() {
    // https://www.w3.org/Bugs/Public/show_bug.cgi?id=17526
    assert_equals(media.mediaText, "screen, print", "Serialization should be \"screen, print\"");
  }, "MediaList.mediaText");

  test(function() {
    assert_equals(media.length, 2, "Got wrong number of media");
  }, "MediaList.length");

  test(function() {
    assert_equals(media[-1], undefined, "media[-1] should return undefined");
    assert_equals(media[0], "screen", "media[0] should return \"screen\"");
    assert_equals(media[1], "print", "media[1] should return \"print\"");
    assert_equals(media[2], undefined, "media[2] should return undefined");
  }, "MediaList getter");

  test(function() {
    assert_equals(media.item(-1), null, "media.item(-1) should return null");
    assert_equals(media.item(0), "screen", "media.item(0) should return \"screen\"");
    assert_equals(media.item(1), "print", "media.item(1) should return \"print\"");
    assert_equals(media.item(2), null, "media.item(2) should return null");
  }, "MediaList.item");
}, "MediaList");
</script>
</body>
</html>