OLD | NEW |
1 description("Test that when image map areas have their shape or coordinate dynam
ically altered, the clickable region changes."); | 1 description("Test that when image map areas have their shape or coordinate dynam
ically altered, the clickable region changes."); |
2 | 2 |
3 if (!window.eventSender) | 3 if (!window.eventSender) |
4 debug("This test will only work properly inside DRT."); | 4 debug("This test will only work properly inside DRT."); |
5 | 5 |
6 var image = document.createElement('img'); | 6 var image = document.createElement('img'); |
7 image.setAttribute('usemap', '#m'); | 7 image.setAttribute('usemap', '#m'); |
8 image.style.width = '400px'; | 8 image.style.width = '400px'; |
9 image.style.height = '400px'; | 9 image.style.height = '400px'; |
10 image.style.border = '1px solid red'; | 10 image.style.border = '1px solid red'; |
11 image.style.position = 'absolute'; | 11 image.style.position = 'absolute'; |
12 image.style.left = '0'; | 12 image.style.left = '0'; |
13 image.style.top = '0'; | 13 image.style.top = '0'; |
14 | 14 |
15 area = document.createElement('area'); | 15 area = document.createElement('area'); |
16 area.setAttribute('href', '#'); | 16 area.setAttribute('href', '#'); |
17 area.setAttribute('onclick', 'areaClicked = true; return false;'); | 17 area.setAttribute('onclick', 'areaClicked = true; return false;'); |
18 | 18 |
19 areaClicked = false; | 19 areaClicked = false; |
20 | 20 |
21 var map = document.createElement('map'); | 21 var map = document.createElement('map'); |
22 map.setAttribute('name', 'm'); | 22 map.setAttribute('name', 'm'); |
23 map.appendChild(area); | 23 map.appendChild(area); |
24 | 24 |
25 document.body.appendChild(image); | 25 document.body.appendChild(image); |
26 document.body.appendChild(map); | 26 document.body.appendChild(map); |
27 | 27 |
28 // Mouse events only work after an initial layout | |
29 document.body.offsetLeft; | |
30 | |
31 function setArea(shape, coords) | 28 function setArea(shape, coords) |
32 { | 29 { |
33 area.setAttribute('shape', shape); | 30 area.setAttribute('shape', shape); |
34 area.setAttribute('coords', coords); | 31 area.setAttribute('coords', coords); |
35 } | 32 } |
36 | 33 |
37 function checkForArea(x, y) | 34 function checkForArea(x, y) |
38 { | 35 { |
39 if (!window.eventSender) | 36 if (!window.eventSender) |
40 return false; | 37 return false; |
(...skipping 23 matching lines...) Expand all Loading... |
64 shouldBe("setArea('circle', '300, 300, 50'); checkForArea(300, 300)", "true"); | 61 shouldBe("setArea('circle', '300, 300, 50'); checkForArea(300, 300)", "true"); |
65 shouldBe("setArea('circle', '300, 300, 50'); checkForArea(320, 300)", "true"); | 62 shouldBe("setArea('circle', '300, 300, 50'); checkForArea(320, 300)", "true"); |
66 | 63 |
67 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(150, 150
)", "true"); | 64 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(150, 150
)", "true"); |
68 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(100, 150
)", "false"); | 65 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(100, 150
)", "false"); |
69 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(300, 300
)", "false"); | 66 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(300, 300
)", "false"); |
70 | 67 |
71 shouldBe("setArea('default', ''); checkForArea(300, 300)", "true"); | 68 shouldBe("setArea('default', ''); checkForArea(300, 300)", "true"); |
72 | 69 |
73 document.body.removeChild(image); | 70 document.body.removeChild(image); |
OLD | NEW |