blob: 15e399fa6f4b9723557a53d5c6299ce31712e0ac [file] [log] [blame]
<script>
var test = 1;
var map1;
var map2;
var map3;
function setResult(result)
{
var message = "FAIL: Unexpected result: " + result;
if (test === 1) {
if (result === '1')
message = "PASS: Hit the first map in the document.";
map1.name = "anothername";
}
if (test === 2) {
if (result === '2')
message = "PASS: Hit the second map after the first was renamed.";
map1.name = "mapname";
}
if (test === 3) {
if (result === '1')
message = "PASS: Hit the first map after it was renamed back.";
map1.parentNode.removeChild(map1);
}
if (test === 4) {
if (result === '2')
message = "PASS: Hit the second map after the first was removed.";
map2.parentNode.insertBefore(map1, map2);
}
if (test === 5) {
if (result === '1')
message = "PASS: Hit the first map after it was added back.";
map2.parentNode.removeChild(map2);
}
if (test === 6) {
if (result === '1')
message = "PASS: Hit the first map after the second was removed.";
map3.parentNode.insertBefore(map2, map3);
}
if (test === 7) {
if (result === '1')
message = "PASS: Hit the first map after the second was re-added.";
}
document.getElementById("log").textContent += test + ": " + message + "\n";
++test;
}
function runTest()
{
map1 = document.getElementsByTagName("map")[0];
map2 = document.getElementsByTagName("map")[1];
map3 = document.getElementsByTagName("map")[2];
var numClicks = 7;
if (!window.eventSender) {
document.getElementById("log").textContent = "To run the test manually, click " + numClicks + " times in the image rectangle.\n";
return;
}
testRunner.dumpAsText();
eventSender.mouseMoveTo(50, 50);
for (var click = 0; click < numClicks; ++click) {
eventSender.mouseDown();
eventSender.mouseUp();
}
}
</script>
<body onload="runTest()">
<map name="mapname"><area shape=rect coords="0,0,100,100" onclick="setResult('1')"></map>
<map name="mapname"><area shape=rect coords="0,0,100,100" onclick="setResult('2')"></map>
<map name="mapname"><area shape=rect coords="0,0,100,100" onclick="setResult('3')"></map>
<img src="resources/green.jpg" border=20 width=100 height=100 usemap="#mapname" ismap onclick="setResult('img')">
<div>This tests image map behavior when there are multiple maps with the same name.</div>
<pre id="log"></pre>
</body>