Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>CSS Variables Allowed Syntax</title> |
michael@0 | 5 | <link rel="author" title="L. David Baron" href="http://dbaron.org/"> |
michael@0 | 6 | <link rel="author" title="Mozilla Corporation" href="http://mozilla.com/" /> |
michael@0 | 7 | <link rel="help" href="http://www.w3.org/TR/css3-conditional/#the-cssgroupingrule-interface"> |
michael@0 | 8 | <meta name="assert" content="requirements in definition of insertRule"> |
michael@0 | 9 | <script src="/resources/testharness.js"></script> |
michael@0 | 10 | <script src="/resources/testharnessreport.js"></script> |
michael@0 | 11 | <style id="style"> |
michael@0 | 12 | @media print {} |
michael@0 | 13 | </style> |
michael@0 | 14 | <script id="metadata_cache">/* |
michael@0 | 15 | { |
michael@0 | 16 | "rule_type": {}, |
michael@0 | 17 | "rule_length": {}, |
michael@0 | 18 | "insert_import_throws": {}, |
michael@0 | 19 | "insert_index_throws1": {}, |
michael@0 | 20 | "insert_index_throws2": {}, |
michael@0 | 21 | "insert_media_succeed": {}, |
michael@0 | 22 | "insert_style_succeed": {}, |
michael@0 | 23 | "insert_bad_media_throw": {}, |
michael@0 | 24 | "insert_empty_throw": {}, |
michael@0 | 25 | "insert_garbage_after_media_throw": {}, |
michael@0 | 26 | "insert_garbage_after_style_throw": {}, |
michael@0 | 27 | "insert_two_media_throw": {}, |
michael@0 | 28 | "insert_style_media_throw": {}, |
michael@0 | 29 | "insert_media_style_throw": {}, |
michael@0 | 30 | "insert_two_style_throw": {}, |
michael@0 | 31 | "insert_retval": {} |
michael@0 | 32 | } |
michael@0 | 33 | */</script> |
michael@0 | 34 | </head> |
michael@0 | 35 | <body onload="run()"> |
michael@0 | 36 | <div id=log></div> |
michael@0 | 37 | <div id="test"></div> |
michael@0 | 38 | <script> |
michael@0 | 39 | |
michael@0 | 40 | var sheet = document.getElementById("style").sheet; |
michael@0 | 41 | |
michael@0 | 42 | var grouping_rule = sheet.cssRules[0]; |
michael@0 | 43 | |
michael@0 | 44 | test(function() { |
michael@0 | 45 | assert_equals(grouping_rule.type, CSSRule.MEDIA_RULE, |
michael@0 | 46 | "Rule type of @media rule"); |
michael@0 | 47 | }, |
michael@0 | 48 | "rule_type"); |
michael@0 | 49 | |
michael@0 | 50 | test(function() { |
michael@0 | 51 | assert_equals(grouping_rule.cssRules.length, 0, |
michael@0 | 52 | "Starting cssRules.length of @media rule"); |
michael@0 | 53 | }, |
michael@0 | 54 | "rule_length"); |
michael@0 | 55 | |
michael@0 | 56 | test(function() { |
michael@0 | 57 | assert_throws("HIERARCHY_REQUEST_ERR", |
michael@0 | 58 | function() { |
michael@0 | 59 | grouping_rule.insertRule("@import url(foo.css);", 0); |
michael@0 | 60 | }, |
michael@0 | 61 | "inserting a disallowed rule should throw HIERARCHY_REQUEST_ERR"); |
michael@0 | 62 | }, |
michael@0 | 63 | "insert_import_throws"); |
michael@0 | 64 | |
michael@0 | 65 | test(function() { |
michael@0 | 66 | assert_throws("INDEX_SIZE_ERR", |
michael@0 | 67 | function() { |
michael@0 | 68 | grouping_rule.insertRule("p { color: green }", 1); |
michael@0 | 69 | }, |
michael@0 | 70 | "inserting at a bad index throws INDEX_SIZE_ERR"); |
michael@0 | 71 | }, |
michael@0 | 72 | "insert_index_throws1"); |
michael@0 | 73 | test(function() { |
michael@0 | 74 | grouping_rule.insertRule("p { color: green }", 0); |
michael@0 | 75 | assert_equals(grouping_rule.cssRules.length, 1, |
michael@0 | 76 | "Modified cssRules.length of @media rule"); |
michael@0 | 77 | grouping_rule.insertRule("p { color: blue }", 1); |
michael@0 | 78 | assert_equals(grouping_rule.cssRules.length, 2, |
michael@0 | 79 | "Modified cssRules.length of @media rule"); |
michael@0 | 80 | grouping_rule.insertRule("p { color: aqua }", 1); |
michael@0 | 81 | assert_equals(grouping_rule.cssRules.length, 3, |
michael@0 | 82 | "Modified cssRules.length of @media rule"); |
michael@0 | 83 | assert_throws("INDEX_SIZE_ERR", |
michael@0 | 84 | function() { |
michael@0 | 85 | grouping_rule.insertRule("p { color: green }", 4); |
michael@0 | 86 | }, |
michael@0 | 87 | "inserting at a bad index throws INDEX_SIZE_ERR"); |
michael@0 | 88 | assert_equals(grouping_rule.cssRules.length, 3, |
michael@0 | 89 | "Modified cssRules.length of @media rule"); |
michael@0 | 90 | }, |
michael@0 | 91 | "insert_index_throws2"); |
michael@0 | 92 | |
michael@0 | 93 | test(function() { |
michael@0 | 94 | while (grouping_rule.cssRules.length > 0) { |
michael@0 | 95 | grouping_rule.deleteRule(0); |
michael@0 | 96 | } |
michael@0 | 97 | grouping_rule.insertRule("@media print {}", 0); |
michael@0 | 98 | assert_equals(grouping_rule.cssRules.length, 1, |
michael@0 | 99 | "Modified cssRules.length of @media rule"); |
michael@0 | 100 | assert_equals(grouping_rule.cssRules[0].type, CSSRule.MEDIA_RULE, |
michael@0 | 101 | "inserting syntactically correct media rule succeeds"); |
michael@0 | 102 | }, |
michael@0 | 103 | "insert_media_succeed"); |
michael@0 | 104 | test(function() { |
michael@0 | 105 | while (grouping_rule.cssRules.length > 0) { |
michael@0 | 106 | grouping_rule.deleteRule(0); |
michael@0 | 107 | } |
michael@0 | 108 | grouping_rule.insertRule("p { color: yellow }", 0); |
michael@0 | 109 | assert_equals(grouping_rule.cssRules.length, 1, |
michael@0 | 110 | "Modified cssRules.length of @media rule"); |
michael@0 | 111 | assert_equals(grouping_rule.cssRules[0].type, CSSRule.STYLE_RULE, |
michael@0 | 112 | "inserting syntactically correct style rule succeeds"); |
michael@0 | 113 | }, |
michael@0 | 114 | "insert_style_succeed"); |
michael@0 | 115 | test(function() { |
michael@0 | 116 | while (grouping_rule.cssRules.length > 0) { |
michael@0 | 117 | grouping_rule.deleteRule(0); |
michael@0 | 118 | } |
michael@0 | 119 | assert_throws("SYNTAX_ERR", |
michael@0 | 120 | function() { |
michael@0 | 121 | grouping_rule.insertRule("@media bad syntax;", 0); |
michael@0 | 122 | }, |
michael@0 | 123 | "inserting syntactically invalid rule throws syntax error"); |
michael@0 | 124 | assert_equals(grouping_rule.cssRules.length, 0, |
michael@0 | 125 | "Modified cssRules.length of @media rule"); |
michael@0 | 126 | }, |
michael@0 | 127 | "insert_bad_media_throw"); |
michael@0 | 128 | test(function() { |
michael@0 | 129 | while (grouping_rule.cssRules.length > 0) { |
michael@0 | 130 | grouping_rule.deleteRule(0); |
michael@0 | 131 | } |
michael@0 | 132 | assert_throws("SYNTAX_ERR", |
michael@0 | 133 | function() { |
michael@0 | 134 | grouping_rule.insertRule("", 0); |
michael@0 | 135 | }, |
michael@0 | 136 | "inserting empty rule throws syntax error"); |
michael@0 | 137 | assert_equals(grouping_rule.cssRules.length, 0, |
michael@0 | 138 | "Modified cssRules.length of @media rule"); |
michael@0 | 139 | }, |
michael@0 | 140 | "insert_empty_throw"); |
michael@0 | 141 | test(function() { |
michael@0 | 142 | while (grouping_rule.cssRules.length > 0) { |
michael@0 | 143 | grouping_rule.deleteRule(0); |
michael@0 | 144 | } |
michael@0 | 145 | assert_throws("SYNTAX_ERR", |
michael@0 | 146 | function() { |
michael@0 | 147 | grouping_rule.insertRule("@media print {} foo", 0); |
michael@0 | 148 | }, |
michael@0 | 149 | "inserting rule with garbage afterwards throws syntax error"); |
michael@0 | 150 | assert_equals(grouping_rule.cssRules.length, 0, |
michael@0 | 151 | "Modified cssRules.length of @media rule"); |
michael@0 | 152 | }, |
michael@0 | 153 | "insert_garbage_after_media_throw"); |
michael@0 | 154 | test(function() { |
michael@0 | 155 | while (grouping_rule.cssRules.length > 0) { |
michael@0 | 156 | grouping_rule.deleteRule(0); |
michael@0 | 157 | } |
michael@0 | 158 | assert_throws("SYNTAX_ERR", |
michael@0 | 159 | function() { |
michael@0 | 160 | grouping_rule.insertRule("p { color: yellow } foo", 0); |
michael@0 | 161 | }, |
michael@0 | 162 | "inserting rule with garbage afterwards throws syntax error"); |
michael@0 | 163 | assert_equals(grouping_rule.cssRules.length, 0, |
michael@0 | 164 | "Modified cssRules.length of @media rule"); |
michael@0 | 165 | }, |
michael@0 | 166 | "insert_garbage_after_style_throw"); |
michael@0 | 167 | test(function() { |
michael@0 | 168 | while (grouping_rule.cssRules.length > 0) { |
michael@0 | 169 | grouping_rule.deleteRule(0); |
michael@0 | 170 | } |
michael@0 | 171 | assert_throws("SYNTAX_ERR", |
michael@0 | 172 | function() { |
michael@0 | 173 | grouping_rule.insertRule("@media print {} @media print {}", 0); |
michael@0 | 174 | }, |
michael@0 | 175 | "inserting multiple rules throws syntax error"); |
michael@0 | 176 | assert_equals(grouping_rule.cssRules.length, 0, |
michael@0 | 177 | "Modified cssRules.length of @media rule"); |
michael@0 | 178 | }, |
michael@0 | 179 | "insert_two_media_throw"); |
michael@0 | 180 | test(function() { |
michael@0 | 181 | while (grouping_rule.cssRules.length > 0) { |
michael@0 | 182 | grouping_rule.deleteRule(0); |
michael@0 | 183 | } |
michael@0 | 184 | assert_throws("SYNTAX_ERR", |
michael@0 | 185 | function() { |
michael@0 | 186 | grouping_rule.insertRule("p { color: yellow } @media print {}", 0); |
michael@0 | 187 | }, |
michael@0 | 188 | "inserting multiple rules throws syntax error"); |
michael@0 | 189 | assert_equals(grouping_rule.cssRules.length, 0, |
michael@0 | 190 | "Modified cssRules.length of @media rule"); |
michael@0 | 191 | }, |
michael@0 | 192 | "insert_style_media_throw"); |
michael@0 | 193 | test(function() { |
michael@0 | 194 | while (grouping_rule.cssRules.length > 0) { |
michael@0 | 195 | grouping_rule.deleteRule(0); |
michael@0 | 196 | } |
michael@0 | 197 | assert_throws("SYNTAX_ERR", |
michael@0 | 198 | function() { |
michael@0 | 199 | grouping_rule.insertRule("@media print {} p { color: yellow }", 0); |
michael@0 | 200 | }, |
michael@0 | 201 | "inserting multiple rules throws syntax error"); |
michael@0 | 202 | assert_equals(grouping_rule.cssRules.length, 0, |
michael@0 | 203 | "Modified cssRules.length of @media rule"); |
michael@0 | 204 | }, |
michael@0 | 205 | "insert_media_style_throw"); |
michael@0 | 206 | test(function() { |
michael@0 | 207 | while (grouping_rule.cssRules.length > 0) { |
michael@0 | 208 | grouping_rule.deleteRule(0); |
michael@0 | 209 | } |
michael@0 | 210 | assert_throws("SYNTAX_ERR", |
michael@0 | 211 | function() { |
michael@0 | 212 | grouping_rule.insertRule("p { color: yellow } p { color: yellow }", 0); |
michael@0 | 213 | }, |
michael@0 | 214 | "inserting multiple rules throws syntax error"); |
michael@0 | 215 | assert_equals(grouping_rule.cssRules.length, 0, |
michael@0 | 216 | "Modified cssRules.length of @media rule"); |
michael@0 | 217 | }, |
michael@0 | 218 | "insert_two_style_throw"); |
michael@0 | 219 | |
michael@0 | 220 | test(function() { |
michael@0 | 221 | while (grouping_rule.cssRules.length > 0) { |
michael@0 | 222 | grouping_rule.deleteRule(0); |
michael@0 | 223 | } |
michael@0 | 224 | var res = grouping_rule.insertRule("p { color: green }", 0); |
michael@0 | 225 | assert_equals(res, 0, "return value should be index"); |
michael@0 | 226 | assert_equals(grouping_rule.cssRules.length, 1, |
michael@0 | 227 | "Modified cssRules.length of @media rule"); |
michael@0 | 228 | res = grouping_rule.insertRule("p { color: green }", 0); |
michael@0 | 229 | assert_equals(res, 0, "return value should be index"); |
michael@0 | 230 | assert_equals(grouping_rule.cssRules.length, 2, |
michael@0 | 231 | "Modified cssRules.length of @media rule"); |
michael@0 | 232 | res = grouping_rule.insertRule("p { color: green }", 2); |
michael@0 | 233 | assert_equals(res, 2, "return value should be index"); |
michael@0 | 234 | assert_equals(grouping_rule.cssRules.length, 3, |
michael@0 | 235 | "Modified cssRules.length of @media rule"); |
michael@0 | 236 | }, |
michael@0 | 237 | "insert_retval"); |
michael@0 | 238 | |
michael@0 | 239 | |
michael@0 | 240 | </script> |
michael@0 | 241 | </body> |
michael@0 | 242 | </html> |
michael@0 | 243 |