toolkit/content/tests/chrome/test_bug557987.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 4 <!--
michael@0 5 XUL Widget Test for bug 557987
michael@0 6 -->
michael@0 7 <window title="Bug 557987" width="400" height="400"
michael@0 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 11
michael@0 12 <toolbarbutton id="button" type="menu-button" label="Test bug 557987"
michael@0 13 onclick="eventReceived('click');"
michael@0 14 oncommand="eventReceived('command');">
michael@0 15 <menupopup onpopupshowing="eventReceived('popupshowing'); return false;" />
michael@0 16 </toolbarbutton>
michael@0 17 <menulist id="menulist" editable="true" value="Test bug 557987"
michael@0 18 onfocus="eventReceived('focus')" />
michael@0 19 <!-- test results are displayed in the html:body -->
michael@0 20 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
michael@0 21
michael@0 22 <script type="application/javascript">
michael@0 23 <![CDATA[
michael@0 24
michael@0 25 SimpleTest.waitForExplicitFinish();
michael@0 26
michael@0 27 SimpleTest.waitForFocus(test);
michael@0 28
michael@0 29 // Tests that mouse events are correctly dispatched to <toolbarbutton type="menu-button"/>
michael@0 30 function test() {
michael@0 31
michael@0 32 disableNonTestMouseEvents(true);
michael@0 33
michael@0 34 let button = $("button");
michael@0 35 let rightEdge = button.getBoundingClientRect().width - 2;
michael@0 36 let centerX = button.getBoundingClientRect().width / 2;
michael@0 37 let centerY = button.getBoundingClientRect().height / 2;
michael@0 38
michael@0 39 synthesizeMouse(button, rightEdge, centerY, {}, window);
michael@0 40 synthesizeMouse(button, centerX, centerY, {}, window);
michael@0 41
michael@0 42 let menulist = $("menulist");
michael@0 43 let centerX = menulist.getBoundingClientRect().width / 2;
michael@0 44 let centerY = menulist.getBoundingClientRect().height / 2;
michael@0 45 synthesizeMouse(menulist, centerX, centerY, {}, window);
michael@0 46
michael@0 47 synthesizeMouse(document.getElementsByTagName("body")[0], 0, 0, {}, window);
michael@0 48
michael@0 49 disableNonTestMouseEvents(false);
michael@0 50 SimpleTest.executeSoon(finishTest);
michael@0 51
michael@0 52 }
michael@0 53
michael@0 54 function finishTest() {
michael@0 55 is(eventCount.command, 1, "Correct number of command events received");
michael@0 56 is(eventCount.popupshowing, 1, "Correct number of popupshowing events received");
michael@0 57 is(eventCount.click, 2, "Correct number of click events received");
michael@0 58 is(eventCount.focus, 1, "Correct number of focus events received");
michael@0 59
michael@0 60 SimpleTest.finish();
michael@0 61 }
michael@0 62
michael@0 63 let eventCount = {
michael@0 64 command: 0,
michael@0 65 popupshowing: 0,
michael@0 66 click: 0,
michael@0 67 focus: 0
michael@0 68 };
michael@0 69
michael@0 70 function eventReceived(eventName) {
michael@0 71 eventCount[eventName]++;
michael@0 72 }
michael@0 73
michael@0 74 ]]>
michael@0 75 </script>
michael@0 76 </window>

mercurial