content/xbl/test/test_bug378518.xul
author Nicholas Nethercote <nnethercote@mozilla.com>
Wed, 18 Jul 2012 17:38:10 -0700
changeset 105208 61d052e202c8ca786b42f7f9116c2619d5a45fe6
parent 75084 67f6f1908b0f4cb8c00d3de763787fdb8fe8eeeb
permissions -rw-r--r--
Bug 647367 - Sequester jshash.{h,cpp} in js/jsd/. r=luke.

<?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[

    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>