summaryrefslogtreecommitdiff
path: root/dom/events/test/test_bug391568.xhtml
blob: 0a35072be45018c7100366502da446f60449af60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xbl="http://www.mozilla.org/xbl">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=391568
-->
<head>
  <title>Test for Bug 391568</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <script>
    var constructorFired = 0;
  </script>
  <xbl:bindings>
    <xbl:binding id="test">
      <xbl:content><span>
        (anonumous content)
        <span><xbl:children/></span>
        (anonumous content)</span>
      </xbl:content>
  
      <xbl:implementation>
        <xbl:constructor>
          var win = XPCNativeWrapper.unwrap(window);
          ++win.constructorFired;
          document.getAnonymousNodes(this)[0].addEventListener(
            "DOMCharacterDataModified", 
            function(evt) {
              ++win.characterdatamodified;
            },
            true);
        </xbl:constructor>
      </xbl:implementation>
    </xbl:binding>
  </xbl:bindings>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=391568">Mozilla Bug 391568</a>
<p id="display"></p>
<div id="content">
  <span style="-moz-binding: url(#test);"><span id="real1">(real content)</span></span>
  <span style="-moz-binding: url(#test);"><span id="real2">(real content)</span></span>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[

/** Test for Bug 391568 **/

var characterdatamodified = 0;

document.getElementById('real1').addEventListener(
  "DOMCharacterDataModified", 
  function(evt) {},
  true);

function testListeners() {
  if (constructorFired < 2) {
    setTimeout(testListeners, 0);
    return;
  }
  document.getElementById('real1').firstChild.data = "(real content 2)";
  ok(characterdatamodified == 1,
     "There is a DOMCharacterDataModified listener in anonymous content which didn't get called (1)!");
  document.getElementById('real2').firstChild.data = "(real content 2)";
  ok(characterdatamodified == 2,
     "There is a DOMCharacterDataModified listener in anonymous content which didn't get called (2)!");
  SimpleTest.finish();
}

SimpleTest.waitForExplicitFinish();
addLoadEvent(testListeners);
]]>
</script>
</pre>
</body>
</html>