dom/tests/mochitest/chrome/file_bug830858.xul

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:21ccb8d43394
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 type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
10 <script type="application/javascript" 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.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
28 .getInterface(Components.interfaces.nsIDOMWindowUtils);
29
30 var docListenerCalled = 0;
31 doc.addEventListener("foo", function() { ++docListenerCalled; }, true);
32 var winListenerCalled = 0;
33 win.addEventListener("foo", function() { ++winListenerCalled; }, true);
34 var iframeListenerCalled = 0;
35 b.addEventListener("foo", function() { ++iframeListenerCalled; }, true);
36
37 doc.dispatchEvent(new Event("foo"));
38 opener.wrappedJSObject.is(docListenerCalled, 1, "Normal dispatch to Document");
39 opener.wrappedJSObject.is(winListenerCalled, 1, "Normal dispatch to Document");
40 opener.wrappedJSObject.is(iframeListenerCalled, 1, "Normal dispatch to Document");
41
42 win.dispatchEvent(new Event("foo"));
43 opener.wrappedJSObject.is(docListenerCalled, 1, "Normal dispatch to Window");
44 opener.wrappedJSObject.is(winListenerCalled, 2, "Normal dispatch to Window");
45 opener.wrappedJSObject.is(iframeListenerCalled, 2, "Normal dispatch to Window");
46
47 wu.dispatchEventToChromeOnly(doc, new Event("foo"));
48 opener.wrappedJSObject.is(docListenerCalled, 1, "Chrome-only dispatch to Document");
49 opener.wrappedJSObject.is(winListenerCalled, 2, "Chrome-only dispatch to Document");
50 opener.wrappedJSObject.is(iframeListenerCalled, 3, "Chrome-only dispatch to Document");
51
52 wu.dispatchEventToChromeOnly(win, new Event("foo"));
53 opener.wrappedJSObject.is(docListenerCalled, 1, "Chrome-only dispatch to Window");
54 opener.wrappedJSObject.is(winListenerCalled, 2, "Chrome-only dispatch to Window");
55 opener.wrappedJSObject.is(iframeListenerCalled, 4, "Chrome-only dispatch to Window");
56
57 window.close();
58 opener.wrappedJSObject.finishedTests();
59 }
60
61 SimpleTest.waitForFocus(runTests);
62 ]]>
63 </script>
64 <iframe xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
65 id="b" type="content" src="about:blank"
66 style="width: 300px; height: 550px; border: 1px solid black;"/>
67 </window>

mercurial