1<html>
2<head>
3<script>
4
5var items;
6
7if (window.layoutTestController) {
8 window.layoutTestController.dumpAsText();
9 window.layoutTestController.waitUntilDone();
10}
11
12function doclick() {
13
14 for (var i = 0; i < items.length; i++)
15 {
16 var title = items[i].title;
17
18 if (!title)
19 break;
20
21 // it is pretty tricky to deal with accelerators in a decent way, but I suppose
22 // just removing the underscores is a good enough way
23
24 title = title.replace(/_/g,'');
25
26 if (title.match("Copy Image")) {
27 items[i].click();
28 break;
29 }
30 }
31
32 // As long as didn't crash, we passed.
33 document.body.innerHTML = "PASS";
34
35 window.layoutTestController.notifyDone();
36}
37
38function hidediv() {
39
40 var div = document.getElementById ("DIV");
41 div.style.display="none";
42
43}
44
45// this is for manual testing only
46function delayhide() {
47
48 setTimeout(hidediv, 100);
49
50}
51
52function doTest() {
53
54 if (!window.layoutTestController)
55 return;
56
57 var image = document.getElementById ("IMG");
58
59 x = image.offsetLeft + 10;
60 y = image.offsetTop + 10;
61
62 eventSender.mouseMoveTo(x, y);
63 items = eventSender.contextClick();
64
65 hidediv();
66
67 setTimeout(doclick, 10);
68
69}
70
71</script>
72</head>
73<body onload="doTest()" onmousedown="delayhide()">
74This is an automated test case for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=31721">31721</a><br>
75If you wish to test manually, mouseover to image, activate context menu, wait for the image to disappear and then click copy image.<br>
76There should be no crash.
77<div ID="DIV">
78 <div> <img id="IMG" src="resources/apple.gif"/> </div>
79 </div>
80</body>
81
82</html>