widget/tests/chrome_context_menus_win.xul

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial