dom/tests/mochitest/chrome/file_bug830858.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/chrome/file_bug830858.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
     1.6 +<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
     1.7 +<!--
     1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=830858
     1.9 +-->
    1.10 +<window title="Mozilla Bug 830858"
    1.11 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.13 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    1.14 +
    1.15 +  <!-- test results are displayed in the html:body -->
    1.16 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.17 +  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=830858"
    1.18 +     target="_blank">Mozilla Bug 830858</a>
    1.19 +  </body>
    1.20 +
    1.21 +  <!-- test code goes here -->
    1.22 +  <script type="application/javascript">
    1.23 +  <![CDATA[
    1.24 +  /** Test for Bug 830858 **/
    1.25 +
    1.26 +  function runTests() {
    1.27 +    var b = document.getElementById("b");
    1.28 +    var win = b.contentWindow;
    1.29 +    var doc = win.document;
    1.30 +    var wu = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
    1.31 +                .getInterface(Components.interfaces.nsIDOMWindowUtils);
    1.32 +
    1.33 +    var docListenerCalled = 0;
    1.34 +    doc.addEventListener("foo", function() { ++docListenerCalled; }, true);
    1.35 +    var winListenerCalled = 0;
    1.36 +    win.addEventListener("foo", function() { ++winListenerCalled; }, true);
    1.37 +    var iframeListenerCalled = 0;
    1.38 +    b.addEventListener("foo", function() { ++iframeListenerCalled; }, true);
    1.39 +
    1.40 +    doc.dispatchEvent(new Event("foo"));
    1.41 +    opener.wrappedJSObject.is(docListenerCalled, 1, "Normal dispatch to Document");
    1.42 +    opener.wrappedJSObject.is(winListenerCalled, 1, "Normal dispatch to Document");
    1.43 +    opener.wrappedJSObject.is(iframeListenerCalled, 1, "Normal dispatch to Document");
    1.44 +
    1.45 +    win.dispatchEvent(new Event("foo"));
    1.46 +    opener.wrappedJSObject.is(docListenerCalled, 1, "Normal dispatch to Window");
    1.47 +    opener.wrappedJSObject.is(winListenerCalled, 2, "Normal dispatch to Window");
    1.48 +    opener.wrappedJSObject.is(iframeListenerCalled, 2, "Normal dispatch to Window");
    1.49 +
    1.50 +    wu.dispatchEventToChromeOnly(doc, new Event("foo"));
    1.51 +    opener.wrappedJSObject.is(docListenerCalled, 1, "Chrome-only dispatch to Document");
    1.52 +    opener.wrappedJSObject.is(winListenerCalled, 2, "Chrome-only dispatch to Document");
    1.53 +    opener.wrappedJSObject.is(iframeListenerCalled, 3, "Chrome-only dispatch to Document");
    1.54 +
    1.55 +    wu.dispatchEventToChromeOnly(win, new Event("foo"));
    1.56 +    opener.wrappedJSObject.is(docListenerCalled, 1, "Chrome-only dispatch to Window");
    1.57 +    opener.wrappedJSObject.is(winListenerCalled, 2, "Chrome-only dispatch to Window");
    1.58 +    opener.wrappedJSObject.is(iframeListenerCalled, 4, "Chrome-only dispatch to Window");
    1.59 +
    1.60 +    window.close();
    1.61 +    opener.wrappedJSObject.finishedTests();
    1.62 +  }
    1.63 +
    1.64 +  SimpleTest.waitForFocus(runTests);
    1.65 +  ]]>
    1.66 +  </script>
    1.67 +  <iframe xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.68 +          id="b" type="content" src="about:blank"
    1.69 +          style="width: 300px; height: 550px; border: 1px solid black;"/>
    1.70 +</window>

mercurial