test_bug1290965.xhtml (1614B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?> 3 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"> 4 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 5 <toolbarbutton oncommand="++countera;" id="a">A</toolbarbutton> 6 <toolbarbutton oncommand="++counterb;" id="b">B</toolbarbutton> 7 <script> 8 //<![CDATA[ 9 let aEl = document.getElementById('a'); 10 let bEl = document.getElementById('b'); 11 let countera = 0; 12 let counterb = 0; 13 14 aEl.addEventListener('click', function (aEvent) { 15 aEvent.preventDefault(); 16 let cmdEvent = document.createEvent("xulcommandevent"); 17 cmdEvent.initCommandEvent("command", true, true, window, 0, 18 aEvent.ctrlKey, aEvent.altKey, aEvent.shiftKey, 19 aEvent.metaKey, 0, null, aEvent.inputSource); 20 aEvent.currentTarget.dispatchEvent(cmdEvent); 21 }); 22 23 bEl.addEventListener('click', function (aEvent) { 24 let cmdEvent = document.createEvent("xulcommandevent"); 25 cmdEvent.initCommandEvent("command", true, true, window, 0, 26 aEvent.ctrlKey, aEvent.altKey, aEvent.shiftKey, 27 aEvent.metaKey, 0, null, aEvent.inputSource); 28 aEvent.currentTarget.dispatchEvent(cmdEvent); 29 }); 30 31 bEl.click(); 32 aEl.click(); 33 34 is(countera, 1, "Counter should be one as event fires once"); 35 is(counterb, 2, "Counter should be two as event fires twice"); 36 //]]> 37 </script> 38 </window>