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
86
87
88
89
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1472427
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1472427</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for Bug 1472427 **/
SimpleTest.waitForExplicitFinish();
var image100x100 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAnUlEQVR42u3RAQ0AAAQAMLJqqCA1zP4Kz+qe4IwUIgQhQhAiBCFCECJEiBCECEGIEIQIQYgQhCBECEKEIEQIQoQgBCFCECIEIUIQIgQhCBGCECEIEYIQIQhBiBCECEGIEIQIQQhChCBECEKEIEQIQhAiBCFCECIEIUIQghAhCBGCECEIEYIQhAhBiBCECEGIEIQIESIEIUIQIgQh3y1XQhXMIlaKKwAAAABJRU5ErkJggg==";
var ifr;
var doc;
var img;
var host;
var root;
var map;
var area;
function initPage() {
ifr = document.createElement("iframe");
ifr.src = "about:blank";
document.body.appendChild(ifr);
ifr.onload = initIframe;
}
function initIframe() {
ifr.contentWindow.focus();
doc = ifr.contentDocument;
host = doc.createElement("div");
doc.body.appendChild(host);
root = host.attachShadow({mode: "open"});
img = document.createElement("img");
img.useMap = "#map"
img.src = image100x100;
img.onload = runTest;
root.appendChild(img);
map = doc.createElement("map");
map.name = "map";
root.appendChild(map);
area = doc.createElement("area");
area.shape = "rect";
area.href = "#area";
area.coords = "0,0,100,100";
map.appendChild(area);
}
function runTest() {
var gotClick = false;
var expectedTarget = area;
root.addEventListener("click",
function(e) {
gotClick = true;
is(e.target, expectedTarget,
expectedTarget.localName + " element should be the target for the click.");
e.preventDefault();
});
synthesizeMouse(img, 50, 50, {}, ifr.contentWindow);
ok(gotClick, "Should have got a click event.");
gotclick = false;
map.name = "wrongNameMap";
expectedTarget = img;
synthesizeMouse(img, 50, 50, {}, ifr.contentWindow);
ok(gotClick, "Should have got a click event.");
SimpleTest.finish();
}
</script>
</head>
<body onload="initPage()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1472427">Mozilla Bug 1472427</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>
|