content/base/test/test_bug433533.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/test_bug433533.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,298 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=433533
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 433533</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=433533">Mozilla Bug 433533</a>
    1.16 +<p id="display"></p>
    1.17 +<div id="content" style="display: none">
    1.18 +  
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script class="testbody" type="text/javascript">
    1.22 +
    1.23 +/** Test for Bug 433533 **/
    1.24 +
    1.25 +var input = document.createElement("input");
    1.26 +input.setAttribute("type", "hidden");
    1.27 +is(input.getAttribute("type"), "hidden", "Setting type attribute didn't work!");
    1.28 +input.setAttribute("type", "hiDDen");
    1.29 +is(input.getAttribute("type"), "hiDDen", "Type attribute didn't store the original value");
    1.30 +is(input.type, "hidden", "Wrong input.type!");
    1.31 +input.setAttribute("type", "HIDDEN");
    1.32 +is(input.getAttribute("type"), "HIDDEN", "Type attribute didn't store the original value");
    1.33 +is(input.type, "hidden", "Wrong input.type!");
    1.34 +
    1.35 +var td = document.createElement("td");
    1.36 +td.setAttribute("scope", "rOW");
    1.37 +is(td.getAttribute("scope"), "rOW", "Scope attribute didn't store the original value");
    1.38 +td.setAttribute("scope", "row");
    1.39 +is(td.getAttribute("scope"), "row", "Scope attribute didn't store the original value");
    1.40 +td.setAttribute("colspan", "100k");
    1.41 +is(td.getAttribute("colspan"), "100k", "Colspan attribute didn't store the original value");
    1.42 +td.setAttribute("colspan", " 100 ");
    1.43 +is(td.getAttribute("colspan"), " 100 ", "Colspan attribute didn't store the original value");
    1.44 +td.setAttribute("colspan", "100");
    1.45 +is(td.getAttribute("colspan"), "100", "Colspan attribute didn't store the original value");
    1.46 +
    1.47 +// Note, if colspan is negative, it is set to 1, because of backwards compatibility.
    1.48 +// @see nsHTMLTableCellElement::ParseAttribute
    1.49 +td.setAttribute("colspan", "-100k");
    1.50 +is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
    1.51 +td.setAttribute("colspan", " -100 ");
    1.52 +is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
    1.53 +td.setAttribute("colspan", "-100");
    1.54 +is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
    1.55 +
    1.56 +
    1.57 +td.setAttribute("colspan", "foobar");
    1.58 +is(td.getAttribute("colspan"), "foobar", "Colspan attribute didn't store the original value");
    1.59 +
    1.60 +var iframe = document.createElement("iframe");
    1.61 +iframe.setAttribute("marginwidth", "50%");
    1.62 +is(iframe.getAttribute("marginwidth"), "50%",
    1.63 +   "Marginwidth attribute didn't store the original value");
    1.64 +iframe.setAttribute("marginwidth", "50");
    1.65 +is(iframe.getAttribute("marginwidth"), "50",
    1.66 +   "Marginwidth attribute didn't store the original value");
    1.67 +iframe.setAttribute("marginwidth", "0");
    1.68 +is(iframe.getAttribute("marginwidth"), "0",
    1.69 +   "Marginwidth attribute didn't store the original value");
    1.70 +iframe.setAttribute("marginwidth", "0%");
    1.71 +is(iframe.getAttribute("marginwidth"), "0%",
    1.72 +   "Marginwidth attribute didn't store the original value");
    1.73 +
    1.74 +iframe.setAttribute("marginwidth", "9999999999999999999999");
    1.75 +is(iframe.getAttribute("marginwidth"), "9999999999999999999999",
    1.76 +   "Marginwidth attribute didn't store the original value");
    1.77 +iframe.setAttribute("marginwidth", "9999999999999999999999%");
    1.78 +is(iframe.getAttribute("marginwidth"), "9999999999999999999999%",
    1.79 +   "Marginwidth attribute didn't store the original value");
    1.80 +
    1.81 +iframe.setAttribute("marginwidth", "-9999999999999999999999");
    1.82 +is(iframe.getAttribute("marginwidth"), "-9999999999999999999999",
    1.83 +   "Marginwidth attribute didn't store the original value");
    1.84 +iframe.setAttribute("marginwidth", "-9999999999999999999999%");
    1.85 +is(iframe.getAttribute("marginwidth"), "-9999999999999999999999%",
    1.86 +   "Marginwidth attribute didn't store the original value");
    1.87 +
    1.88 +   
    1.89 +// Test PRInt32 min/max value
    1.90 +iframe.setAttribute("marginwidth", "2147483647");
    1.91 +is(iframe.getAttribute("marginwidth"), "2147483647",
    1.92 +   "Marginwidth attribute didn't store the original value");
    1.93 +iframe.setAttribute("marginwidth", "2147483647%");
    1.94 +is(iframe.getAttribute("marginwidth"), "2147483647%",
    1.95 +   "Marginwidth attribute didn't store the original value");
    1.96 +
    1.97 +iframe.setAttribute("marginwidth", "-2147483648");
    1.98 +is(iframe.getAttribute("marginwidth"), "-2147483648",
    1.99 +   "Marginwidth attribute didn't store the original value");
   1.100 +iframe.setAttribute("marginwidth", "-2147483648%");
   1.101 +is(iframe.getAttribute("marginwidth"), "-2147483648%",
   1.102 +   "Marginwidth attribute didn't store the original value");
   1.103 +
   1.104 +iframe.setAttribute("marginwidth", "2147483646");
   1.105 +is(iframe.getAttribute("marginwidth"), "2147483646",
   1.106 +   "Marginwidth attribute didn't store the original value");
   1.107 +iframe.setAttribute("marginwidth", "2147483647%");
   1.108 +is(iframe.getAttribute("marginwidth"), "2147483647%",
   1.109 +   "Marginwidth attribute didn't store the original value");
   1.110 +
   1.111 +iframe.setAttribute("marginwidth", "-2147483647");
   1.112 +is(iframe.getAttribute("marginwidth"), "-2147483647",
   1.113 +   "Marginwidth attribute didn't store the original value");
   1.114 +iframe.setAttribute("marginwidth", "-2147483647%");
   1.115 +is(iframe.getAttribute("marginwidth"), "-2147483647%",
   1.116 +   "Marginwidth attribute didn't store the original value");
   1.117 +
   1.118 +iframe.setAttribute("marginwidth", "2147483648");
   1.119 +is(iframe.getAttribute("marginwidth"), "2147483648",
   1.120 +   "Marginwidth attribute didn't store the original value");
   1.121 +iframe.setAttribute("marginwidth", "2147483648%");
   1.122 +is(iframe.getAttribute("marginwidth"), "2147483648%",
   1.123 +   "Marginwidth attribute didn't store the original value");
   1.124 +
   1.125 +iframe.setAttribute("marginwidth", "-2147483649");
   1.126 +is(iframe.getAttribute("marginwidth"), "-2147483649",
   1.127 +   "Marginwidth attribute didn't store the original value");
   1.128 +iframe.setAttribute("marginwidth", "-2147483649%");
   1.129 +is(iframe.getAttribute("marginwidth"), "-2147483649%",
   1.130 +   "Marginwidth attribute didn't store the original value");
   1.131 +
   1.132 +// some values 0 > x > NS_ATTRVALUE_INTEGERTYPE_MAXVALUE
   1.133 +iframe.setAttribute("marginwidth", "134217726");
   1.134 +is(iframe.getAttribute("marginwidth"), "134217726",
   1.135 +   "Marginwidth attribute didn't store the original value");
   1.136 +iframe.setAttribute("marginwidth", "134217727");
   1.137 +is(iframe.getAttribute("marginwidth"), "134217727",
   1.138 +   "Marginwidth attribute didn't store the original value");
   1.139 +iframe.setAttribute("marginwidth", "134217728");
   1.140 +is(iframe.getAttribute("marginwidth"), "134217728",
   1.141 +   "Marginwidth attribute didn't store the original value");
   1.142 +iframe.setAttribute("marginwidth", "134217729");
   1.143 +is(iframe.getAttribute("marginwidth"), "134217729",
   1.144 +   "Marginwidth attribute didn't store the original value");
   1.145 +
   1.146 +iframe.setAttribute("marginwidth", "134217726%");
   1.147 +is(iframe.getAttribute("marginwidth"), "134217726%",
   1.148 +   "Marginwidth attribute didn't store the original value");
   1.149 +iframe.setAttribute("marginwidth", "134217727%");
   1.150 +is(iframe.getAttribute("marginwidth"), "134217727%",
   1.151 +   "Marginwidth attribute didn't store the original value");
   1.152 +iframe.setAttribute("marginwidth", "134217728%");
   1.153 +is(iframe.getAttribute("marginwidth"), "134217728%",
   1.154 +   "Marginwidth attribute didn't store the original value");
   1.155 +iframe.setAttribute("marginwidth", "134217729%");
   1.156 +is(iframe.getAttribute("marginwidth"), "134217729%",
   1.157 +   "Marginwidth attribute didn't store the original value");
   1.158 +
   1.159 +// some values 0 < x < NS_ATTRVALUE_INTEGERTYPE_MINVALUE
   1.160 +iframe.setAttribute("marginwidth", "-134217727");
   1.161 +is(iframe.getAttribute("marginwidth"), "-134217727",
   1.162 +   "Marginwidth attribute didn't store the original value");
   1.163 +iframe.setAttribute("marginwidth", "-134217728");
   1.164 +is(iframe.getAttribute("marginwidth"), "-134217728",
   1.165 +   "Marginwidth attribute didn't store the original value");
   1.166 +iframe.setAttribute("marginwidth", "-134217729");
   1.167 +is(iframe.getAttribute("marginwidth"), "-134217729",
   1.168 +   "Marginwidth attribute didn't store the original value");
   1.169 +iframe.setAttribute("marginwidth", "-134217730");
   1.170 +is(iframe.getAttribute("marginwidth"), "-134217730",
   1.171 +   "Marginwidth attribute didn't store the original value");
   1.172 +iframe.setAttribute("marginwidth", "-134217727%");
   1.173 +is(iframe.getAttribute("marginwidth"), "-134217727%",
   1.174 +   "Marginwidth attribute didn't store the original value");
   1.175 +iframe.setAttribute("marginwidth", "-134217728%");
   1.176 +is(iframe.getAttribute("marginwidth"), "-134217728%",
   1.177 +   "Marginwidth attribute didn't store the original value");
   1.178 +iframe.setAttribute("marginwidth", "-134217729%");
   1.179 +is(iframe.getAttribute("marginwidth"), "-134217729%",
   1.180 +   "Marginwidth attribute didn't store the original value");
   1.181 +iframe.setAttribute("marginwidth", "-134217730%");
   1.182 +is(iframe.getAttribute("marginwidth"), "-134217730%",
   1.183 +   "Marginwidth attribute didn't store the original value");
   1.184 +
   1.185 +iframe.setAttribute("marginwidth", "-0");
   1.186 +is(iframe.getAttribute("marginwidth"), "-0",
   1.187 +   "Marginwidth attribute didn't store the original value");
   1.188 +iframe.setAttribute("marginwidth", "-0%");
   1.189 +is(iframe.getAttribute("marginwidth"), "-0%",
   1.190 +   "Marginwidth attribute didn't store the original value");   
   1.191 +iframe.setAttribute("marginwidth", " 0 ");
   1.192 +is(iframe.getAttribute("marginwidth"), " 0 ",
   1.193 +   "Marginwidth attribute didn't store the original value");
   1.194 +iframe.setAttribute("marginwidth", " 0% ");
   1.195 +is(iframe.getAttribute("marginwidth"), " 0% ",
   1.196 +   "Marginwidth attribute didn't store the original value");
   1.197 +iframe.setAttribute("marginwidth", "-50%");
   1.198 +is(iframe.getAttribute("marginwidth"), "-50%",
   1.199 +   "Marginwidth attribute didn't store the original value");
   1.200 +iframe.setAttribute("marginwidth", "-50");
   1.201 +is(iframe.getAttribute("marginwidth"), "-50",
   1.202 +   "Marginwidth attribute didn't store the original value");
   1.203 +iframe.setAttribute("marginwidth", " -50% ");
   1.204 +is(iframe.getAttribute("marginwidth"), " -50% ",
   1.205 +   "Marginwidth attribute didn't store the original value");
   1.206 +iframe.setAttribute("marginwidth", " -50 ");
   1.207 +is(iframe.getAttribute("marginwidth"), " -50 ",
   1.208 +   "Marginwidth attribute didn't store the original value");
   1.209 +iframe.setAttribute("marginwidth", "foobar");
   1.210 +is(iframe.getAttribute("marginwidth"), "foobar",
   1.211 +   "Marginwidth attribute didn't store the original value");
   1.212 +
   1.213 +var bd = document.createElement("body");
   1.214 +bd.setAttribute("bgcolor", "red");
   1.215 +is(bd.getAttribute("bgcolor"), "red", "Bgcolor attribute didn't store the original value");
   1.216 +is(bd.bgColor, "red", ".bgColor didn't return the right value!");
   1.217 +
   1.218 +bd.setAttribute("bgcolor", "  red  ");
   1.219 +is(bd.getAttribute("bgcolor"), "  red  ", "Bgcolor attribute didn't store the original value");
   1.220 +is(bd.bgColor, "  red  ", ".bgColor didn't return the right value!");
   1.221 +
   1.222 +bd.setAttribute("bgcolor", "#ff0000");
   1.223 +is(bd.getAttribute("bgcolor"), "#ff0000", "Bgcolor attribute didn't store the original value");
   1.224 +is(bd.bgColor, "#ff0000", ".bgColor didn't return the right value!");
   1.225 +
   1.226 +bd.setAttribute("bgcolor", "#f00");
   1.227 +is(bd.getAttribute("bgcolor"), "#f00", "Bgcolor attribute didn't store the original value");
   1.228 +is(bd.bgColor, "#f00", ".bgColor didn't return the right value!");
   1.229 +
   1.230 +bd.setAttribute("bgcolor", "  #ff0000  ");
   1.231 +is(bd.getAttribute("bgcolor"), "  #ff0000  ", "Bgcolor attribute didn't store the original value");
   1.232 +is(bd.bgColor, "  #ff0000  ", ".bgColor didn't return the right value!");
   1.233 +
   1.234 +bd.setAttribute("bgcolor", "nonsense(complete)");
   1.235 +is(bd.getAttribute("bgcolor"), "nonsense(complete)", "Bgcolor attribute didn't store the original value");
   1.236 +is(bd.bgColor, "nonsense(complete)", ".bgColor didn't return the right value!");
   1.237 +
   1.238 +// same test again setting the prop
   1.239 +bd.bgColor = "red";
   1.240 +is(bd.getAttribute("bgcolor"), "red", "Bgcolor attribute didn't store the original value");
   1.241 +is(bd.bgColor, "red", ".bgColor didn't return the right value!");
   1.242 +
   1.243 +bd.bgColor = "  red  ";
   1.244 +is(bd.getAttribute("bgcolor"), "  red  ", "Bgcolor attribute didn't store the original value");
   1.245 +is(bd.bgColor, "  red  ", ".bgColor didn't return the right value!");
   1.246 +
   1.247 +bd.bgColor = "#ff0000";
   1.248 +is(bd.getAttribute("bgcolor"), "#ff0000", "Bgcolor attribute didn't store the original value");
   1.249 +is(bd.bgColor, "#ff0000", ".bgColor didn't return the right value!");
   1.250 +
   1.251 +bd.bgColor = "#f00";
   1.252 +is(bd.getAttribute("bgcolor"), "#f00", "Bgcolor attribute didn't store the original value");
   1.253 +is(bd.bgColor, "#f00", ".bgColor didn't return the right value!");
   1.254 +
   1.255 +bd.bgColor = "  #ff0000  ";
   1.256 +is(bd.getAttribute("bgcolor"), "  #ff0000  ", "Bgcolor attribute didn't store the original value");
   1.257 +is(bd.bgColor, "  #ff0000  ", ".bgColor didn't return the right value!");
   1.258 +
   1.259 +bd.bgColor = "nonsense(complete)";
   1.260 +is(bd.getAttribute("bgcolor"), "nonsense(complete)", "Bgcolor attribute didn't store the original value");
   1.261 +is(bd.bgColor, "nonsense(complete)", ".bgColor didn't return the right value!");
   1.262 +
   1.263 +// equal color, unequal string
   1.264 +var f1 = document.createElement("font");
   1.265 +var f2 = document.createElement("font");
   1.266 +var f3 = document.createElement("font");
   1.267 +f1.color = "#f00";
   1.268 +f2.color = "#ff0000";
   1.269 +f3.color = "red";
   1.270 +isnot(f1.color, f2.color, "#f00 and #ff0000 should not compare equal");
   1.271 +isnot(f1.color, f3.color, "#f00 and red should not compare equal");
   1.272 +isnot(f2.color, f3.color, "#ff0000 and red should not compare equal");
   1.273 +
   1.274 +isnot(f1.getAttribute("color"), f2.getAttribute("color"),
   1.275 +      "#f00 and #ff0000 should not compare equal [attr]");
   1.276 +isnot(f1.getAttribute("color"), f3.getAttribute("color"),
   1.277 +      "#f00 and red should not compare equal [attr]");
   1.278 +isnot(f2.getAttribute("color"), f3.getAttribute("color"),
   1.279 +      "#ff0000 and red should not compare equal [attr]");
   1.280 +
   1.281 +var video = document.createElement("video");
   1.282 +video.setAttribute("playbackrate", "1");
   1.283 +is(video.getAttribute('playbackrate'), "1",
   1.284 +   "Playbackrate attribute didn't store the original value");
   1.285 +video.setAttribute("playbackrate", "1.5");
   1.286 +is(video.getAttribute('playbackrate'), "1.5",
   1.287 +   "Playbackrate attribute didn't store the original value");
   1.288 +video.setAttribute("playbackrate", "999999999999999999");
   1.289 +is(video.getAttribute('playbackrate'), "999999999999999999",
   1.290 +   "Playbackrate attribute didn't store the original value");
   1.291 +video.setAttribute("playbackrate", "-999999999999999999");
   1.292 +is(video.getAttribute('playbackrate'), "-999999999999999999",
   1.293 +   "Playbackrate attribute didn't store the original value");
   1.294 +video.setAttribute("playbackrate", "foo");
   1.295 +is(video.getAttribute('playbackrate'), "foo",
   1.296 +   "Playbackrate attribute didn't store the original value");
   1.297 +</script>
   1.298 +</pre>
   1.299 +</body>
   1.300 +</html>
   1.301 +

mercurial