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>
9 let aEl = document.getElementById('a');
10 let bEl = document.getElementById('b');
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);
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);
34 is(countera,
1,
"Counter should be one as event fires once");
35 is(counterb,
2,
"Counter should be two as event fires twice");