test_bug609549.xhtml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <!--
  3. https://bugzilla.mozilla.org/show_bug.cgi?id=609549
  4. -->
  5. <head>
  6. <title>Test for Bug 609549</title>
  7. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  8. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  9. <bindings xmlns="http://www.mozilla.org/xbl">
  10. <binding id="testBinding">
  11. <!-- No linebreaks since this is html and whitespace is preserved. -->
  12. <content><div anonid="box-A">x</div><div anonid="box-B"><children includes="span"/></div><div anonid="box-C">x</div><children/></content>
  13. </binding>
  14. </bindings>
  15. </head>
  16. <body>
  17. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=609549">Mozilla Bug 609549</a>
  18. <div id="bound" style="-moz-binding: url(#testBinding);"><p id="p">lorem ipsum dolor sit amet</p><span id="sandwiched">sandwiched</span></div>
  19. <div id="content" style="display: none">
  20. </div>
  21. <pre id="test">
  22. <script type="application/javascript">
  23. <![CDATA[
  24. /** Test for Bug 609549 **/
  25. SimpleTest.waitForExplicitFinish();
  26. addLoadEvent(function() {
  27. var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"].
  28. getService(SpecialPowers.Ci.inIDOMUtils);
  29. ok("getChildrenForNode" in domUtils, "domUtils has no getChildrenForNode");
  30. var withoutAnons = SpecialPowers.unwrap(domUtils.getChildrenForNode($("bound"), false));
  31. is(withoutAnons.length, $("bound").childNodes.length,
  32. "withoutAnons should be the same length as childNodes");
  33. is(withoutAnons[0], $("p"), "didn't get paragraph - without anons");
  34. is(withoutAnons[1], $("sandwiched"),
  35. "didn't get sandwiched span - without anons");
  36. var withAnons = domUtils.getChildrenForNode($("bound"), true);
  37. is(withAnons.length, 4, "bad withAnons.length");
  38. is(withAnons[0].getAttribute("anonid"), "box-A",
  39. "didn't get anonymous box-A");
  40. is(withAnons[1].getAttribute("anonid"), "box-B",
  41. "didn't get anonymous box-B");
  42. is(withAnons[2].getAttribute("anonid"), "box-C",
  43. "didn't get anonymous box-C");
  44. is(withAnons[3].id, "p", "didn't get paragraph - with anons");
  45. var bKids = domUtils.getChildrenForNode(withAnons[1], true);
  46. is(bKids.length, 1, "bKids.length is bad");
  47. is(SpecialPowers.unwrap(bKids[0]), $("sandwiched"),
  48. "didn't get sandwiched span inserted into box-B");
  49. SimpleTest.finish();
  50. });
  51. ]]>
  52. </script>
  53. </pre>
  54. </body>
  55. </html>