Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>Test that when image map areas have their shape or coordinate dynamically altered, the clickable region changes.</title> |
| 3 <head> | 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 </head> | |
| 6 <body> | 5 <body> |
| 7 <script src="script-tests/imagemap-dynamic-area-updates.js"></script> | 6 <script> |
| 8 </body> | 7 test(function() { |
| 9 </html> | 8 var image = document.createElement('img'); |
| 9 image.setAttribute('usemap', '#m'); | |
| 10 image.style.width = '400px'; | |
| 11 image.style.height = '400px'; | |
| 12 image.style.border = '1px solid red'; | |
| 13 image.style.position = 'absolute'; | |
| 14 image.style.left = '0'; | |
| 15 image.style.top = '0'; | |
| 16 var area = document.createElement('area'); | |
| 17 area.setAttribute('href', '#'); | |
| 18 area.setAttribute('onclick', 'areaClicked = true; return false;'); | |
| 19 areaClicked = false; | |
|
Srirama
2016/08/16 14:22:19
make it local with "var" and move it above before
sivag
2016/08/16 14:53:12
I think this is needed here
to get the access.
| |
| 20 var map = document.createElement('map'); | |
| 21 map.setAttribute('name', 'm'); | |
| 22 map.appendChild(area); | |
| 23 document.body.appendChild(image); | |
| 24 document.body.appendChild(map); | |
| 25 | |
| 26 function setArea(shape, coords) { | |
| 27 area.setAttribute('shape', shape); | |
| 28 area.setAttribute('coords', coords); | |
| 29 } | |
| 30 | |
| 31 function checkForArea(x, y) { | |
| 32 console.log("eventSender"); | |
|
Srirama
2016/08/16 14:22:19
you can remove these 3 lines.
sivag
2016/08/16 14:53:12
Done.
| |
| 33 if (!window.eventSender) | |
| 34 return false; | |
| 35 areaClicked = false; | |
| 36 eventSender.mouseMoveTo(x, y); | |
| 37 eventSender.mouseDown(); | |
| 38 eventSender.mouseUp(); | |
| 39 return areaClicked; | |
| 40 } | |
| 41 setArea('default', ''); | |
| 42 assert_equals(checkForArea(50, 50), true); | |
| 43 setArea('default', ''); | |
| 44 assert_equals(checkForArea(50, 50), true); | |
| 45 setArea('rect', '0, 0, 100, 100'); | |
| 46 assert_equals(checkForArea(50, 50), true); | |
| 47 setArea('rect', '0, 0, 100, 100'); | |
| 48 assert_equals(checkForArea(150, 150), false); | |
| 49 setArea('rect', '200, 200, 300, 300'); | |
| 50 assert_equals(checkForArea(50, 50), false); | |
| 51 setArea('rect', '200, 200, 300, 300'); | |
| 52 assert_equals(checkForArea(250, 250), true); | |
| 53 setArea('circle', '100, 100, 50'); | |
| 54 assert_equals(checkForArea(100, 100), true); | |
| 55 setArea('circle', '100, 100, 50'); | |
| 56 assert_equals(checkForArea(120, 100), true); | |
| 57 setArea('circle', '100, 100, 50'); | |
| 58 assert_equals(checkForArea(200, 100), false); | |
| 59 setArea('circle', '300, 300, 50'); | |
| 60 assert_equals(checkForArea(100, 100), false); | |
| 61 setArea('circle', '300, 300, 50'); | |
| 62 assert_equals(checkForArea(300, 300), true); | |
| 63 setArea('circle', '300, 300, 50'); | |
| 64 assert_equals(checkForArea(320, 300), true); | |
| 65 setArea('poly', '100, 100, 200, 100, 200, 200'); | |
| 66 assert_equals(checkForArea(150, 150), true); | |
| 67 setArea('poly', '100, 100, 200, 100, 200, 200'); | |
| 68 assert_equals(checkForArea(100, 150), false); | |
| 69 setArea('poly', '100, 100, 200, 100, 200, 200'); | |
| 70 assert_equals(checkForArea(300, 300), false); | |
| 71 setArea('default', ''); | |
| 72 assert_equals(checkForArea(300, 300), true); | |
| 73 document.body.removeChild(image); | |
| 74 }); | |
| 75 </script> | |
| OLD | NEW |