content/xul/document/test/test_bug445177.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/xul/document/test/test_bug445177.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,85 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     1.7 +<!--
     1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=445177
     1.9 +-->
    1.10 +<window title="Test for Bug 445177"
    1.11 +  id="test_bug445177_xul"
    1.12 +  xmlns:html="http://www.w3.org/1999/xhtml"
    1.13 +  xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.14 +  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.15 +
    1.16 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.17 +
    1.18 +<body id="body" xmlns="http://www.w3.org/1999/xhtml">
    1.19 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=445177">Mozilla Bug 445177</a>
    1.20 +
    1.21 +
    1.22 +<hbox id="b1" value="foo"/>
    1.23 +<hbox id="o1" observes="b1"/>
    1.24 +
    1.25 +<pre id="test">
    1.26 +  <script class="testbody" type="text/javascript">
    1.27 +<![CDATA[
    1.28 +  SimpleTest.waitForExplicitFinish();
    1.29 +  function do_test() {
    1.30 +    var b1 = document.getElementById("b1");
    1.31 +    var o1 = document.getElementById("o1");
    1.32 +
    1.33 +    is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (1)");
    1.34 +
    1.35 +    b1.setAttribute("value", "bar");
    1.36 +    is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (2)");
    1.37 +
    1.38 +    b1.removeAttribute("value");
    1.39 +    is(o1.hasAttribute("value"), b1.hasAttribute("value"), "Wrong value (3)");
    1.40 +
    1.41 +    o1.setAttribute("value", "foo");
    1.42 +    isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (4)");
    1.43 +
    1.44 +    b1.setAttribute("value", "foobar");
    1.45 +    is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (5)");
    1.46 +
    1.47 +    //After removing listener, changes to broadcaster shouldn't have any effect.
    1.48 +    o1.parentNode.removeChild(o1);
    1.49 +    b1.setAttribute("value", "foo");
    1.50 +    isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (6)");
    1.51 +
    1.52 +    b1.parentNode.appendChild(o1);
    1.53 +    is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (7)");
    1.54 +
    1.55 +    o1.parentNode.removeChild(o1);
    1.56 +    o1.removeAttribute("observes");
    1.57 +    o1.removeAttribute("value");
    1.58 +    b1.parentNode.appendChild(o1);
    1.59 +    isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (8)");
    1.60 +
    1.61 +    document.addBroadcastListenerFor(b1, o1, "value");
    1.62 +    is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (9)");
    1.63 +
    1.64 +    o1.parentNode.removeChild(o1);
    1.65 +    b1.setAttribute("value", "foobar");
    1.66 +    is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (10)");
    1.67 +
    1.68 +    b1.parentNode.appendChild(o1);
    1.69 +    is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (11)");
    1.70 +
    1.71 +    o1.setAttribute("observes", "b1");
    1.72 +    is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (12)");
    1.73 +
    1.74 +    // When broadcaster isn't in document, changes to its attributes aren't
    1.75 +    // reflected to listener.
    1.76 +    b1.parentNode.removeChild(b1);
    1.77 +    b1.setAttribute("value", "foo");
    1.78 +    isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (13)");
    1.79 +
    1.80 +    SimpleTest.finish();
    1.81 +  }
    1.82 +
    1.83 +  addLoadEvent(do_test);
    1.84 +]]>
    1.85 +  </script>
    1.86 +</pre>
    1.87 +</body>
    1.88 +</window>

mercurial