tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug1224790-2.xhtml (2313B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
      3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
      4 <!--
      5 https://bugzilla.mozilla.org/show_bug.cgi?id=1224790
      6 -->
      7 <window title="Mozilla Bug 1224790"
      8        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
     10  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
     11 
     12  <!-- test code goes here -->
     13  <script type="application/javascript">
     14  <![CDATA[
     15 
     16  /** Test for Bug 1224790 */
     17  /*
     18   * 1. Opens modal dialog
     19   * 2. Open non-modal window from modal dialog
     20   * 3. Close modal dialog
     21   * 4. Wait for a while for destructor for modal dialog
     22   * 5. Close non-modal window
     23   * 6. Click button to ensure mouse event is working
     24   */
     25 
     26  function startTest() {
     27    window.openDialog('file_bug1224790-2_modal.xhtml', '', 'modal,noopener', window);
     28  }
     29 
     30  function nonModalClosed() {
     31    SimpleTest.waitForFocus(gotFocus);
     32  }
     33 
     34  var timer = null;
     35  function gotFocus() {
     36    var button = document.getElementById('button');
     37    synthesizeMouseAtCenter(button, { type: 'mousemove' }, window);
     38    function click() {
     39      // The bug is not reproducible with synthesizeMouseAtCenter.
     40      synthesizeNativeMouseEvent({ type: "click", target: button, atCenter: true });
     41    }
     42    click();
     43    // On debug build, it's possible that the click event handler is not
     44    // triggered by the first click in case the click is dispatched too early
     45    // before Firefox gets ready for input.
     46    // Click the button again after 1 sec when we don't get click event.
     47    timer = setTimeout(click, 1000);
     48  }
     49 
     50  function onClick() {
     51    if (timer) {
     52      // Avoid clicking unrelated thing.
     53      clearTimeout(timer);
     54    }
     55    ok(true, "Click event should be fired");
     56    SimpleTest.finish();
     57  }
     58 
     59  SimpleTest.waitForExplicitFinish();
     60  SimpleTest.waitForFocus(startTest);
     61  ]]>
     62  </script>
     63 
     64  <!-- test results are displayed in the html:body -->
     65  <body xmlns="http://www.w3.org/1999/xhtml">
     66  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1224790"
     67     target="_blank">Mozilla Bug 1224790</a>
     68  </body>
     69  <button id="button" label="button" oncommand="onClick()" />
     70 </window>