blob: 7e21862239033ff6df00b582944c9cd26a30e2da [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<div id="testParent" style="visibility:hidden"></div>
<script>
description('Various tests for the marquee element.');
var marquee;
var testParent = document.getElementById("testParent");
debug('"behavior" IDL attribute reflects content attribute:');
testParent.innerHTML = '<marquee id="marquee" behavior="slide">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.behavior', '"slide"');
debug('"behavior" IDL attribute can be modified:');
testParent.innerHTML = '<marquee id="marquee" behavior="slide">test</marquee>';
marquee = document.getElementById('marquee');
marquee.behavior="alternate";
shouldBe('marquee.behavior', '"alternate"');
debug('"bgColor" IDL attribute reflects content attribute:');
testParent.innerHTML = '<marquee id="marquee" bgcolor="red">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.bgColor', '"red"');
debug('"bgColor" IDL attribute can be modified:');
testParent.innerHTML = '<marquee id="marquee" bgcolor="red">test</marquee>';
marquee = document.getElementById('marquee');
marquee.bgColor="blue";
shouldBe('marquee.bgColor', '"blue"');
debug('"direction" IDL attribute reflects content attribute:');
testParent.innerHTML = '<marquee id="marquee" direction="right">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.direction', '"right"');
debug('"direction" IDL attribute can be modified:');
testParent.innerHTML = '<marquee id="marquee" direction="right">test</marquee>';
marquee = document.getElementById('marquee');
marquee.direction="left";
shouldBe('marquee.direction', '"left"');
debug('"height" IDL attribute reflects content attribute:');
testParent.innerHTML = '<marquee id="marquee" height="100px">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.height', '"100px"');
debug('"height" IDL attribute can be modified:');
testParent.innerHTML = '<marquee id="marquee" height="100px">test</marquee>';
marquee = document.getElementById('marquee');
marquee.height="200px";
shouldBe('marquee.height', '"200px"');
debug('"hspace" IDL attribute reflects content attribute:');
testParent.innerHTML = '<marquee id="marquee" hspace="10">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.hspace', '10');
debug('"hspace" IDL attribute can be modified:');
testParent.innerHTML = '<marquee id="marquee" hspace="10">test</marquee>';
marquee = document.getElementById('marquee');
marquee.hspace=20;
shouldBe('marquee.hspace', '20');
debug('"hspace" IDL attribute is 0 when content attribute is negative:');
testParent.innerHTML = '<marquee id="marquee" hspace="-1">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.hspace', '0');
debug('"hspace" IDL attribute is 0 when content attribute is too large:');
testParent.innerHTML = '<marquee id="marquee" hspace="2147483648">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.hspace', '0');
debug('"loop" IDL attribute reflects content attribute:');
testParent.innerHTML = '<marquee id="marquee" loop="3">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.loop', '3');
debug('"loop" IDL attribute can be modified:');
testParent.innerHTML = '<marquee id="marquee" loop="3">test</marquee>';
marquee = document.getElementById('marquee');
marquee.loop=4;
shouldBe('marquee.loop', '4');
debug('"scrollAmount" IDL attribute reflects content attribute:');
testParent.innerHTML = '<marquee id="marquee" scrollamount="5">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollAmount', '5');
debug('"scrollAmount" IDL attribute can be modified:');
testParent.innerHTML = '<marquee id="marquee" scrollamount="5">test</marquee>';
marquee = document.getElementById('marquee');
marquee.scrollAmount=6;
shouldBe('marquee.scrollAmount', '6');
debug('"scrollDelay" IDL attribute reflects content attribute:');
testParent.innerHTML = '<marquee id="marquee" scrolldelay="50">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollDelay', '50');
debug('"scrollDelay" IDL attribute can be modified:');
testParent.innerHTML = '<marquee id="marquee" scrolldelay="50">test</marquee>';
marquee = document.getElementById('marquee');
marquee.scrollDelay=60;
shouldBe('marquee.scrollDelay', '60');
debug('"trueSpeed" IDL attribute reflects content attribute:');
testParent.innerHTML = '<marquee id="marquee" truespeed="true">test</marquee>';
marquee = document.getElementById('marquee');
shouldBeTrue('marquee.trueSpeed');
debug('"trueSpeed" IDL attribute can be modified:');
testParent.innerHTML = '<marquee id="marquee" truespeed="true">test</marquee>';
marquee = document.getElementById('marquee');
marquee.trueSpeed=false;
shouldBe('marquee.trueSpeed', 'false');
debug('"vspace" IDL attribute reflects content attribute:');
testParent.innerHTML = '<marquee id="marquee" vspace="10">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.vspace', '10');
debug('"vspace" IDL attribute can be modified:');
testParent.innerHTML = '<marquee id="marquee" vspace="10">test</marquee>';
marquee = document.getElementById('marquee');
marquee.vspace=20;
shouldBe('marquee.vspace', '20');
debug('"vspace" IDL attribute is 0 when content attribute is negative:');
testParent.innerHTML = '<marquee id="marquee" vspace="-1">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.vspace', '0');
debug('"vspace" IDL attribute is 0 when content attribute is too large:');
testParent.innerHTML = '<marquee id="marquee" vspace="2147483648">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.vspace', '0');
debug('Default "scrollAmount" value is 6:');
testParent.innerHTML = '<marquee id="marquee">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollAmount', '6');
debug('"scrollAmount" uses default value when content attribute is not a number:');
testParent.innerHTML = '<marquee id="marquee" scrollamount="a1">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollAmount', '6');
debug('"scrollAmount" uses default value when content attribute is too large:');
testParent.innerHTML = '<marquee id="marquee" scrollamount="2147483648">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollAmount', '6');
debug('"scrollAmount" uses default value when content attribute is negative:');
testParent.innerHTML = '<marquee id="marquee" scrollamount="-1">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollAmount', '6');
debug('"scrollAmount" can be set to 0:');
testParent.innerHTML = '<marquee id="marquee" scrollamount="0">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollAmount', '0');
debug('"scrollAmount" can be set to 2^31-1:');
testParent.innerHTML = '<marquee id="marquee" scrollamount="2147483647">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollAmount', '2147483647');
debug('"scrollAmount" can contain whitespace:');
testParent.innerHTML = '<marquee id="marquee" scrollamount=" 5 ">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollAmount', '5');
debug('"scrollAmount" can contain trailing non-numeric values:');
testParent.innerHTML = '<marquee id="marquee" scrollamount="5a">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollAmount', '5');
debug('Setting "scrollAmount" to a negative value should set to the default value:');
testParent.innerHTML = '<marquee id="marquee">test</marquee>';
marquee = document.getElementById('marquee');
shouldNotThrow('marquee.scrollAmount = -1;');
shouldBe('marquee.scrollAmount', '6');
debug('Setting "scrollAmount" to a value that is too large should set to the default value:');
testParent.innerHTML = '<marquee id="marquee">test</marquee>';
marquee = document.getElementById('marquee');
shouldNotThrow('marquee.scrollAmount = 2147483648;');
shouldBe('marquee.scrollAmount', '6');
debug('Default "scrollDelay" value is 85:');
testParent.innerHTML = '<marquee id="marquee">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollDelay', '85');
debug('"scrollDelay" uses default value when content attribute is not a number:');
testParent.innerHTML = '<marquee id="marquee" scrolldelay="a1">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollDelay', '85');
debug('"scrollDelay" uses default value when content attribute is too large:');
testParent.innerHTML = '<marquee id="marquee" scrolldelay="2147483648">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollDelay', '85');
debug('"scrollDelay" uses default value when content attribute is negative:');
testParent.innerHTML = '<marquee id="marquee" scrolldelay="-1">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollDelay', '85');
debug('"scrollDelay" can be set to 0:');
testParent.innerHTML = '<marquee id="marquee" scrolldelay="0">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollDelay', '0');
debug('"scrollDelay" can be set to 2^31-1:');
testParent.innerHTML = '<marquee id="marquee" scrolldelay="2147483647">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollDelay', '2147483647');
debug('"scrollDelay" can contain whitespace:');
testParent.innerHTML = '<marquee id="marquee" scrolldelay=" 5 ">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollDelay', '5');
debug('"scrollDelay" can contain trailing non-numeric values:');
testParent.innerHTML = '<marquee id="marquee" scrolldelay="5a">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.scrollDelay', '5');
debug('Setting "scrollDelay" to a negative value should set to the default value:');
testParent.innerHTML = '<marquee id="marquee">test</marquee>';
marquee = document.getElementById('marquee');
shouldNotThrow('marquee.scrollDelay = -1;');
shouldBe('marquee.scrollDelay', '85');
debug('Setting "scrollDelay" to a value that is too large should set to the default value:');
testParent.innerHTML = '<marquee id="marquee">test</marquee>';
marquee = document.getElementById('marquee');
shouldNotThrow('marquee.scrollDelay = 2147483648;');
shouldBe('marquee.scrollDelay', '85');
debug('Default "loop" value is -1:');
testParent.innerHTML = '<marquee id="marquee">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.loop', '-1');
debug('"loop" uses default value when content attribute is not a number:');
testParent.innerHTML = '<marquee id="marquee" loop="a1">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.loop', '-1');
debug('"loop" uses default value when content attribute is too large:');
testParent.innerHTML = '<marquee id="marquee" loop="2147483648">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.loop', '-1');
debug('"loop" uses default value when content attribute is negative:');
testParent.innerHTML = '<marquee id="marquee" loop="-5">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.loop', '-1');
debug('"loop" uses default value when set to 0:');
testParent.innerHTML = '<marquee id="marquee" loop="0">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.loop', '-1');
debug('"loop" can be set to 1:');
testParent.innerHTML = '<marquee id="marquee" loop="1">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.loop', '1');
debug('"loop" can be set to 2^31-1:');
testParent.innerHTML = '<marquee id="marquee" loop="2147483647">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.loop', '2147483647');
debug('"loop" can contain whitespace:');
testParent.innerHTML = '<marquee id="marquee" loop=" 5 ">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.loop', '5');
debug('"loop" can contain trailing non-numeric values:');
testParent.innerHTML = '<marquee id="marquee" loop="5a">test</marquee>';
marquee = document.getElementById('marquee');
shouldBe('marquee.loop', '5');
debug('Setting "loop" to 0 raises an exception:');
testParent.innerHTML = '<marquee id="marquee">test</marquee>';
shouldThrow('document.getElementById("marquee").loop = 0;');
debug('Setting "loop" to a negative value raises an exception:');
testParent.innerHTML = '<marquee id="marquee">test</marquee>';
shouldThrow('document.getElementById("marquee").loop = -5;');
debug('"loop" can be set to -1 by script:');
testParent.innerHTML = '<marquee id="marquee" loop="5">test</marquee>';
marquee = document.getElementById('marquee');
marquee.loop = -1;
shouldBe('marquee.loop', '-1');
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>