[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.22
[framework/web/webkit-efl.git] / LayoutTests / fast / images / image-map-multiple.html
1 <script>
2
3 var test = 1;
4 var map1;
5 var map2;
6 var map3;
7
8 function setResult(result)
9 {
10     var message = "FAIL: Unexpected result: " + result;
11
12     if (test === 1) {
13         if (result === '1')
14             message = "PASS: Hit the first map in the document.";
15         map1.name = "anothername";
16     }
17     if (test === 2) {
18         if (result === '2')
19             message = "PASS: Hit the second map after the first was renamed.";
20         map1.name = "mapname";
21     }
22     if (test === 3) {
23         if (result === '1')
24             message = "PASS: Hit the first map after it was renamed back.";
25         map1.parentNode.removeChild(map1);
26     }
27     if (test === 4) {
28         if (result === '2')
29             message = "PASS: Hit the second map after the first was removed.";
30         map2.parentNode.insertBefore(map1, map2);
31     }
32     if (test === 5) {
33         if (result === '1')
34             message = "PASS: Hit the first map after it was added back.";
35         map2.parentNode.removeChild(map2);
36     }
37     if (test === 6) {
38         if (result === '1')
39             message = "PASS: Hit the first map after the second was removed.";
40         map3.parentNode.insertBefore(map2, map3);
41     }
42     if (test === 7) {
43         if (result === '1')
44             message = "PASS: Hit the first map after the second was re-added.";
45     }
46
47     document.getElementById("log").textContent += test + ": " + message + "\n";
48     ++test;
49 }
50
51 function runTest()
52 {
53     map1 = document.getElementsByTagName("map")[0];
54     map2 = document.getElementsByTagName("map")[1];
55     map3 = document.getElementsByTagName("map")[2];
56
57     var numClicks = 7;
58     if (!window.eventSender) {
59         document.getElementById("log").textContent = "To run the test manually, click " + numClicks + " times in the image rectangle.\n";
60         return;
61     }
62     layoutTestController.dumpAsText();
63     eventSender.mouseMoveTo(50, 50);
64     for (var click = 0; click < numClicks; ++click) {
65         eventSender.mouseDown();
66         eventSender.mouseUp();
67     }
68 }
69
70 </script>
71 <body onload="runTest()">
72 <map name="mapName"><area shape=rect coords="0,0,100,100" onclick="setResult('1')"></map>
73 <map name="mapname"><area shape=rect coords="0,0,100,100" onclick="setResult('2')"></map>
74 <map name="mapname"><area shape=rect coords="0,0,100,100" onclick="setResult('3')"></map>
75 <img src="resources/green.jpg" border=20 width=100 height=100 usemap="#mapname" ismap onclick="setResult('img')">
76 <div>This tests image map behavior when there are multiple maps with the same name.</div>
77 <pre id="log"></pre>
78 </body>