2 <style type=
"text/css">@media screen
{ }</style>
3 <script src=
"../../resources/testharness.js"></script>
4 <script src=
"../../resources/testharnessreport.js"></script>
7 var rules
= document
.styleSheets
[0].cssRules
;
8 var mediaList
= rules
.item(0).media
;
13 mediaList
.mediaText
= "screen";
14 mediaList
.appendMedium("tv, screen");
15 assert_equals(mediaList
.mediaText
, "screen");
16 // CSSOM 4.1: Parsing media query returns none as
17 // there are more than one; terminate steps.
18 }, "Add 'tv, screen' to 'screen'");
21 mediaList
.mediaText
= "screen";
22 mediaList
.appendMedium("tv");
23 assert_equals(mediaList
.mediaText
, "screen, tv");
24 // The valid media query is appended.
25 }, "Add 'tv' to 'screen'");
28 mediaList
.mediaText
= "screen, tv";
29 mediaList
.appendMedium("tv");
30 assert_equals(mediaList
.mediaText
, "screen, tv");
31 // CSSOM says to ignore if it exists, terminate steps.
32 }, "Add 'tv' to 'screen, tv'");
35 mediaList
.mediaText
= "screen, tv";
36 mediaList
.appendMedium("screen");
37 assert_equals(mediaList
.mediaText
, "screen, tv");
38 // CSSOM says to ignore if it exists, where as
39 // CSS 2.1 says to remove existing and then add
41 // http://dev.w3.org/csswg/cssom/#dom-medialist-appendmedium
42 // http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html
43 }, "Add 'screen' to 'screen, tv'");
46 mediaList
.mediaText
= "screen, tv";
47 mediaList
.appendMedium(" ");
48 // Ignored; terminate steps.
49 assert_equals(mediaList
.mediaText
, "screen, tv");
50 }, "Add ' ' to 'screen, tv'");
53 mediaList
.mediaText
= "screen, tv";
54 mediaList
.appendMedium("");
55 // Ignored; terminate steps.
56 assert_equals(mediaList
.mediaText
, "screen, tv");
57 }, "Add '' to 'screen, tv'");
60 mediaList
.mediaText
= "screen, tv";
61 mediaList
.appendMedium(",");
62 assert_equals(mediaList
.mediaText
, "screen, tv");
63 // CSSOM 4.1: Parsing media query returns none as
64 // there are more than one; terminate steps.
65 }, "Add ',' to 'screen, tv'");
68 mediaList
.mediaText
= "screen, tv";
69 mediaList
.appendMedium("&invalid");
70 assert_equals(mediaList
.mediaText
, "screen, tv, not all");
71 // Ignored; terminate steps.
72 }, "Add '&invalid' to 'screen, tv'");
75 mediaList
.mediaText
= "screen, tv";
76 mediaList
.appendMedium("not all");
77 assert_equals(mediaList
.mediaText
, "screen, tv, not all");
78 }, "Add 'not all' to 'screen, tv'");
81 mediaList
.mediaText
= "screen, tv";
82 mediaList
.appendMedium("#?:/");
83 assert_equals(mediaList
.mediaText
, "screen, tv, not all");
84 // Ignored; terminate steps.
85 }, "Add '#?:/' to 'screen, tv'");
88 mediaList
.mediaText
= "screen, tv";
89 assert_throws({ name
: "TypeError" },
90 function () { document
.appendMedium(); },
91 "Not enough arguments");
92 }, "Add without argument");
97 mediaList
.mediaText
= "screen, tv, not all";
98 mediaList
.deleteMedium("&invalid");
99 // Ignored; terminate steps.
100 assert_equals(mediaList
.mediaText
, "screen, tv");
101 }, "Remove '&invalid' from 'screen, tv, not all'");
104 mediaList
.mediaText
= "screen, tv";
105 assert_throws("NOT_FOUND_ERR",
106 function () { mediaList
.deleteMedium("not all"); }
108 // Not found; throw NotFoundError.
109 }, "Remove 'not all' from 'screen, tv'");
112 mediaList
.mediaText
= "screen, tv";
113 assert_throws("NOT_FOUND_ERR",
114 function () { mediaList
.deleteMedium("cow"); }
116 // Not found; throw NotFoundError.
117 }, "Remove 'cow' from 'screen, tv'");
120 mediaList
.mediaText
= "screen, tv, not all";
121 mediaList
.deleteMedium("not all");
122 assert_equals(mediaList
.mediaText
, "screen, tv");
123 // Remove any media query from the collection of media queries
124 // for which comparing the media query returns true.
125 }, "Remove 'not all' from 'screen, tv, not all'");
128 mediaList
.mediaText
= "screen, tv";
129 mediaList
.deleteMedium("tv");
130 assert_equals(mediaList
.mediaText
, "screen");
131 // Remove any media query from the collection of media queries
132 // for which comparing the media query returns true.
133 }, "Remove 'tv' from 'screen, tv'");
136 mediaList
.mediaText
= "not all, not all, tv, not all";
137 mediaList
.deleteMedium("not all");
138 assert_equals(mediaList
.mediaText
, "tv");
139 // Remove any media query from the collection of media queries
140 // for which comparing the media query returns true.
141 }, "Remove 'not all' from 'not all, not all, tv, not all'");
144 mediaList
.mediaText
= "not all, not all, tv, not all";
145 mediaList
.deleteMedium("tv");
146 assert_equals(mediaList
.mediaText
, "not all, not all, not all");
147 // Remove any media query from the collection of media queries
148 // for which comparing the media query returns true.
149 }, "Remove 'tv' from 'not all, not all, tv, not all'");
152 mediaList
.mediaText
= "tv, print, screen";
153 mediaList
.deleteMedium("tv, print");
154 assert_equals(mediaList
.mediaText
, "tv, print, screen");
155 // CSSOM 4.1: Parsing media query returns none as
156 // there are more than one; terminate steps.
157 }, "Remove 'tv, print' from 'screen, tv, screen'");
160 mediaList
.mediaText
= "screen, tv, not all";
161 mediaList
.deleteMedium("#?:/");
162 // Ignored; terminate steps.
163 assert_equals(mediaList
.mediaText
, "screen, tv");
164 }, "Remove '#?:/' from 'screen, tv, not all'");
167 mediaList
.mediaText
= "tv, print, screen";
168 assert_throws({ name
: "TypeError" },
169 function () { document
.deleteMedium(); },
170 "Not enough arguments");
171 }, "Remove without argument");