Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: third_party/WebKit/LayoutTests/fast/images/imagemap-dynamic-area-updates.html

Issue 2255433002: Use testharness.js instead of js-test.js in fast/images. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use testharness.js instead of js-test.js in fast/images. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698