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; | |
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); | |
fs
2016/08/16 15:17:07
Could this just be added to the HTML directly?
<i
sivag
2016/08/16 16:42:59
Done.
| |
25 | |
26 function setArea(shape, coords) { | |
27 area.setAttribute('shape', shape); | |
28 area.setAttribute('coords', coords); | |
29 } | |
30 | |
31 function checkForArea(x, y) { | |
fs
2016/08/16 15:17:07
Nit: Maybe rename this to checkPointInArea or so.
sivag
2016/08/16 16:42:59
Done.
| |
32 areaClicked = false; | |
33 eventSender.mouseMoveTo(x, y); | |
fs
2016/08/16 15:17:07
If elementFromPoint could be used here instead tha
sivag
2016/08/16 16:42:59
Done.
| |
34 eventSender.mouseDown(); | |
35 eventSender.mouseUp(); | |
36 return areaClicked; | |
37 } | |
38 setArea('default', ''); | |
39 assert_equals(checkForArea(50, 50), true); | |
fs
2016/08/16 15:17:07
assert_equals(..., true) -> assert_true(...)
(Unl
sivag
2016/08/16 16:42:59
Done.
| |
40 setArea('default', ''); | |
41 assert_equals(checkForArea(50, 50), true); | |
42 setArea('rect', '0, 0, 100, 100'); | |
43 assert_equals(checkForArea(50, 50), true); | |
44 setArea('rect', '0, 0, 100, 100'); | |
45 assert_equals(checkForArea(150, 150), false); | |
fs
2016/08/16 15:17:07
assert_false
sivag
2016/08/16 16:42:59
Done.
| |
46 setArea('rect', '200, 200, 300, 300'); | |
47 assert_equals(checkForArea(50, 50), false); | |
48 setArea('rect', '200, 200, 300, 300'); | |
49 assert_equals(checkForArea(250, 250), true); | |
50 setArea('circle', '100, 100, 50'); | |
51 assert_equals(checkForArea(100, 100), true); | |
52 setArea('circle', '100, 100, 50'); | |
53 assert_equals(checkForArea(120, 100), true); | |
54 setArea('circle', '100, 100, 50'); | |
55 assert_equals(checkForArea(200, 100), false); | |
56 setArea('circle', '300, 300, 50'); | |
57 assert_equals(checkForArea(100, 100), false); | |
58 setArea('circle', '300, 300, 50'); | |
59 assert_equals(checkForArea(300, 300), true); | |
60 setArea('circle', '300, 300, 50'); | |
61 assert_equals(checkForArea(320, 300), true); | |
62 setArea('poly', '100, 100, 200, 100, 200, 200'); | |
63 assert_equals(checkForArea(150, 150), true); | |
64 setArea('poly', '100, 100, 200, 100, 200, 200'); | |
65 assert_equals(checkForArea(100, 150), false); | |
66 setArea('poly', '100, 100, 200, 100, 200, 200'); | |
67 assert_equals(checkForArea(300, 300), false); | |
68 setArea('default', ''); | |
69 assert_equals(checkForArea(300, 300), true); | |
70 document.body.removeChild(image); | |
fs
2016/08/16 15:17:07
No need for this I think.
sivag
2016/08/16 16:42:59
Done.
| |
71 }); | |
72 </script> | |
OLD | NEW |