xbl-children-3.xhtml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <html xmlns="http://www.w3.org/1999/xhtml"
  2. xmlns:html="http://www.w3.org/1999/xhtml"
  3. xmlns:xbl="http://www.mozilla.org/xbl"
  4. xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  5. class="reftest-wait">
  6. <head>
  7. <xbl:bindings xmlns="http://www.mozilla.org/xbl">
  8. <binding id="base">
  9. <content>
  10. <html:div style="border: solid red">
  11. <children />
  12. </html:div>
  13. </content>
  14. <implementation>
  15. <property name="foo" onget="return 42" />
  16. </implementation>
  17. </binding>
  18. <binding id="derived" extends="#base">
  19. <content>
  20. <html:div style="border: dashed green">
  21. <children includes="span" />
  22. </html:div>
  23. </content>
  24. </binding>
  25. <binding id="nochildren">
  26. <content>
  27. PASS
  28. </content>
  29. </binding>
  30. </xbl:bindings>
  31. </head>
  32. <body>
  33. <!-- Control case: our (only) child matches the children element. -->
  34. <div id="first" style="-moz-binding: url(#derived)"><span style="color: green">should be green in a green border</span></div>
  35. <!-- Make sure we ignore xul:template and xul:observes elements! -->
  36. <div style="-moz-binding: url(#derived)"><xul:template /><xul:observes /><span style="color: green">should be green in a green border</span></div>
  37. <!-- Case where our (only) child doesn't match any children elements. -->
  38. <div id="second" style="-moz-binding: url(#derived)"><div>Should be uncolored with no border</div></div>
  39. <!-- But make sure the binding was still applied! -->
  40. <div id="output" />
  41. <script>
  42. var $ = document.getElementById.bind(document);
  43. // Note: Done in an onload handler because binding instantiation is
  44. // asynchronous.
  45. onload = function() {
  46. $('output').textContent =
  47. ($('first').foo === 42) + ", " + ($('first').foo === $('second').foo);
  48. document.documentElement.removeAttribute('class');
  49. }
  50. </script>
  51. <!-- Case where one of our children matches but the other one doesn't. -->
  52. <div id="third" style="-moz-binding: url(#derived)"><span>In a span</span><div>Should be uncolored with no border</div></div>
  53. <!-- Control case with no <children> in the binding. -->
  54. <div style="-moz-binding: url(#nochildren)" />
  55. <!-- Case where we have a child but no <children> in the binding. -->
  56. <div style="-moz-binding: url(#nochildren)"><span style="color: green">PASS</span></div>
  57. <!-- But we must ignore xul:template and xul:observes elements! -->
  58. <div style="-moz-binding: url(#nochildren)"><xul:template /><xul:observes /></div>
  59. </body>
  60. </html>