1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/tests/chrome_context_menus_win.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,101 @@ 1.4 +<?xml version="1.0"?> 1.5 + 1.6 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.7 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.9 + 1.10 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.11 + 1.12 +<window id="ChromeContextMenuTest" 1.13 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.14 + width="300" 1.15 + height="300" 1.16 + title="Chrome Context Menu Test w/Plugin Focus"> 1.17 + 1.18 +<script type="application/javascript" 1.19 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 1.20 +<script type="application/javascript" 1.21 + src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.22 + 1.23 +<popupset> 1.24 + <menupopup id="testmenu" onpopupshown="menuDisplayed()"> 1.25 + <menuitem label="One"/> 1.26 + <menuitem label="Two"/> 1.27 + <menuitem label="Three"/> 1.28 + </menupopup> 1.29 +</popupset> 1.30 + 1.31 +<toolbox> 1.32 + <toolbar id="nav-toolbar" style="height:30px" context="testmenu"> 1.33 + </toolbar> 1.34 +</toolbox> 1.35 + 1.36 +<script type="application/javascript"><![CDATA[ 1.37 + 1.38 +function ok(condition, message) { 1.39 + window.opener.wrappedJSObject.SimpleTest.ok(condition, message); 1.40 +} 1.41 + 1.42 +function onTestsFinished() { 1.43 + window.close(); 1.44 + window.opener.wrappedJSObject.SimpleTest.finish(); 1.45 +} 1.46 + 1.47 +function openContextMenuFor(element) { 1.48 + 1.49 + var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). 1.50 + getInterface(Components.interfaces.nsIDOMWindowUtils); 1.51 + 1.52 + var tbX = (window.mozInnerScreenX + 10) * utils.screenPixelsPerCSSPixel; 1.53 + var tbY = (window.mozInnerScreenY + 10) * utils.screenPixelsPerCSSPixel; 1.54 + 1.55 + // See nsWidnow's SynthesizeNativeMouseEvent & SendInput on msdn 1.56 + var MOUSEEVENTF_RIGHTDOWN = 0x0008; 1.57 + var MOUSEEVENTF_RIGHTUP = 0x0010; 1.58 + 1.59 + utils.sendNativeMouseEvent(tbX, tbY, 1.60 + MOUSEEVENTF_RIGHTDOWN, 1.61 + 0, element); 1.62 + utils.sendNativeMouseEvent(tbX, tbY, 1.63 + MOUSEEVENTF_RIGHTUP, 1.64 + 0, element); 1.65 +} 1.66 + 1.67 +var tid = 0; 1.68 + 1.69 +function onFocus() { 1.70 + var _delayedOnLoad = function() { 1.71 + var plugin = document.getElementById("plugin"); 1.72 + var toolbar = document.getElementById("nav-toolbar"); 1.73 + 1.74 + plugin.focus(); 1.75 + 1.76 + tid = setTimeout("menuTimeout()", 5000); 1.77 + 1.78 + openContextMenuFor(toolbar); 1.79 + } 1.80 + setTimeout(_delayedOnLoad, 3000); 1.81 +} 1.82 + 1.83 +function menuTimeout() { 1.84 + ok(false, "Right-click chrome menu did not display with focus on a plugin."); 1.85 + onTestsFinished(); 1.86 +} 1.87 + 1.88 +function menuDisplayed() { 1.89 + clearTimeout(tid); 1.90 + ok(true, "Right-click chrome menu displayed despite plugin having focus."); 1.91 + onTestsFinished(); 1.92 +} 1.93 + 1.94 +window.opener.wrappedJSObject.SimpleTest.waitForFocus(onFocus, window); 1.95 + 1.96 + 1.97 +]]></script> 1.98 + 1.99 +<body xmlns="http://www.w3.org/1999/xhtml"> 1.100 + <br/> 1.101 + <embed id="plugin" type="application/x-test" width="50" height="50"></embed> 1.102 +</body> 1.103 + 1.104 +</window>