test_bug391568.xhtml 2.2 KB

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