tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug433533.html (14255B)


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