content/xul/document/test/test_bug468176.xul

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:cb9ca97d7cf6
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
4 <!--
5 https://bugzilla.mozilla.org/show_bug.cgi?id=468176
6 -->
7 <window title="Test for Bug 468176"
8 id="test_bug468176_xul"
9 xmlns:html="http://www.w3.org/1999/xhtml"
10 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
11 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
12
13 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
14
15 <body id="body" xmlns="http://www.w3.org/1999/xhtml">
16 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=468176">Mozilla Bug 468176</a>
17
18 <xul:hbox id="b1" value="foo"/>
19
20 <xul:hbox id="o1">
21 <xul:observes id="inner" element="b1" attribute="*"/>
22 </xul:hbox>
23
24 <pre id="test">
25 <script class="testbody" type="text/javascript">
26 <![CDATA[
27 SimpleTest.waitForExplicitFinish();
28
29 var broadcastCount = 0;
30 function b_listener(evt) {
31 ++broadcastCount;
32 }
33
34 function do_test() {
35 var b1 = document.getElementById("b1");
36 var o1 = document.getElementById("o1");
37 var inner = document.getElementById("inner");
38 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (1)");
39
40 inner.addEventListener("broadcast", b_listener, true);
41 b1.setAttribute("value", "bar");
42 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (2)");
43 is(broadcastCount, 1, "Wrong value (3)");
44
45 b1.removeAttribute("value");
46 is(o1.hasAttribute("value"), b1.hasAttribute("value"), "Wrong value (4)");
47 is(broadcastCount, 2, "Wrong value (5)");
48
49 o1.setAttribute("value", "foo");
50 isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (6)");
51 is(broadcastCount, 2, "Wrong value (7)");
52
53 b1.setAttribute("value", "foobar");
54 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (8)");
55 is(broadcastCount, 3, "Wrong value (9)");
56
57 b1.removeAttribute("value");
58 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (10)");
59 is(broadcastCount, 4, "Wrong value (11)");
60
61 b1.removeAttribute("value");
62 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (12)");
63 is(broadcastCount, 4, "Wrong value (13)");
64
65 o1.setAttribute("value", "bar");
66 b1.setAttribute("value", "bar"); // This should still dispatch 'broadcast'
67 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (14)");
68 is(broadcastCount, 5, "Wrong value (15)");
69
70 //After removing listener, changes to broadcaster shouldn't have any effect.
71 o1.parentNode.removeChild(o1);
72 b1.setAttribute("value", "foo");
73 isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (16)");
74 is(broadcastCount, 5, "Wrong value (17)");
75
76 SimpleTest.finish();
77 }
78
79 addLoadEvent(do_test);
80 ]]>
81 </script>
82 </pre>
83 </body>
84 </window>

mercurial