Chromium Code Reviews| 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..e0e79548bb617f4bd67324bcde0dff663d1d0783 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,72 @@ |
| -<!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; |
| + var map = document.createElement('map'); |
| + map.setAttribute('name', 'm'); |
| + map.appendChild(area); |
| + document.body.appendChild(image); |
| + 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.
|
| + |
| + function setArea(shape, coords) { |
| + area.setAttribute('shape', shape); |
| + area.setAttribute('coords', coords); |
| + } |
| + |
| + 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.
|
| + areaClicked = false; |
| + 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.
|
| + eventSender.mouseDown(); |
| + eventSender.mouseUp(); |
| + return areaClicked; |
| + } |
| + setArea('default', ''); |
| + 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.
|
| + 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); |
|
fs
2016/08/16 15:17:07
assert_false
sivag
2016/08/16 16:42:59
Done.
|
| + 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); |
|
fs
2016/08/16 15:17:07
No need for this I think.
sivag
2016/08/16 16:42:59
Done.
|
| +}); |
| +</script> |