<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<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")[1];
map2 = document.getElementsByTagName("map")[2];
map3 = document.getElementsByTagName("map")[3];
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; numClicks > click; ++click) {
eventSender.mouseDown();
eventSender.mouseUp();
}
}
</script>
</head>
<body onload="runTest()">
<map name="mapName"><area shape="rect" coords="0,0,100,100" onclick="setResult('0')" /></map>
<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="ismap" onclick="setResult('img')" />
<div>This tests image map behavior when there are multiple maps with the same name.</div>
<pre id="log" />
</body>
</html>