gecko/content/xbl/test/test_bug378518.xul
2013-02-25 18:39:21 -08:00

85 lines
2.6 KiB
XML

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=378518
-->
<window title="Mozilla Bug 378518"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="mybinding" extends="xul:checkbox">
<content>
</content>
</binding>
</bindings>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=378518"
target="_blank">Mozilla Bug 378518</a>
</body>
<!-- The elements we're testing with -->
<command id="myBoxCommand" oncommand="myBoxClicked = true;"/>
<command id="myCheckBoxCommand" oncommand="myCheckBoxClicked = true;"/>
<command id="myExtendedBoxCommand" oncommand="myExtendedBoxClicked = true;"/>
<box id="myBox" command="myBoxCommand">
<label>myBox</label>
</box>
<checkbox id="myCheckBox" command="myCheckBoxCommand" label="myCheckBox"/>
<box id="myExtendedBox" command="myExtendedBoxCommand"
style="-moz-binding:url(#mybinding)">
<label>myExtendedBox</label>
</box>
<!-- test code goes here -->
<script type="application/javascript"> <![CDATA[
SimpleTest.expectAssertions(1);
var myBoxClicked = false;
var myCheckBoxClicked = false;
var myExtendedBoxClicked = false;
function testClick(elemName) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var wu =
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
var a = document.getElementById(elemName).getBoundingClientRect();
wu.sendMouseEvent('mousedown', a.left + 1, a.top + 1, 0, 1, 0);
wu.sendMouseEvent('mouseup', a.left + 1, a.top + 1, 0, 1, 0);
}
function doTest() {
testClick('myBox');
testClick('myCheckBox');
testClick('myExtendedBox');
ok(!myBoxClicked, "Shouldn't fire");
ok(myCheckBoxClicked, "Should fire");
ok(!myExtendedBoxClicked, "Shouldn't fire");
SimpleTest.finish();
}
/** Test for Bug 378518 **/
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
setTimeout(doTest, 0);
});
]]>
</script>
</window>