1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/test_deck.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 +<!-- 1.8 + XUL Widget Test for deck 1.9 + --> 1.10 +<window title="Deck Test" 1.11 + onload="setTimeout(test_deck, 0);" 1.12 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.13 + <script type="application/javascript" 1.14 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.15 + <script type="application/javascript" 1.16 + src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.17 + 1.18 +<deck id="deck1" style="padding-top: 5px; padding-bottom: 12px;"> 1.19 + <button id="d1b1" label="Button One"/> 1.20 + <button id="d1b2" label="Button Two is larger" height="80" style="margin: 1px;"/> 1.21 +</deck> 1.22 +<deck id="deck2" selectedIndex="1"> 1.23 + <button id="d2b1" label="Button One"/> 1.24 + <button id="d2b2" label="Button Two"/> 1.25 +</deck> 1.26 + 1.27 + <!-- test results are displayed in the html:body --> 1.28 + <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> 1.29 + 1.30 + <!-- test code goes here --> 1.31 + <script type="application/javascript"><![CDATA[ 1.32 + 1.33 +SimpleTest.waitForExplicitFinish(); 1.34 + 1.35 +function test_deck() 1.36 +{ 1.37 + var deck = $("deck1"); 1.38 + ok(deck.selectedIndex === '0', "deck one selectedIndex"); 1.39 + // this size is the button height, 80, plus the button padding of 1px on each side, 1.40 + // plus the deck's 5px top padding and the 12px bottom padding. 1.41 + var rect = deck.getBoundingClientRect(); 1.42 + is(Math.round(rect.bottom) - Math.round(rect.top), 99, "deck size of largest child"); 1.43 + synthesizeMouseExpectEvent(deck, 12, 12, { }, $("d1b1"), "click", "mouse on deck one"); 1.44 + 1.45 + // change the selected page of the deck and ensure that the mouse click goes 1.46 + // to the button on that page 1.47 + deck.selectedIndex = 1; 1.48 + ok(deck.selectedIndex === '1', "deck one selectedIndex after change"); 1.49 + synthesizeMouseExpectEvent(deck, 9, 9, { }, $("d1b2"), "click", "mouse on deck one after change"); 1.50 + 1.51 + deck = $("deck2"); 1.52 + ok(deck.selectedIndex === '1', "deck two selectedIndex"); 1.53 + synthesizeMouseExpectEvent(deck, 9, 9, { }, $("d2b2"), "click", "mouse on deck two"); 1.54 + 1.55 + SimpleTest.finish(); 1.56 +} 1.57 + 1.58 +]]> 1.59 +</script> 1.60 + 1.61 +</window>