widget/tests/chrome_context_menus_win.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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>

mercurial