Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <?xml version="1.0"?>
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/. -->
7 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
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">
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>
20 <popupset>
21 <menupopup id="testmenu" onpopupshown="menuDisplayed()">
22 <menuitem label="One"/>
23 <menuitem label="Two"/>
24 <menuitem label="Three"/>
25 </menupopup>
26 </popupset>
28 <toolbox>
29 <toolbar id="nav-toolbar" style="height:30px" context="testmenu">
30 </toolbar>
31 </toolbox>
33 <script type="application/javascript"><![CDATA[
35 function ok(condition, message) {
36 window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
37 }
39 function onTestsFinished() {
40 window.close();
41 window.opener.wrappedJSObject.SimpleTest.finish();
42 }
44 function openContextMenuFor(element) {
46 var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
47 getInterface(Components.interfaces.nsIDOMWindowUtils);
49 var tbX = (window.mozInnerScreenX + 10) * utils.screenPixelsPerCSSPixel;
50 var tbY = (window.mozInnerScreenY + 10) * utils.screenPixelsPerCSSPixel;
52 // See nsWidnow's SynthesizeNativeMouseEvent & SendInput on msdn
53 var MOUSEEVENTF_RIGHTDOWN = 0x0008;
54 var MOUSEEVENTF_RIGHTUP = 0x0010;
56 utils.sendNativeMouseEvent(tbX, tbY,
57 MOUSEEVENTF_RIGHTDOWN,
58 0, element);
59 utils.sendNativeMouseEvent(tbX, tbY,
60 MOUSEEVENTF_RIGHTUP,
61 0, element);
62 }
64 var tid = 0;
66 function onFocus() {
67 var _delayedOnLoad = function() {
68 var plugin = document.getElementById("plugin");
69 var toolbar = document.getElementById("nav-toolbar");
71 plugin.focus();
73 tid = setTimeout("menuTimeout()", 5000);
75 openContextMenuFor(toolbar);
76 }
77 setTimeout(_delayedOnLoad, 3000);
78 }
80 function menuTimeout() {
81 ok(false, "Right-click chrome menu did not display with focus on a plugin.");
82 onTestsFinished();
83 }
85 function menuDisplayed() {
86 clearTimeout(tid);
87 ok(true, "Right-click chrome menu displayed despite plugin having focus.");
88 onTestsFinished();
89 }
91 window.opener.wrappedJSObject.SimpleTest.waitForFocus(onFocus, window);
94 ]]></script>
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>
101 </window>