| 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 |
| 28 function setArea(shape, coords) | 31 function setArea(shape, coords) |
| 29 { | 32 { |
| 30 area.setAttribute('shape', shape); | 33 area.setAttribute('shape', shape); |
| 31 area.setAttribute('coords', coords); | 34 area.setAttribute('coords', coords); |
| 32 } | 35 } |
| 33 | 36 |
| 34 function checkForArea(x, y) | 37 function checkForArea(x, y) |
| 35 { | 38 { |
| 36 if (!window.eventSender) | 39 if (!window.eventSender) |
| 37 return false; | 40 return false; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 61 shouldBe("setArea('circle', '300, 300, 50'); checkForArea(300, 300)", "true"); | 64 shouldBe("setArea('circle', '300, 300, 50'); checkForArea(300, 300)", "true"); |
| 62 shouldBe("setArea('circle', '300, 300, 50'); checkForArea(320, 300)", "true"); | 65 shouldBe("setArea('circle', '300, 300, 50'); checkForArea(320, 300)", "true"); |
| 63 | 66 |
| 64 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(150, 150
)", "true"); | 67 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(150, 150
)", "true"); |
| 65 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(100, 150
)", "false"); | 68 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(100, 150
)", "false"); |
| 66 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(300, 300
)", "false"); | 69 shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(300, 300
)", "false"); |
| 67 | 70 |
| 68 shouldBe("setArea('default', ''); checkForArea(300, 300)", "true"); | 71 shouldBe("setArea('default', ''); checkForArea(300, 300)", "true"); |
| 69 | 72 |
| 70 document.body.removeChild(image); | 73 document.body.removeChild(image); |
| OLD | NEW |