/toolkit/content/tests/chrome/test_deck.xul

http://github.com/zpao/v8monkey · Unknown · 58 lines · 48 code · 10 blank · 0 comment · 0 complexity · d81cc0b72df7456d282f966d0a91590f MD5 · raw file

  1. <?xml version="1.0"?>
  2. <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
  3. <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
  4. <!--
  5. XUL Widget Test for deck
  6. -->
  7. <window title="Deck Test"
  8. onload="setTimeout(test_deck, 0);"
  9. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  10. <script type="application/javascript"
  11. src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  12. <script type="application/javascript"
  13. src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
  14. <deck id="deck1" style="padding-top: 5px; padding-bottom: 12px;">
  15. <button id="d1b1" label="Button One"/>
  16. <button id="d1b2" label="Button Two is larger" height="80" style="margin: 1px;"/>
  17. </deck>
  18. <deck id="deck2" selectedIndex="1">
  19. <button id="d2b1" label="Button One"/>
  20. <button id="d2b2" label="Button Two"/>
  21. </deck>
  22. <!-- test results are displayed in the html:body -->
  23. <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
  24. <!-- test code goes here -->
  25. <script type="application/javascript"><![CDATA[
  26. SimpleTest.waitForExplicitFinish();
  27. function test_deck()
  28. {
  29. var deck = $("deck1");
  30. ok(deck.selectedIndex === '0', "deck one selectedIndex");
  31. // this size is the button height, 80, plus the button padding of 1px on each side,
  32. // plus the deck's 5px top padding and the 12px bottom padding.
  33. var rect = deck.getBoundingClientRect();
  34. is(Math.round(rect.bottom) - Math.round(rect.top), 99, "deck size of largest child");
  35. synthesizeMouseExpectEvent(deck, 12, 12, { }, $("d1b1"), "click", "mouse on deck one");
  36. // change the selected page of the deck and ensure that the mouse click goes
  37. // to the button on that page
  38. deck.selectedIndex = 1;
  39. ok(deck.selectedIndex === '1', "deck one selectedIndex after change");
  40. synthesizeMouseExpectEvent(deck, 9, 9, { }, $("d1b2"), "click", "mouse on deck one after change");
  41. deck = $("deck2");
  42. ok(deck.selectedIndex === '1', "deck two selectedIndex");
  43. synthesizeMouseExpectEvent(deck, 9, 9, { }, $("d2b2"), "click", "mouse on deck two");
  44. SimpleTest.finish();
  45. }
  46. ]]>
  47. </script>
  48. </window>