|
1 <?xml version="1.0"?> |
|
2 |
|
3 <!-- This Source Code Form is subject to the terms of the Mozilla Public |
|
4 - License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
|
6 |
|
7 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
8 |
|
9 <window id="ChromeContextMenuTest" |
|
10 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
11 width="300" |
|
12 height="300" |
|
13 title="Chrome Context Menu Test w/Plugin Focus"> |
|
14 |
|
15 <script type="application/javascript" |
|
16 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> |
|
17 <script type="application/javascript" |
|
18 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
19 |
|
20 <popupset> |
|
21 <menupopup id="testmenu" onpopupshown="menuDisplayed()"> |
|
22 <menuitem label="One"/> |
|
23 <menuitem label="Two"/> |
|
24 <menuitem label="Three"/> |
|
25 </menupopup> |
|
26 </popupset> |
|
27 |
|
28 <toolbox> |
|
29 <toolbar id="nav-toolbar" style="height:30px" context="testmenu"> |
|
30 </toolbar> |
|
31 </toolbox> |
|
32 |
|
33 <script type="application/javascript"><![CDATA[ |
|
34 |
|
35 function ok(condition, message) { |
|
36 window.opener.wrappedJSObject.SimpleTest.ok(condition, message); |
|
37 } |
|
38 |
|
39 function onTestsFinished() { |
|
40 window.close(); |
|
41 window.opener.wrappedJSObject.SimpleTest.finish(); |
|
42 } |
|
43 |
|
44 function openContextMenuFor(element) { |
|
45 |
|
46 var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). |
|
47 getInterface(Components.interfaces.nsIDOMWindowUtils); |
|
48 |
|
49 var tbX = (window.mozInnerScreenX + 10) * utils.screenPixelsPerCSSPixel; |
|
50 var tbY = (window.mozInnerScreenY + 10) * utils.screenPixelsPerCSSPixel; |
|
51 |
|
52 // See nsWidnow's SynthesizeNativeMouseEvent & SendInput on msdn |
|
53 var MOUSEEVENTF_RIGHTDOWN = 0x0008; |
|
54 var MOUSEEVENTF_RIGHTUP = 0x0010; |
|
55 |
|
56 utils.sendNativeMouseEvent(tbX, tbY, |
|
57 MOUSEEVENTF_RIGHTDOWN, |
|
58 0, element); |
|
59 utils.sendNativeMouseEvent(tbX, tbY, |
|
60 MOUSEEVENTF_RIGHTUP, |
|
61 0, element); |
|
62 } |
|
63 |
|
64 var tid = 0; |
|
65 |
|
66 function onFocus() { |
|
67 var _delayedOnLoad = function() { |
|
68 var plugin = document.getElementById("plugin"); |
|
69 var toolbar = document.getElementById("nav-toolbar"); |
|
70 |
|
71 plugin.focus(); |
|
72 |
|
73 tid = setTimeout("menuTimeout()", 5000); |
|
74 |
|
75 openContextMenuFor(toolbar); |
|
76 } |
|
77 setTimeout(_delayedOnLoad, 3000); |
|
78 } |
|
79 |
|
80 function menuTimeout() { |
|
81 ok(false, "Right-click chrome menu did not display with focus on a plugin."); |
|
82 onTestsFinished(); |
|
83 } |
|
84 |
|
85 function menuDisplayed() { |
|
86 clearTimeout(tid); |
|
87 ok(true, "Right-click chrome menu displayed despite plugin having focus."); |
|
88 onTestsFinished(); |
|
89 } |
|
90 |
|
91 window.opener.wrappedJSObject.SimpleTest.waitForFocus(onFocus, window); |
|
92 |
|
93 |
|
94 ]]></script> |
|
95 |
|
96 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
97 <br/> |
|
98 <embed id="plugin" type="application/x-test" width="50" height="50"></embed> |
|
99 </body> |
|
100 |
|
101 </window> |