content/base/test/test_bug433533.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=433533
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 433533</title>
michael@0 8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=433533">Mozilla Bug 433533</a>
michael@0 13 <p id="display"></p>
michael@0 14 <div id="content" style="display: none">
michael@0 15
michael@0 16 </div>
michael@0 17 <pre id="test">
michael@0 18 <script class="testbody" type="text/javascript">
michael@0 19
michael@0 20 /** Test for Bug 433533 **/
michael@0 21
michael@0 22 var input = document.createElement("input");
michael@0 23 input.setAttribute("type", "hidden");
michael@0 24 is(input.getAttribute("type"), "hidden", "Setting type attribute didn't work!");
michael@0 25 input.setAttribute("type", "hiDDen");
michael@0 26 is(input.getAttribute("type"), "hiDDen", "Type attribute didn't store the original value");
michael@0 27 is(input.type, "hidden", "Wrong input.type!");
michael@0 28 input.setAttribute("type", "HIDDEN");
michael@0 29 is(input.getAttribute("type"), "HIDDEN", "Type attribute didn't store the original value");
michael@0 30 is(input.type, "hidden", "Wrong input.type!");
michael@0 31
michael@0 32 var td = document.createElement("td");
michael@0 33 td.setAttribute("scope", "rOW");
michael@0 34 is(td.getAttribute("scope"), "rOW", "Scope attribute didn't store the original value");
michael@0 35 td.setAttribute("scope", "row");
michael@0 36 is(td.getAttribute("scope"), "row", "Scope attribute didn't store the original value");
michael@0 37 td.setAttribute("colspan", "100k");
michael@0 38 is(td.getAttribute("colspan"), "100k", "Colspan attribute didn't store the original value");
michael@0 39 td.setAttribute("colspan", " 100 ");
michael@0 40 is(td.getAttribute("colspan"), " 100 ", "Colspan attribute didn't store the original value");
michael@0 41 td.setAttribute("colspan", "100");
michael@0 42 is(td.getAttribute("colspan"), "100", "Colspan attribute didn't store the original value");
michael@0 43
michael@0 44 // Note, if colspan is negative, it is set to 1, because of backwards compatibility.
michael@0 45 // @see nsHTMLTableCellElement::ParseAttribute
michael@0 46 td.setAttribute("colspan", "-100k");
michael@0 47 is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
michael@0 48 td.setAttribute("colspan", " -100 ");
michael@0 49 is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
michael@0 50 td.setAttribute("colspan", "-100");
michael@0 51 is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
michael@0 52
michael@0 53
michael@0 54 td.setAttribute("colspan", "foobar");
michael@0 55 is(td.getAttribute("colspan"), "foobar", "Colspan attribute didn't store the original value");
michael@0 56
michael@0 57 var iframe = document.createElement("iframe");
michael@0 58 iframe.setAttribute("marginwidth", "50%");
michael@0 59 is(iframe.getAttribute("marginwidth"), "50%",
michael@0 60 "Marginwidth attribute didn't store the original value");
michael@0 61 iframe.setAttribute("marginwidth", "50");
michael@0 62 is(iframe.getAttribute("marginwidth"), "50",
michael@0 63 "Marginwidth attribute didn't store the original value");
michael@0 64 iframe.setAttribute("marginwidth", "0");
michael@0 65 is(iframe.getAttribute("marginwidth"), "0",
michael@0 66 "Marginwidth attribute didn't store the original value");
michael@0 67 iframe.setAttribute("marginwidth", "0%");
michael@0 68 is(iframe.getAttribute("marginwidth"), "0%",
michael@0 69 "Marginwidth attribute didn't store the original value");
michael@0 70
michael@0 71 iframe.setAttribute("marginwidth", "9999999999999999999999");
michael@0 72 is(iframe.getAttribute("marginwidth"), "9999999999999999999999",
michael@0 73 "Marginwidth attribute didn't store the original value");
michael@0 74 iframe.setAttribute("marginwidth", "9999999999999999999999%");
michael@0 75 is(iframe.getAttribute("marginwidth"), "9999999999999999999999%",
michael@0 76 "Marginwidth attribute didn't store the original value");
michael@0 77
michael@0 78 iframe.setAttribute("marginwidth", "-9999999999999999999999");
michael@0 79 is(iframe.getAttribute("marginwidth"), "-9999999999999999999999",
michael@0 80 "Marginwidth attribute didn't store the original value");
michael@0 81 iframe.setAttribute("marginwidth", "-9999999999999999999999%");
michael@0 82 is(iframe.getAttribute("marginwidth"), "-9999999999999999999999%",
michael@0 83 "Marginwidth attribute didn't store the original value");
michael@0 84
michael@0 85
michael@0 86 // Test PRInt32 min/max value
michael@0 87 iframe.setAttribute("marginwidth", "2147483647");
michael@0 88 is(iframe.getAttribute("marginwidth"), "2147483647",
michael@0 89 "Marginwidth attribute didn't store the original value");
michael@0 90 iframe.setAttribute("marginwidth", "2147483647%");
michael@0 91 is(iframe.getAttribute("marginwidth"), "2147483647%",
michael@0 92 "Marginwidth attribute didn't store the original value");
michael@0 93
michael@0 94 iframe.setAttribute("marginwidth", "-2147483648");
michael@0 95 is(iframe.getAttribute("marginwidth"), "-2147483648",
michael@0 96 "Marginwidth attribute didn't store the original value");
michael@0 97 iframe.setAttribute("marginwidth", "-2147483648%");
michael@0 98 is(iframe.getAttribute("marginwidth"), "-2147483648%",
michael@0 99 "Marginwidth attribute didn't store the original value");
michael@0 100
michael@0 101 iframe.setAttribute("marginwidth", "2147483646");
michael@0 102 is(iframe.getAttribute("marginwidth"), "2147483646",
michael@0 103 "Marginwidth attribute didn't store the original value");
michael@0 104 iframe.setAttribute("marginwidth", "2147483647%");
michael@0 105 is(iframe.getAttribute("marginwidth"), "2147483647%",
michael@0 106 "Marginwidth attribute didn't store the original value");
michael@0 107
michael@0 108 iframe.setAttribute("marginwidth", "-2147483647");
michael@0 109 is(iframe.getAttribute("marginwidth"), "-2147483647",
michael@0 110 "Marginwidth attribute didn't store the original value");
michael@0 111 iframe.setAttribute("marginwidth", "-2147483647%");
michael@0 112 is(iframe.getAttribute("marginwidth"), "-2147483647%",
michael@0 113 "Marginwidth attribute didn't store the original value");
michael@0 114
michael@0 115 iframe.setAttribute("marginwidth", "2147483648");
michael@0 116 is(iframe.getAttribute("marginwidth"), "2147483648",
michael@0 117 "Marginwidth attribute didn't store the original value");
michael@0 118 iframe.setAttribute("marginwidth", "2147483648%");
michael@0 119 is(iframe.getAttribute("marginwidth"), "2147483648%",
michael@0 120 "Marginwidth attribute didn't store the original value");
michael@0 121
michael@0 122 iframe.setAttribute("marginwidth", "-2147483649");
michael@0 123 is(iframe.getAttribute("marginwidth"), "-2147483649",
michael@0 124 "Marginwidth attribute didn't store the original value");
michael@0 125 iframe.setAttribute("marginwidth", "-2147483649%");
michael@0 126 is(iframe.getAttribute("marginwidth"), "-2147483649%",
michael@0 127 "Marginwidth attribute didn't store the original value");
michael@0 128
michael@0 129 // some values 0 > x > NS_ATTRVALUE_INTEGERTYPE_MAXVALUE
michael@0 130 iframe.setAttribute("marginwidth", "134217726");
michael@0 131 is(iframe.getAttribute("marginwidth"), "134217726",
michael@0 132 "Marginwidth attribute didn't store the original value");
michael@0 133 iframe.setAttribute("marginwidth", "134217727");
michael@0 134 is(iframe.getAttribute("marginwidth"), "134217727",
michael@0 135 "Marginwidth attribute didn't store the original value");
michael@0 136 iframe.setAttribute("marginwidth", "134217728");
michael@0 137 is(iframe.getAttribute("marginwidth"), "134217728",
michael@0 138 "Marginwidth attribute didn't store the original value");
michael@0 139 iframe.setAttribute("marginwidth", "134217729");
michael@0 140 is(iframe.getAttribute("marginwidth"), "134217729",
michael@0 141 "Marginwidth attribute didn't store the original value");
michael@0 142
michael@0 143 iframe.setAttribute("marginwidth", "134217726%");
michael@0 144 is(iframe.getAttribute("marginwidth"), "134217726%",
michael@0 145 "Marginwidth attribute didn't store the original value");
michael@0 146 iframe.setAttribute("marginwidth", "134217727%");
michael@0 147 is(iframe.getAttribute("marginwidth"), "134217727%",
michael@0 148 "Marginwidth attribute didn't store the original value");
michael@0 149 iframe.setAttribute("marginwidth", "134217728%");
michael@0 150 is(iframe.getAttribute("marginwidth"), "134217728%",
michael@0 151 "Marginwidth attribute didn't store the original value");
michael@0 152 iframe.setAttribute("marginwidth", "134217729%");
michael@0 153 is(iframe.getAttribute("marginwidth"), "134217729%",
michael@0 154 "Marginwidth attribute didn't store the original value");
michael@0 155
michael@0 156 // some values 0 < x < NS_ATTRVALUE_INTEGERTYPE_MINVALUE
michael@0 157 iframe.setAttribute("marginwidth", "-134217727");
michael@0 158 is(iframe.getAttribute("marginwidth"), "-134217727",
michael@0 159 "Marginwidth attribute didn't store the original value");
michael@0 160 iframe.setAttribute("marginwidth", "-134217728");
michael@0 161 is(iframe.getAttribute("marginwidth"), "-134217728",
michael@0 162 "Marginwidth attribute didn't store the original value");
michael@0 163 iframe.setAttribute("marginwidth", "-134217729");
michael@0 164 is(iframe.getAttribute("marginwidth"), "-134217729",
michael@0 165 "Marginwidth attribute didn't store the original value");
michael@0 166 iframe.setAttribute("marginwidth", "-134217730");
michael@0 167 is(iframe.getAttribute("marginwidth"), "-134217730",
michael@0 168 "Marginwidth attribute didn't store the original value");
michael@0 169 iframe.setAttribute("marginwidth", "-134217727%");
michael@0 170 is(iframe.getAttribute("marginwidth"), "-134217727%",
michael@0 171 "Marginwidth attribute didn't store the original value");
michael@0 172 iframe.setAttribute("marginwidth", "-134217728%");
michael@0 173 is(iframe.getAttribute("marginwidth"), "-134217728%",
michael@0 174 "Marginwidth attribute didn't store the original value");
michael@0 175 iframe.setAttribute("marginwidth", "-134217729%");
michael@0 176 is(iframe.getAttribute("marginwidth"), "-134217729%",
michael@0 177 "Marginwidth attribute didn't store the original value");
michael@0 178 iframe.setAttribute("marginwidth", "-134217730%");
michael@0 179 is(iframe.getAttribute("marginwidth"), "-134217730%",
michael@0 180 "Marginwidth attribute didn't store the original value");
michael@0 181
michael@0 182 iframe.setAttribute("marginwidth", "-0");
michael@0 183 is(iframe.getAttribute("marginwidth"), "-0",
michael@0 184 "Marginwidth attribute didn't store the original value");
michael@0 185 iframe.setAttribute("marginwidth", "-0%");
michael@0 186 is(iframe.getAttribute("marginwidth"), "-0%",
michael@0 187 "Marginwidth attribute didn't store the original value");
michael@0 188 iframe.setAttribute("marginwidth", " 0 ");
michael@0 189 is(iframe.getAttribute("marginwidth"), " 0 ",
michael@0 190 "Marginwidth attribute didn't store the original value");
michael@0 191 iframe.setAttribute("marginwidth", " 0% ");
michael@0 192 is(iframe.getAttribute("marginwidth"), " 0% ",
michael@0 193 "Marginwidth attribute didn't store the original value");
michael@0 194 iframe.setAttribute("marginwidth", "-50%");
michael@0 195 is(iframe.getAttribute("marginwidth"), "-50%",
michael@0 196 "Marginwidth attribute didn't store the original value");
michael@0 197 iframe.setAttribute("marginwidth", "-50");
michael@0 198 is(iframe.getAttribute("marginwidth"), "-50",
michael@0 199 "Marginwidth attribute didn't store the original value");
michael@0 200 iframe.setAttribute("marginwidth", " -50% ");
michael@0 201 is(iframe.getAttribute("marginwidth"), " -50% ",
michael@0 202 "Marginwidth attribute didn't store the original value");
michael@0 203 iframe.setAttribute("marginwidth", " -50 ");
michael@0 204 is(iframe.getAttribute("marginwidth"), " -50 ",
michael@0 205 "Marginwidth attribute didn't store the original value");
michael@0 206 iframe.setAttribute("marginwidth", "foobar");
michael@0 207 is(iframe.getAttribute("marginwidth"), "foobar",
michael@0 208 "Marginwidth attribute didn't store the original value");
michael@0 209
michael@0 210 var bd = document.createElement("body");
michael@0 211 bd.setAttribute("bgcolor", "red");
michael@0 212 is(bd.getAttribute("bgcolor"), "red", "Bgcolor attribute didn't store the original value");
michael@0 213 is(bd.bgColor, "red", ".bgColor didn't return the right value!");
michael@0 214
michael@0 215 bd.setAttribute("bgcolor", " red ");
michael@0 216 is(bd.getAttribute("bgcolor"), " red ", "Bgcolor attribute didn't store the original value");
michael@0 217 is(bd.bgColor, " red ", ".bgColor didn't return the right value!");
michael@0 218
michael@0 219 bd.setAttribute("bgcolor", "#ff0000");
michael@0 220 is(bd.getAttribute("bgcolor"), "#ff0000", "Bgcolor attribute didn't store the original value");
michael@0 221 is(bd.bgColor, "#ff0000", ".bgColor didn't return the right value!");
michael@0 222
michael@0 223 bd.setAttribute("bgcolor", "#f00");
michael@0 224 is(bd.getAttribute("bgcolor"), "#f00", "Bgcolor attribute didn't store the original value");
michael@0 225 is(bd.bgColor, "#f00", ".bgColor didn't return the right value!");
michael@0 226
michael@0 227 bd.setAttribute("bgcolor", " #ff0000 ");
michael@0 228 is(bd.getAttribute("bgcolor"), " #ff0000 ", "Bgcolor attribute didn't store the original value");
michael@0 229 is(bd.bgColor, " #ff0000 ", ".bgColor didn't return the right value!");
michael@0 230
michael@0 231 bd.setAttribute("bgcolor", "nonsense(complete)");
michael@0 232 is(bd.getAttribute("bgcolor"), "nonsense(complete)", "Bgcolor attribute didn't store the original value");
michael@0 233 is(bd.bgColor, "nonsense(complete)", ".bgColor didn't return the right value!");
michael@0 234
michael@0 235 // same test again setting the prop
michael@0 236 bd.bgColor = "red";
michael@0 237 is(bd.getAttribute("bgcolor"), "red", "Bgcolor attribute didn't store the original value");
michael@0 238 is(bd.bgColor, "red", ".bgColor didn't return the right value!");
michael@0 239
michael@0 240 bd.bgColor = " red ";
michael@0 241 is(bd.getAttribute("bgcolor"), " red ", "Bgcolor attribute didn't store the original value");
michael@0 242 is(bd.bgColor, " red ", ".bgColor didn't return the right value!");
michael@0 243
michael@0 244 bd.bgColor = "#ff0000";
michael@0 245 is(bd.getAttribute("bgcolor"), "#ff0000", "Bgcolor attribute didn't store the original value");
michael@0 246 is(bd.bgColor, "#ff0000", ".bgColor didn't return the right value!");
michael@0 247
michael@0 248 bd.bgColor = "#f00";
michael@0 249 is(bd.getAttribute("bgcolor"), "#f00", "Bgcolor attribute didn't store the original value");
michael@0 250 is(bd.bgColor, "#f00", ".bgColor didn't return the right value!");
michael@0 251
michael@0 252 bd.bgColor = " #ff0000 ";
michael@0 253 is(bd.getAttribute("bgcolor"), " #ff0000 ", "Bgcolor attribute didn't store the original value");
michael@0 254 is(bd.bgColor, " #ff0000 ", ".bgColor didn't return the right value!");
michael@0 255
michael@0 256 bd.bgColor = "nonsense(complete)";
michael@0 257 is(bd.getAttribute("bgcolor"), "nonsense(complete)", "Bgcolor attribute didn't store the original value");
michael@0 258 is(bd.bgColor, "nonsense(complete)", ".bgColor didn't return the right value!");
michael@0 259
michael@0 260 // equal color, unequal string
michael@0 261 var f1 = document.createElement("font");
michael@0 262 var f2 = document.createElement("font");
michael@0 263 var f3 = document.createElement("font");
michael@0 264 f1.color = "#f00";
michael@0 265 f2.color = "#ff0000";
michael@0 266 f3.color = "red";
michael@0 267 isnot(f1.color, f2.color, "#f00 and #ff0000 should not compare equal");
michael@0 268 isnot(f1.color, f3.color, "#f00 and red should not compare equal");
michael@0 269 isnot(f2.color, f3.color, "#ff0000 and red should not compare equal");
michael@0 270
michael@0 271 isnot(f1.getAttribute("color"), f2.getAttribute("color"),
michael@0 272 "#f00 and #ff0000 should not compare equal [attr]");
michael@0 273 isnot(f1.getAttribute("color"), f3.getAttribute("color"),
michael@0 274 "#f00 and red should not compare equal [attr]");
michael@0 275 isnot(f2.getAttribute("color"), f3.getAttribute("color"),
michael@0 276 "#ff0000 and red should not compare equal [attr]");
michael@0 277
michael@0 278 var video = document.createElement("video");
michael@0 279 video.setAttribute("playbackrate", "1");
michael@0 280 is(video.getAttribute('playbackrate'), "1",
michael@0 281 "Playbackrate attribute didn't store the original value");
michael@0 282 video.setAttribute("playbackrate", "1.5");
michael@0 283 is(video.getAttribute('playbackrate'), "1.5",
michael@0 284 "Playbackrate attribute didn't store the original value");
michael@0 285 video.setAttribute("playbackrate", "999999999999999999");
michael@0 286 is(video.getAttribute('playbackrate'), "999999999999999999",
michael@0 287 "Playbackrate attribute didn't store the original value");
michael@0 288 video.setAttribute("playbackrate", "-999999999999999999");
michael@0 289 is(video.getAttribute('playbackrate'), "-999999999999999999",
michael@0 290 "Playbackrate attribute didn't store the original value");
michael@0 291 video.setAttribute("playbackrate", "foo");
michael@0 292 is(video.getAttribute('playbackrate'), "foo",
michael@0 293 "Playbackrate attribute didn't store the original value");
michael@0 294 </script>
michael@0 295 </pre>
michael@0 296 </body>
michael@0 297 </html>
michael@0 298

mercurial