Skip to content

Commit 8d38606

Browse files
committed
Test coords parsing; remove old manual test
This tests whatwg/html#514. In Gecko currently these tests fail because of https://bugzilla.mozilla.org/show_bug.cgi?id=1227469
1 parent 69fddac commit 8d38606

File tree

6 files changed

+154
-27
lines changed

6 files changed

+154
-27
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!doctype html>
2+
<meta charset=utf-8>
3+
<title>HTMLAreaElement coords parsing</title>
4+
<script src=/resources/testharness.js></script>
5+
<script src=/resources/testharnessreport.js></script>
6+
<style>
7+
body { margin: 0 }
8+
</style>
9+
<img src=/images/threecolors.png usemap=#x id=img width=300 height=300>
10+
<map name=x><area id=area></map>
11+
<script src=support/hit-test.js></script>
12+
<script>
13+
tests = [
14+
{desc: 'COMMA', shape: 'rect', coords: "2,2,10,10", hit: hitRect},
15+
{desc: 'SEMICOLON', shape: 'rect', coords: "2;2;10;10", hit: hitRect},
16+
{desc: 'SPACE', shape: 'rect', coords: "2 2 10 10", hit: hitRect},
17+
{desc: 'TAB', shape: 'rect', coords: "2\t2\t10\t10", hit: hitRect},
18+
{desc: 'FORM FEED', shape: 'rect', coords: "2\f2\f10\f10", hit: hitRect},
19+
{desc: 'LINE FEED', shape: 'rect', coords: "2\n2\n10\n10", hit: hitRect},
20+
{desc: 'CARRIGAGE RETURN', shape: 'rect', coords: "2\r2\r10\r10", hit: hitRect},
21+
{desc: 'LINE TABULATION', shape: 'rect', coords: "2\u000b2\u000b10\u000b10", hit: hitNone},
22+
{desc: 'LINE NEXT', shape: 'rect', coords: "2\u00852\u008510\u008510", hit: hitNone},
23+
{desc: 'EN QUAD', shape: 'rect', coords: "2\u20002\u200010\u200010", hit: hitNone},
24+
{desc: 'abc between numbers', shape: 'rect', coords: "2a2b20c20,2,10,10", hit: hitRect},
25+
{desc: 'COLON between numbers', shape: 'rect', coords: "2:2:20:20,2,10,10", hit: hitRect},
26+
{desc: 'U+0000 between numbers', shape: 'rect', coords: "2\u00002\u000020\u000020,2,10,10", hit: hitRect},
27+
{desc: 'leading COMMA', shape: 'rect', coords: ",2,2,10,10", hit: hitRect},
28+
{desc: 'leading SPACE', shape: 'rect', coords: " 2,2,10,10", hit: hitRect},
29+
{desc: 'leading SEMICOLON', shape: 'rect', coords: ";2,2,10,10", hit: hitRect},
30+
{desc: 'trailing COMMA', shape: 'rect', coords: "2,2,10,", hit: hitNone},
31+
{desc: 'trailing SPACE', shape: 'rect', coords: "2,2,10 ", hit: hitNone},
32+
{desc: 'trailing SEMICOLON', shape: 'rect', coords: "2,2,10;", hit: hitNone},
33+
{desc: 'PERCENT', shape: 'rect', coords: "2%,2%,10%,10%", hit: hitRect},
34+
{desc: 'CSS units', shape: 'rect', coords: "2in,2in,10cm,10cm", hit: hitRect},
35+
{desc: 'float', shape: 'rect', coords: "1.4,1.4,10,10", hit: hitRect},
36+
{desc: 'number starting with PERIOD', shape: 'rect', coords: ".4,.4,10,10", hit: [[area, 1, 1], [img, 0, 0]]},
37+
{desc: 'sci-not', shape: 'rect', coords: "2,2,1e1,1e1", hit: hitRect},
38+
{desc: 'leading/trailing garbage', shape: 'rect', coords: "='2,2,10,10' ", hit: hitRect},
39+
{desc: 'non-ascii garbage', shape: 'rect', coords: "“2,2,10,10\"", hit: hitRect},
40+
{desc: 'URL garbage with number', shape: 'rect', coords: "2,2,10ls/spain/holidays/regions/10/Canary+Islands/Canary+Islands.html", hit: hitNone},
41+
{desc: 'consecutive COMMAs', shape: 'rect', coords: "2,,10,10", hit: hitNone},
42+
{desc: 'consecutive SPACEs', shape: 'rect', coords: "2 10,10", hit: hitNone},
43+
{desc: 'consecutive SEMICOLONs', shape: 'rect', coords: "2;;10,10", hit: hitNone},
44+
{desc: 'several consecutive separators', shape: 'rect', coords: ",,2;,;2,;,10 \t\r\n10;;", hit: hitRect},
45+
{desc: 'one too many numbers, trailing COMMA', shape: 'poly', coords: "100,100,120,100,100,120,300,", hit: hitPoly},
46+
];
47+
</script>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!doctype html>
2+
<meta charset=utf-8>
3+
<title>HTMLAreaElement processing</title>
4+
<script src=/resources/testharness.js></script>
5+
<script src=/resources/testharnessreport.js></script>
6+
<style>
7+
body { margin: 0 }
8+
</style>
9+
<img src=/images/threecolors.png usemap=#x id=img width=300 height=300>
10+
<map name=x><area id=area></map>
11+
<script src=support/hit-test.js></script>
12+
<script>
13+
var tests = [
14+
{desc: 'too few numbers', shape: 'rect', coords: "2,2,10", hit: hitNone},
15+
{desc: 'negative', shape: 'rect', coords: "-10,-10,10,10", hit: [[area, 1, 1], [img, 299, 299]]},
16+
{desc: 'empty string', shape: 'rect', coords: "", hit: hitNone},
17+
{desc: 'omitted coords', shape: 'rect', coords: null, hit: hitNone},
18+
{desc: 'first > third', shape: 'rect', coords: "10,2,2,10", hit: hitRect},
19+
{desc: 'second > fourth', shape: 'rect', coords: "2,10,10,2", hit: hitRect},
20+
{desc: 'first > third, second > fourth', shape: 'rect', coords: "10,10,2,2", hit: hitRect},
21+
22+
{desc: 'negative', shape: 'default', coords: "-10,-10,-10,-10", hit: hitAll},
23+
24+
{desc: 'too few numbers', shape: 'circle', coords: "20,40", hit: hitNone},
25+
{desc: 'negative radius', shape: 'circle', coords: "20,40,-10", hit: hitNone},
26+
{desc: 'zero radius', shape: 'circle', coords: "20,40,0", hit: hitNone},
27+
28+
{desc: 'too few numbers', shape: 'poly', coords: "100,100,120,100,100", hit: hitNone},
29+
{desc: 'one too many numbers', shape: 'poly', coords: "100,100,120,100,100,120,300", hit: hitPoly},
30+
{desc: 'even-odd rule', shape: 'poly', coords: "100,100,200,100,100,200,150,50,200,200", hit: hitStar},
31+
];
32+
</script>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!doctype html>
2+
<meta charset=utf-8>
3+
<title>HTMLAreaElement shape</title>
4+
<script src=/resources/testharness.js></script>
5+
<script src=/resources/testharnessreport.js></script>
6+
<style>
7+
body { margin: 0 }
8+
</style>
9+
<img src=/images/threecolors.png usemap=#x id=img width=300 height=300>
10+
<map name=x><area id=area></map>
11+
<script src=support/hit-test.js></script>
12+
<script>
13+
var tests = [
14+
{desc: 'missing value default', shape: null, coords: "2,2,10,10", hit: hitRect},
15+
{desc: 'missing value default', shape: null, coords: "20,40,10", hit: hitNone},
16+
{desc: 'missing value default', shape: null, coords: null, hit: hitNone},
17+
{desc: 'invalid value default', shape: 'foobar invalid', coords: "2,2,10,10", hit: hitRect},
18+
{desc: 'invalid value default', shape: '', coords: "2,2,10,10", hit: hitRect},
19+
20+
{desc: 'empty string', shape: 'default', coords: "", hit: hitAll},
21+
{desc: 'omitted coords', shape: 'DEFAULT', coords: null, hit: hitAll},
22+
23+
{desc: 'simple', shape: 'circle', coords: "20,40,10", hit: hitCircle},
24+
{desc: 'simple', shape: 'circ', coords: "20,40,10", hit: hitCircle},
25+
{desc: 'simple', shape: 'CIRCLE', coords: "20,40,10", hit: hitCircle},
26+
{desc: 'simple', shape: 'CIRC', coords: "20,40,10", hit: hitCircle},
27+
{desc: 'LATIN CAPITAL LETTER I WITH DOT ABOVE', shape: 'C\u0130RCLE', coords: "20,40,10", hit: hitNone},
28+
{desc: 'LATIN SMALL LETTER DOTLESS I', shape: 'c\u0131rcle', coords: "20,40,10", hit: hitNone},
29+
30+
{desc: 'simple', shape: 'poly', coords: "100,100,120,100,100,120", hit: hitPoly},
31+
{desc: 'simple', shape: 'polygon', coords: "100,100,120,100,100,120", hit: hitPoly},
32+
];
33+
</script>

html/semantics/embedded-content/the-area-element/area_nohref.xhtml

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
setup({explicit_done: true});
2+
3+
var img = document.getElementById('img');
4+
var area = document.getElementById('area');
5+
6+
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]];
7+
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]];
8+
var hitAll = [[area, 1, 1], [area, 1, 299], [area, 299, 1], [area, 299, 299], [area, 21, 41], [area, 101, 101]];
9+
var hitCircle = [[area, 11, 40], [area, 29, 40], [area, 20, 31], [area, 20, 49], [img, 12, 32], [img, 28, 48], [img, 101, 101]];
10+
var hitPoly = [[area, 101, 101], [area, 119, 101], [area, 101, 119], [img, 118, 118], [img, 3, 3], [img, 21, 41]];
11+
var hitStar = [[area, 101, 101], [area, 199, 101], [area, 150, 51], [img, 150, 125], [img, 3, 3], [img, 21, 41]];
12+
13+
var tests;
14+
// The test file should have `tests` defined as follows:
15+
// tests = [
16+
// {desc: string, shape: string?, coords: string?, hit: [[element, x, y], ...]},
17+
// ...
18+
// ];
19+
20+
onload = function() {
21+
tests.forEach(function(t) {
22+
test(function(t_obj) {
23+
if (area.shape === null) {
24+
area.removeAttribute('shape');
25+
} else {
26+
area.shape = t.shape;
27+
}
28+
if (area.coords === null) {
29+
area.removeAttribute('coords');
30+
} else {
31+
area.coords = t.coords;
32+
}
33+
t.hit.forEach(function(arr) {
34+
var expected = arr[0];
35+
var x = arr[1];
36+
var y = arr[2];
37+
assert_equals(document.elementFromPoint(x, y), expected, 'elementFromPoint('+x+', '+y+')');
38+
});
39+
}, t.desc + ': ' + format_value(t.coords) + ' (' + t.shape + ')');
40+
});
41+
done();
42+
};

html/semantics/embedded-content/the-area-element/test-area.xhtml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)