toolkit/content/tests/chrome/test_bug562554.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 562554
michael@0 6 -->
michael@0 7 <window title="Bug 562554" width="400" height="400"
michael@0 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 9 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 11 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 12
michael@0 13 <xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl">
michael@0 14 <xbl:binding id="menu" display="xul:menu"
michael@0 15 extends="chrome://global/content/bindings/button.xml#button-base">
michael@0 16 <xbl:content>
michael@0 17 <xbl:children includes="menupopup"/>
michael@0 18 <xul:stack>
michael@0 19 <xul:button width="100" left="0" top="0" height="30" allowevents="true"
michael@0 20 onclick="eventReceived('clickbutton1'); return false;"/>
michael@0 21 <xul:button width="100" left="70" top="0" height="30"
michael@0 22 onclick="eventReceived('clickbutton2'); return false;"/>
michael@0 23 </xul:stack>
michael@0 24 </xbl:content>
michael@0 25 </xbl:binding>
michael@0 26 </xbl:bindings>
michael@0 27
michael@0 28 <toolbarbutton type="menu" id="toolbarmenu" height="200" style="-moz-binding: url(#menu);">
michael@0 29 <menupopup id="menupopup" onpopupshowing="eventReceived('popupshowing'); return false;"/>
michael@0 30 </toolbarbutton>
michael@0 31
michael@0 32 <!-- test results are displayed in the html:body -->
michael@0 33 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
michael@0 34
michael@0 35 <script type="application/javascript">
michael@0 36 <![CDATA[
michael@0 37
michael@0 38 SimpleTest.waitForExplicitFinish();
michael@0 39 SimpleTest.waitForFocus(test);
michael@0 40
michael@0 41 // Tests that mouse events are correctly dispatched to <toolbarbutton type="menu"/>
michael@0 42 function test() {
michael@0 43 disableNonTestMouseEvents(true);
michael@0 44 nextTest();
michael@0 45 }
michael@0 46
michael@0 47 let tests = [
michael@0 48 // Click on the toolbarbutton itself - should call popupshowing
michael@0 49 function() synthesizeMouse($("toolbarmenu"), 10, 50, {}, window),
michael@0 50
michael@0 51 // Click on button1 which has allowevents="true" - should call clickbutton1
michael@0 52 function() synthesizeMouse($("toolbarmenu"), 10, 15, {}, window),
michael@0 53
michael@0 54 // Click on button2 where it intersects with button1 - should call popupshowing
michael@0 55 function() synthesizeMouse($("toolbarmenu"), 85, 15, {}, window),
michael@0 56
michael@0 57 // Click on button2 outside of intersection - should call popupshowing
michael@0 58 function() synthesizeMouse($("toolbarmenu"), 150, 15, {}, window)
michael@0 59 ];
michael@0 60
michael@0 61 function nextTest() {
michael@0 62 if (tests.length) {
michael@0 63 let func = tests.shift();
michael@0 64 func();
michael@0 65 SimpleTest.executeSoon(nextTest);
michael@0 66 } else {
michael@0 67 disableNonTestMouseEvents(false);
michael@0 68 SimpleTest.executeSoon(finishTest);
michael@0 69 }
michael@0 70 }
michael@0 71
michael@0 72 function finishTest() {
michael@0 73 is(eventCount.clickbutton1, 1, "Correct number of clicks on button 1");
michael@0 74 is(eventCount.clickbutton2, 0, "Correct number of clicks on button 2");
michael@0 75 is(eventCount.popupshowing, 3, "Correct number of popupshowing events received");
michael@0 76
michael@0 77 SimpleTest.finish();
michael@0 78 }
michael@0 79
michael@0 80 let eventCount = {
michael@0 81 popupshowing: 0,
michael@0 82 clickbutton1: 0,
michael@0 83 clickbutton2: 0
michael@0 84 };
michael@0 85
michael@0 86 function eventReceived(eventName) {
michael@0 87 eventCount[eventName]++;
michael@0 88 }
michael@0 89
michael@0 90 ]]>
michael@0 91 </script>
michael@0 92 </window>

mercurial