3 <!-- ***** BEGIN LICENSE BLOCK *****
4 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 - The contents of this file are subject to the Mozilla Public License Version
7 - 1.1 (the "License"); you may not use this file except in compliance with
8 - the License. You may obtain a copy of the License at
9 - http://www.mozilla.org/MPL/
11 - Software distributed under the License is distributed on an "AS IS" basis,
12 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 - for the specific language governing rights and limitations under the
16 - The Original Code is Native Menus Test code
18 - The Initial Developer of the Original Code is
20 - Portions created by the Initial Developer are Copyright (C) 2010
21 - the Initial Developer. All Rights Reserved.
25 - Alternatively, the contents of this file may be used under the terms of
26 - either the GNU General Public License Version 2 or later (the "GPL"), or
27 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 - in which case the provisions of the GPL or the LGPL are applicable instead
29 - of those above. If you wish to allow use of your version of this file only
30 - under the terms of either the GPL or the LGPL, and not to allow others to
31 - use your version of this file under the terms of the MPL, indicate your
32 - decision by deleting the provisions above and replace them with the notice
33 - and other provisions required by the GPL or the LGPL. If you do not delete
34 - the provisions above, a recipient may use your version of this file under
35 - the terms of any one of the MPL, the GPL or the LGPL.
37 - ***** END LICENSE BLOCK ***** -->
39 <?xml-stylesheet href=
"chrome://global/skin" type=
"text/css"?>
41 <window id=
"ChromeContextMenuTest"
42 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
45 title=
"Chrome Context Menu Test w/Plugin Focus">
47 <script type=
"application/javascript"
48 src=
"chrome://mochikit/content/MochiKit/packed.js"></script>
49 <script type=
"application/javascript"
50 src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
51 <script type=
"application/javascript"
52 src=
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
55 <menupopup id=
"testmenu" onpopupshown=
"menuDisplayed()">
56 <menuitem label=
"One"/>
57 <menuitem label=
"Two"/>
58 <menuitem label=
"Three"/>
63 <toolbar id=
"nav-toolbar" style=
"height:30px" context=
"testmenu">
67 <script type=
"application/javascript"><![CDATA[
69 function ok(condition, message) {
70 window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
73 function onTestsFinished() {
75 window.opener.wrappedJSObject.SimpleTest.finish();
78 function openContextMenuFor(element) {
79 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
81 var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
82 getInterface(Components.interfaces.nsIDOMWindowUtils);
84 var tbX = (window.mozInnerScreenX +
10) * utils.screenPixelsPerCSSPixel;
85 var tbY = (window.mozInnerScreenY +
10) * utils.screenPixelsPerCSSPixel;
87 // See nsWidnow's SynthesizeNativeMouseEvent & SendInput on msdn
88 var MOUSEEVENTF_RIGHTDOWN =
0x0008;
89 var MOUSEEVENTF_RIGHTUP =
0x0010;
91 utils.sendNativeMouseEvent(tbX, tbY,
92 MOUSEEVENTF_RIGHTDOWN,
94 utils.sendNativeMouseEvent(tbX, tbY,
102 var _delayedOnLoad = function() {
103 var plugin = document.getElementById(
"plugin");
104 var toolbar = document.getElementById(
"nav-toolbar");
108 tid = setTimeout(
"menuTimeout()",
5000);
110 openContextMenuFor(toolbar);
112 setTimeout(_delayedOnLoad,
3000);
115 function menuTimeout() {
116 ok(false,
"Right-click chrome menu did not display with focus on a plugin.");
120 function menuDisplayed() {
122 ok(true,
"Right-click chrome menu displayed despite plugin having focus.");
126 window.opener.wrappedJSObject.SimpleTest.waitForFocus(onFocus, window);
131 <body xmlns=
"http://www.w3.org/1999/xhtml">
133 <embed id=
"plugin" type=
"application/x-test" width=
"50" height=
"50"></embed>