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

Unified Diff: third_party/WebKit/LayoutTests/fast/html/resources/hit-test.js

Issue 1618373002: Add tests for HTMLAreaElement coords/shape and processing model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment in W3CImportExpectations. Created 4 years, 11 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/html/area-shape-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/html/resources/hit-test.js
diff --git a/third_party/WebKit/LayoutTests/fast/html/resources/hit-test.js b/third_party/WebKit/LayoutTests/fast/html/resources/hit-test.js
new file mode 100644
index 0000000000000000000000000000000000000000..54cda3e5cd183f64254919451e52f04ea1087a9f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/html/resources/hit-test.js
@@ -0,0 +1,42 @@
+setup({explicit_done: true});
+
+var img = document.getElementById('img');
+var area = document.getElementById('area');
+
+var hitRect = [[area, 3, 3], [area, 9, 9], [img, 1, 3], [img, 3, 1], [img, 11, 9], [img, 9, 11], [img, 21, 41], [img, 101, 101]];
+var hitNone = [[img, 3, 3], [img, 9, 9], [img, 1, 3], [img, 3, 1], [img, 11, 9], [img, 9, 11], [img, 21, 41], [img, 101, 101]];
+var hitAll = [[area, 1, 1], [area, 1, 299], [area, 299, 1], [area, 299, 299], [area, 21, 41], [area, 101, 101]];
+var hitCircle = [[area, 11, 40], [area, 29, 40], [area, 20, 31], [area, 20, 49], [img, 12, 32], [img, 28, 48], [img, 101, 101]];
+var hitPoly = [[area, 101, 101], [area, 119, 101], [area, 101, 119], [img, 118, 118], [img, 3, 3], [img, 21, 41]];
+var hitStar = [[area, 101, 101], [area, 199, 101], [area, 150, 51], [img, 150, 125], [img, 3, 3], [img, 21, 41]];
+
+var tests;
+// The test file should have `tests` defined as follows:
+// tests = [
+// {desc: string, shape: string?, coords: string?, hit: [[element, x, y], ...]},
+// ...
+// ];
+
+onload = function() {
+ tests.forEach(function(t) {
+ test(function(t_obj) {
+ if (area.shape === null) {
+ area.removeAttribute('shape');
+ } else {
+ area.shape = t.shape;
+ }
+ if (area.coords === null) {
+ area.removeAttribute('coords');
+ } else {
+ area.coords = t.coords;
+ }
+ t.hit.forEach(function(arr) {
+ var expected = arr[0];
+ var x = arr[1];
+ var y = arr[2];
+ assert_equals(document.elementFromPoint(x, y), expected, 'elementFromPoint('+x+', '+y+')');
+ });
+ }, t.desc + ': ' + format_value(t.coords) + ' (' + t.shape + ')');
+ });
+ done();
+};
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/html/area-shape-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698