Index: third_party/WebKit/LayoutTests/fast/images/imagemap-dynamic-area-updates.html |
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-dynamic-area-updates.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-dynamic-area-updates.html |
index e3790e5950ef5ec80d5ce9a5ff368d009984d966..182d986a96f1d320761514f656c8124c5883a672 100644 |
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-dynamic-area-updates.html |
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-dynamic-area-updates.html |
@@ -1,9 +1,75 @@ |
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
-<html> |
-<head> |
-<script src="../../resources/js-test.js"></script> |
-</head> |
+<!DOCTYPE html> |
+<title>Test that when image map areas have their shape or coordinate dynamically altered, the clickable region changes.</title> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
<body> |
-<script src="script-tests/imagemap-dynamic-area-updates.js"></script> |
-</body> |
-</html> |
+<script> |
+test(function() { |
+ var image = document.createElement('img'); |
+ image.setAttribute('usemap', '#m'); |
+ image.style.width = '400px'; |
+ image.style.height = '400px'; |
+ image.style.border = '1px solid red'; |
+ image.style.position = 'absolute'; |
+ image.style.left = '0'; |
+ image.style.top = '0'; |
+ var area = document.createElement('area'); |
+ area.setAttribute('href', '#'); |
+ area.setAttribute('onclick', 'areaClicked = true; return false;'); |
+ 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.
|
+ var map = document.createElement('map'); |
+ map.setAttribute('name', 'm'); |
+ map.appendChild(area); |
+ document.body.appendChild(image); |
+ document.body.appendChild(map); |
+ |
+ function setArea(shape, coords) { |
+ area.setAttribute('shape', shape); |
+ area.setAttribute('coords', coords); |
+ } |
+ |
+ function checkForArea(x, y) { |
+ console.log("eventSender"); |
Srirama
2016/08/16 14:22:19
you can remove these 3 lines.
sivag
2016/08/16 14:53:12
Done.
|
+ if (!window.eventSender) |
+ return false; |
+ areaClicked = false; |
+ eventSender.mouseMoveTo(x, y); |
+ eventSender.mouseDown(); |
+ eventSender.mouseUp(); |
+ return areaClicked; |
+ } |
+ setArea('default', ''); |
+ assert_equals(checkForArea(50, 50), true); |
+ setArea('default', ''); |
+ assert_equals(checkForArea(50, 50), true); |
+ setArea('rect', '0, 0, 100, 100'); |
+ assert_equals(checkForArea(50, 50), true); |
+ setArea('rect', '0, 0, 100, 100'); |
+ assert_equals(checkForArea(150, 150), false); |
+ setArea('rect', '200, 200, 300, 300'); |
+ assert_equals(checkForArea(50, 50), false); |
+ setArea('rect', '200, 200, 300, 300'); |
+ assert_equals(checkForArea(250, 250), true); |
+ setArea('circle', '100, 100, 50'); |
+ assert_equals(checkForArea(100, 100), true); |
+ setArea('circle', '100, 100, 50'); |
+ assert_equals(checkForArea(120, 100), true); |
+ setArea('circle', '100, 100, 50'); |
+ assert_equals(checkForArea(200, 100), false); |
+ setArea('circle', '300, 300, 50'); |
+ assert_equals(checkForArea(100, 100), false); |
+ setArea('circle', '300, 300, 50'); |
+ assert_equals(checkForArea(300, 300), true); |
+ setArea('circle', '300, 300, 50'); |
+ assert_equals(checkForArea(320, 300), true); |
+ setArea('poly', '100, 100, 200, 100, 200, 200'); |
+ assert_equals(checkForArea(150, 150), true); |
+ setArea('poly', '100, 100, 200, 100, 200, 200'); |
+ assert_equals(checkForArea(100, 150), false); |
+ setArea('poly', '100, 100, 200, 100, 200, 200'); |
+ assert_equals(checkForArea(300, 300), false); |
+ setArea('default', ''); |
+ assert_equals(checkForArea(300, 300), true); |
+ document.body.removeChild(image); |
+}); |
+</script> |