tor-browser

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

file_bug830858.xhtml (2858B)


      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=830858
      6 -->
      7 <window title="Mozilla Bug 830858"
      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 results are displayed in the html:body -->
     13  <body xmlns="http://www.w3.org/1999/xhtml">
     14  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=830858"
     15     target="_blank">Mozilla Bug 830858</a>
     16  </body>
     17 
     18  <!-- test code goes here -->
     19  <script type="application/javascript">
     20  <![CDATA[
     21  /** Test for Bug 830858 */
     22 
     23  function runTests() {
     24    var b = document.getElementById("b");
     25    var win = b.contentWindow;
     26    var doc = win.document;
     27    var wu = win.windowUtils;
     28 
     29    var docListenerCalled = 0;
     30    doc.addEventListener("foo", function() { ++docListenerCalled; }, true);
     31    var winListenerCalled = 0;
     32    win.addEventListener("foo", function() { ++winListenerCalled; }, true);
     33    var iframeListenerCalled = 0;
     34    b.addEventListener("foo", function() { ++iframeListenerCalled; }, true);
     35 
     36    doc.dispatchEvent(new Event("foo"));
     37    window.arguments[0].is(docListenerCalled, 1, "Normal dispatch to Document");
     38    window.arguments[0].is(winListenerCalled, 1, "Normal dispatch to Document");
     39    window.arguments[0].is(iframeListenerCalled, 1, "Normal dispatch to Document");
     40 
     41    win.dispatchEvent(new Event("foo"));
     42    window.arguments[0].is(docListenerCalled, 1, "Normal dispatch to Window");
     43    window.arguments[0].is(winListenerCalled, 2, "Normal dispatch to Window");
     44    window.arguments[0].is(iframeListenerCalled, 2, "Normal dispatch to Window");
     45 
     46    wu.dispatchEventToChromeOnly(doc, new Event("foo"));
     47    window.arguments[0].is(docListenerCalled, 1, "Chrome-only dispatch to Document");
     48    window.arguments[0].is(winListenerCalled, 2, "Chrome-only dispatch to Document");
     49    window.arguments[0].is(iframeListenerCalled, 3, "Chrome-only dispatch to Document");
     50 
     51    wu.dispatchEventToChromeOnly(win, new Event("foo"));
     52    window.arguments[0].is(docListenerCalled, 1, "Chrome-only dispatch to Window");
     53    window.arguments[0].is(winListenerCalled, 2, "Chrome-only dispatch to Window");
     54    window.arguments[0].is(iframeListenerCalled, 4, "Chrome-only dispatch to Window");
     55 
     56    window.close();
     57    window.arguments[0].finishedTests();
     58  }
     59 
     60  SimpleTest.waitForFocus(runTests);
     61  ]]>
     62  </script>
     63  <iframe xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     64          id="b" type="content" src="about:blank"
     65          style="width: 300px; height: 550px; border: 1px solid black;"/>
     66 </window>