summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/images/image-map-multiple-xhtml.xhtml
blob: b42b07cd801e197720649d5ab4571e0bc37e7cf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script>

var test = 1;
var map1;
var map2;
var map3;

function setResult(result)
{
    var message = "FAIL: Unexpected result: " + result;

    if (test === 1) {
        if (result === '1')
            message = "PASS: Hit the first map in the document.";
        map1.name = "anothername";
    }
    if (test === 2) {
        if (result === '2')
            message = "PASS: Hit the second map after the first was renamed.";
        map1.name = "mapname";
    }
    if (test === 3) {
        if (result === '1')
            message = "PASS: Hit the first map after it was renamed back.";
        map1.parentNode.removeChild(map1);
    }
    if (test === 4) {
        if (result === '2')
            message = "PASS: Hit the second map after the first was removed.";
        map2.parentNode.insertBefore(map1, map2);
    }
    if (test === 5) {
        if (result === '1')
            message = "PASS: Hit the first map after it was added back.";
        map2.parentNode.removeChild(map2);
    }
    if (test === 6) {
        if (result === '1')
            message = "PASS: Hit the first map after the second was removed.";
        map3.parentNode.insertBefore(map2, map3);
    }
    if (test === 7) {
        if (result === '1')
            message = "PASS: Hit the first map after the second was re-added.";
    }

    document.getElementById("log").textContent += test + ": " + message + "\n";
    ++test;
}

function runTest()
{
    map1 = document.getElementsByTagName("map")[1];
    map2 = document.getElementsByTagName("map")[2];
    map3 = document.getElementsByTagName("map")[3];

    var numClicks = 7;
    if (!window.eventSender) {
        document.getElementById("log").textContent = "To run the test manually, click " + numClicks + " times in the image rectangle.\n";
        return;
    }
    testRunner.dumpAsText();
    eventSender.mouseMoveTo(50, 50);
    for (var click = 0; numClicks > click; ++click) {
        eventSender.mouseDown();
        eventSender.mouseUp();
    }
}

</script>
</head>
<body onload="runTest()">
<map name="mapName"><area shape="rect" coords="0,0,100,100" onclick="setResult('0')" /></map>
<map name="mapname"><area shape="rect" coords="0,0,100,100" onclick="setResult('1')" /></map>
<map name="mapname"><area shape="rect" coords="0,0,100,100" onclick="setResult('2')" /></map>
<map name="mapname"><area shape="rect" coords="0,0,100,100" onclick="setResult('3')" /></map>
<img src="resources/green.jpg" border="20" width="100" height="100" usemap="mapname" ismap="ismap" onclick="setResult('img')" />
<div>This tests image map behavior when there are multiple maps with the same name.</div>
<pre id="log" />
</body>
</html>