|
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=445177 |
|
6 --> |
|
7 <window title="Test for Bug 445177" |
|
8 id="test_bug445177_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=445177">Mozilla Bug 445177</a> |
|
17 |
|
18 |
|
19 <hbox id="b1" value="foo"/> |
|
20 <hbox id="o1" observes="b1"/> |
|
21 |
|
22 <pre id="test"> |
|
23 <script class="testbody" type="text/javascript"> |
|
24 <![CDATA[ |
|
25 SimpleTest.waitForExplicitFinish(); |
|
26 function do_test() { |
|
27 var b1 = document.getElementById("b1"); |
|
28 var o1 = document.getElementById("o1"); |
|
29 |
|
30 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (1)"); |
|
31 |
|
32 b1.setAttribute("value", "bar"); |
|
33 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (2)"); |
|
34 |
|
35 b1.removeAttribute("value"); |
|
36 is(o1.hasAttribute("value"), b1.hasAttribute("value"), "Wrong value (3)"); |
|
37 |
|
38 o1.setAttribute("value", "foo"); |
|
39 isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (4)"); |
|
40 |
|
41 b1.setAttribute("value", "foobar"); |
|
42 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (5)"); |
|
43 |
|
44 //After removing listener, changes to broadcaster shouldn't have any effect. |
|
45 o1.parentNode.removeChild(o1); |
|
46 b1.setAttribute("value", "foo"); |
|
47 isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (6)"); |
|
48 |
|
49 b1.parentNode.appendChild(o1); |
|
50 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (7)"); |
|
51 |
|
52 o1.parentNode.removeChild(o1); |
|
53 o1.removeAttribute("observes"); |
|
54 o1.removeAttribute("value"); |
|
55 b1.parentNode.appendChild(o1); |
|
56 isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (8)"); |
|
57 |
|
58 document.addBroadcastListenerFor(b1, o1, "value"); |
|
59 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (9)"); |
|
60 |
|
61 o1.parentNode.removeChild(o1); |
|
62 b1.setAttribute("value", "foobar"); |
|
63 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (10)"); |
|
64 |
|
65 b1.parentNode.appendChild(o1); |
|
66 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (11)"); |
|
67 |
|
68 o1.setAttribute("observes", "b1"); |
|
69 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (12)"); |
|
70 |
|
71 // When broadcaster isn't in document, changes to its attributes aren't |
|
72 // reflected to listener. |
|
73 b1.parentNode.removeChild(b1); |
|
74 b1.setAttribute("value", "foo"); |
|
75 isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (13)"); |
|
76 |
|
77 SimpleTest.finish(); |
|
78 } |
|
79 |
|
80 addLoadEvent(do_test); |
|
81 ]]> |
|
82 </script> |
|
83 </pre> |
|
84 </body> |
|
85 </window> |