content/base/test/test_bug433533.html
author L. David Baron <dbaron@dbaron.org>
Wed, 06 May 2009 13:46:04 -0700
changeset 28048 8f7b73d88f6bbedec99c6c8ef48b243ab922d05c
parent 19769 07afef6cd29c5199ca2a186c2b9f237484db8e1b
child 28611 821405837446610ade88a2bdfc70b71677e58a05
permissions -rw-r--r--
Switch HTML mochitests from using MochiKit.js to packed.js. (Bug 490955) r=sayrer

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=433533
-->
<head>
  <title>Test for Bug 433533</title>
  <script type="text/javascript" src="/MochiKit/packed.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=433533">Mozilla Bug 433533</a>
<p id="display"></p>
<div id="content" style="display: none">
  
</div>
<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for Bug 433533 **/

var input = document.createElement("input");
input.setAttribute("type", "hidden");
is(input.getAttribute("type"), "hidden", "Setting type attribute didn't work!");
input.setAttribute("type", "hiDDen");
is(input.getAttribute("type"), "hiDDen", "Type attribute didn't store the original value");
is(input.type, "hidden", "Wrong input.type!");
input.setAttribute("type", "HIDDEN");
is(input.getAttribute("type"), "HIDDEN", "Type attribute didn't store the original value");
is(input.type, "hidden", "Wrong input.type!");

var td = document.createElement("td");
td.setAttribute("scope", "rOW");
is(td.getAttribute("scope"), "rOW", "Scope attribute didn't store the original value");
td.setAttribute("scope", "row");
is(td.getAttribute("scope"), "row", "Scope attribute didn't store the original value");
td.setAttribute("colspan", "100k");
is(td.getAttribute("colspan"), "100k", "Colspan attribute didn't store the original value");
td.setAttribute("colspan", " 100 ");
is(td.getAttribute("colspan"), " 100 ", "Colspan attribute didn't store the original value");
td.setAttribute("colspan", "100");
is(td.getAttribute("colspan"), "100", "Colspan attribute didn't store the original value");

// Note, if colspan is negative, it is set to 1, because of backwards compatibility.
// @see nsHTMLTableCellElement::ParseAttribute
td.setAttribute("colspan", "-100k");
is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
td.setAttribute("colspan", " -100 ");
is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
td.setAttribute("colspan", "-100");
is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");


td.setAttribute("colspan", "foobar");
is(td.getAttribute("colspan"), "foobar", "Colspan attribute didn't store the original value");

var iframe = document.createElement("iframe");
iframe.setAttribute("marginwidth", "50%");
is(iframe.getAttribute("marginwidth"), "50%",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "50");
is(iframe.getAttribute("marginwidth"), "50",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "0");
is(iframe.getAttribute("marginwidth"), "0",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "0%");
is(iframe.getAttribute("marginwidth"), "0%",
   "Marginwidth attribute didn't store the original value");

iframe.setAttribute("marginwidth", "9999999999999999999999");
is(iframe.getAttribute("marginwidth"), "9999999999999999999999",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "9999999999999999999999%");
is(iframe.getAttribute("marginwidth"), "9999999999999999999999%",
   "Marginwidth attribute didn't store the original value");

iframe.setAttribute("marginwidth", "-9999999999999999999999");
is(iframe.getAttribute("marginwidth"), "-9999999999999999999999",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-9999999999999999999999%");
is(iframe.getAttribute("marginwidth"), "-9999999999999999999999%",
   "Marginwidth attribute didn't store the original value");

   
// Test PRInt32 min/max value
iframe.setAttribute("marginwidth", "2147483647");
is(iframe.getAttribute("marginwidth"), "2147483647",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "2147483647%");
is(iframe.getAttribute("marginwidth"), "2147483647%",
   "Marginwidth attribute didn't store the original value");

iframe.setAttribute("marginwidth", "-2147483648");
is(iframe.getAttribute("marginwidth"), "-2147483648",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-2147483648%");
is(iframe.getAttribute("marginwidth"), "-2147483648%",
   "Marginwidth attribute didn't store the original value");

iframe.setAttribute("marginwidth", "2147483646");
is(iframe.getAttribute("marginwidth"), "2147483646",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "2147483647%");
is(iframe.getAttribute("marginwidth"), "2147483647%",
   "Marginwidth attribute didn't store the original value");

iframe.setAttribute("marginwidth", "-2147483647");
is(iframe.getAttribute("marginwidth"), "-2147483647",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-2147483647%");
is(iframe.getAttribute("marginwidth"), "-2147483647%",
   "Marginwidth attribute didn't store the original value");

iframe.setAttribute("marginwidth", "2147483648");
is(iframe.getAttribute("marginwidth"), "2147483648",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "2147483648%");
is(iframe.getAttribute("marginwidth"), "2147483648%",
   "Marginwidth attribute didn't store the original value");

iframe.setAttribute("marginwidth", "-2147483649");
is(iframe.getAttribute("marginwidth"), "-2147483649",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-2147483649%");
is(iframe.getAttribute("marginwidth"), "-2147483649%",
   "Marginwidth attribute didn't store the original value");

// some values 0 > x > NS_ATTRVALUE_INTEGERTYPE_MAXVALUE
iframe.setAttribute("marginwidth", "134217726");
is(iframe.getAttribute("marginwidth"), "134217726",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "134217727");
is(iframe.getAttribute("marginwidth"), "134217727",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "134217728");
is(iframe.getAttribute("marginwidth"), "134217728",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "134217729");
is(iframe.getAttribute("marginwidth"), "134217729",
   "Marginwidth attribute didn't store the original value");

iframe.setAttribute("marginwidth", "134217726%");
is(iframe.getAttribute("marginwidth"), "134217726%",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "134217727%");
is(iframe.getAttribute("marginwidth"), "134217727%",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "134217728%");
is(iframe.getAttribute("marginwidth"), "134217728%",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "134217729%");
is(iframe.getAttribute("marginwidth"), "134217729%",
   "Marginwidth attribute didn't store the original value");

// some values 0 < x < NS_ATTRVALUE_INTEGERTYPE_MINVALUE
iframe.setAttribute("marginwidth", "-134217727");
is(iframe.getAttribute("marginwidth"), "-134217727",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-134217728");
is(iframe.getAttribute("marginwidth"), "-134217728",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-134217729");
is(iframe.getAttribute("marginwidth"), "-134217729",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-134217730");
is(iframe.getAttribute("marginwidth"), "-134217730",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-134217727%");
is(iframe.getAttribute("marginwidth"), "-134217727%",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-134217728%");
is(iframe.getAttribute("marginwidth"), "-134217728%",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-134217729%");
is(iframe.getAttribute("marginwidth"), "-134217729%",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-134217730%");
is(iframe.getAttribute("marginwidth"), "-134217730%",
   "Marginwidth attribute didn't store the original value");

iframe.setAttribute("marginwidth", "-0");
is(iframe.getAttribute("marginwidth"), "-0",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-0%");
is(iframe.getAttribute("marginwidth"), "-0%",
   "Marginwidth attribute didn't store the original value");   
iframe.setAttribute("marginwidth", " 0 ");
is(iframe.getAttribute("marginwidth"), " 0 ",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", " 0% ");
is(iframe.getAttribute("marginwidth"), " 0% ",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-50%");
is(iframe.getAttribute("marginwidth"), "-50%",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "-50");
is(iframe.getAttribute("marginwidth"), "-50",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", " -50% ");
is(iframe.getAttribute("marginwidth"), " -50% ",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", " -50 ");
is(iframe.getAttribute("marginwidth"), " -50 ",
   "Marginwidth attribute didn't store the original value");
iframe.setAttribute("marginwidth", "foobar");
is(iframe.getAttribute("marginwidth"), "foobar",
   "Marginwidth attribute didn't store the original value");

var bd = document.createElement("body");
bd.setAttribute("bgcolor", "red");
is(bd.getAttribute("bgcolor"), "red", "Bgcolor attribute didn't store the original value");
bd.setAttribute("bgcolor", "  red  ");
todo(bd.getAttribute("bgcolor") == "  red  ", "Bgcolor attribute didn't store the original value");
td.setAttribute("colspan", "100k");
is(td.getAttribute("colspan"), "100k", "Colspan attribute didn't store the original value");
bd.setAttribute("bgcolor", "red");
is(bd.bgColor, "#ff0000", ".bgColor didn't return the right value!");
bd.setAttribute("bgcolor", "  red  ");
is(bd.bgColor, "#ff0000", ".bgColor didn't return the right value!");
bd.setAttribute("bgcolor", "#ff0000");
is(bd.bgColor, "#ff0000", ".bgColor didn't return the right value!");

var video = document.createElement("video");
video.setAttribute("playbackrate", "1");
is(video.getAttribute('playbackrate'), "1",
   "Playbackrate attribute didn't store the original value");
video.setAttribute("playbackrate", "1.5");
is(video.getAttribute('playbackrate'), "1.5",
   "Playbackrate attribute didn't store the original value");
video.setAttribute("playbackrate", "999999999999999999");
is(video.getAttribute('playbackrate'), "999999999999999999",
   "Playbackrate attribute didn't store the original value");
video.setAttribute("playbackrate", "-999999999999999999");
is(video.getAttribute('playbackrate'), "-999999999999999999",
   "Playbackrate attribute didn't store the original value");
video.setAttribute("playbackrate", "foo");
is(video.getAttribute('playbackrate'), "foo",
   "Playbackrate attribute didn't store the original value");
</script>
</pre>
</body>
</html>