gecko/toolkit/content/tests/chrome/test_hiddenpaging.xul

160 lines
8.0 KiB
Plaintext
Raw Normal View History

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
Bug 508710 - moving toolkit/content/tests/widgets/*.xul from mochitest to mochitest-chrome. r=enn, a=test-only --HG-- rename : toolkit/content/tests/widgets/frame_popupremoving_frame.xul => toolkit/content/tests/chrome/frame_popupremoving_frame.xul rename : toolkit/content/tests/widgets/popup_childframe_node.xul => toolkit/content/tests/chrome/popup_childframe_node.xul rename : toolkit/content/tests/widgets/popup_trigger.js => toolkit/content/tests/chrome/popup_trigger.js rename : toolkit/content/tests/widgets/test_bug360220.xul => toolkit/content/tests/chrome/test_bug360220.xul rename : toolkit/content/tests/widgets/test_bug365773.xul => toolkit/content/tests/chrome/test_bug365773.xul rename : toolkit/content/tests/widgets/test_bug382990.xul => toolkit/content/tests/chrome/test_bug382990.xul rename : toolkit/content/tests/widgets/test_bug457632.xul => toolkit/content/tests/chrome/test_bug457632.xul rename : toolkit/content/tests/widgets/test_bug460942.xul => toolkit/content/tests/chrome/test_bug460942.xul rename : toolkit/content/tests/widgets/test_bug509732.xul => toolkit/content/tests/chrome/test_bug509732.xul rename : toolkit/content/tests/widgets/test_bug554279.xul => toolkit/content/tests/chrome/test_bug554279.xul rename : toolkit/content/tests/widgets/test_bug557987.xul => toolkit/content/tests/chrome/test_bug557987.xul rename : toolkit/content/tests/widgets/test_bug562554.xul => toolkit/content/tests/chrome/test_bug562554.xul rename : toolkit/content/tests/widgets/test_button.xul => toolkit/content/tests/chrome/test_button.xul rename : toolkit/content/tests/widgets/test_closemenu_attribute.xul => toolkit/content/tests/chrome/test_closemenu_attribute.xul rename : toolkit/content/tests/widgets/test_colorpicker_popup.xul => toolkit/content/tests/chrome/test_colorpicker_popup.xul rename : toolkit/content/tests/widgets/test_contextmenu_list.xul => toolkit/content/tests/chrome/test_contextmenu_list.xul rename : toolkit/content/tests/widgets/test_focus_anons.xul => toolkit/content/tests/chrome/test_focus_anons.xul rename : toolkit/content/tests/widgets/test_hiddenitems.xul => toolkit/content/tests/chrome/test_hiddenitems.xul rename : toolkit/content/tests/widgets/test_hiddenpaging.xul => toolkit/content/tests/chrome/test_hiddenpaging.xul rename : toolkit/content/tests/widgets/test_menu.xul => toolkit/content/tests/chrome/test_menu.xul rename : toolkit/content/tests/widgets/test_menu_hide.xul => toolkit/content/tests/chrome/test_menu_hide.xul rename : toolkit/content/tests/widgets/test_menuitem_blink.xul => toolkit/content/tests/chrome/test_menuitem_blink.xul rename : toolkit/content/tests/widgets/test_menulist.xul => toolkit/content/tests/chrome/test_menulist.xul rename : toolkit/content/tests/widgets/test_menulist_keynav.xul => toolkit/content/tests/chrome/test_menulist_keynav.xul rename : toolkit/content/tests/widgets/test_notificationbox.xul => toolkit/content/tests/chrome/test_notificationbox.xul rename : toolkit/content/tests/widgets/test_panelfrommenu.xul => toolkit/content/tests/chrome/test_panelfrommenu.xul rename : toolkit/content/tests/widgets/test_popup_attribute.xul => toolkit/content/tests/chrome/test_popup_attribute.xul rename : toolkit/content/tests/widgets/test_popup_button.xul => toolkit/content/tests/chrome/test_popup_button.xul rename : toolkit/content/tests/widgets/test_popup_coords.xul => toolkit/content/tests/chrome/test_popup_coords.xul rename : toolkit/content/tests/widgets/test_popup_keys.xul => toolkit/content/tests/chrome/test_popup_keys.xul rename : toolkit/content/tests/widgets/test_popup_preventdefault.xul => toolkit/content/tests/chrome/test_popup_preventdefault.xul rename : toolkit/content/tests/widgets/test_popup_recreate.xul => toolkit/content/tests/chrome/test_popup_recreate.xul rename : toolkit/content/tests/widgets/test_popup_scaled.xul => toolkit/content/tests/chrome/test_popup_scaled.xul rename : toolkit/content/tests/widgets/test_popup_tree.xul => toolkit/content/tests/chrome/test_popup_tree.xul rename : toolkit/content/tests/widgets/test_popuphidden.xul => toolkit/content/tests/chrome/test_popuphidden.xul rename : toolkit/content/tests/widgets/test_popupincontent.xul => toolkit/content/tests/chrome/test_popupincontent.xul rename : toolkit/content/tests/widgets/test_popupremoving.xul => toolkit/content/tests/chrome/test_popupremoving.xul rename : toolkit/content/tests/widgets/test_popupremoving_frame.xul => toolkit/content/tests/chrome/test_popupremoving_frame.xul rename : toolkit/content/tests/widgets/test_position.xul => toolkit/content/tests/chrome/test_position.xul rename : toolkit/content/tests/widgets/test_progressmeter.xul => toolkit/content/tests/chrome/test_progressmeter.xul rename : toolkit/content/tests/widgets/test_props.xul => toolkit/content/tests/chrome/test_props.xul rename : toolkit/content/tests/widgets/test_radio.xul => toolkit/content/tests/chrome/test_radio.xul rename : toolkit/content/tests/widgets/test_richlist_direction.xul => toolkit/content/tests/chrome/test_richlist_direction.xul rename : toolkit/content/tests/widgets/test_scale.xul => toolkit/content/tests/chrome/test_scale.xul rename : toolkit/content/tests/widgets/test_scrollbar.xul => toolkit/content/tests/chrome/test_scrollbar.xul rename : toolkit/content/tests/widgets/test_sorttemplate.xul => toolkit/content/tests/chrome/test_sorttemplate.xul rename : toolkit/content/tests/widgets/test_statusbar.xul => toolkit/content/tests/chrome/test_statusbar.xul rename : toolkit/content/tests/widgets/test_tabbox.xul => toolkit/content/tests/chrome/test_tabbox.xul rename : toolkit/content/tests/widgets/test_tabindex.xul => toolkit/content/tests/chrome/test_tabindex.xul rename : toolkit/content/tests/widgets/test_textbox_emptytext.xul => toolkit/content/tests/chrome/test_textbox_emptytext.xul rename : toolkit/content/tests/widgets/test_textbox_number.xul => toolkit/content/tests/chrome/test_textbox_number.xul rename : toolkit/content/tests/widgets/test_textbox_search.xul => toolkit/content/tests/chrome/test_textbox_search.xul rename : toolkit/content/tests/widgets/test_timepicker.xul => toolkit/content/tests/chrome/test_timepicker.xul rename : toolkit/content/tests/widgets/test_toolbar.xul => toolkit/content/tests/chrome/test_toolbar.xul rename : toolkit/content/tests/widgets/test_tooltip.xul => toolkit/content/tests/chrome/test_tooltip.xul rename : toolkit/content/tests/widgets/test_tooltip_noautohide.xul => toolkit/content/tests/chrome/test_tooltip_noautohide.xul rename : toolkit/content/tests/widgets/test_tree.xul => toolkit/content/tests/chrome/test_tree.xul rename : toolkit/content/tests/widgets/test_tree_single.xul => toolkit/content/tests/chrome/test_tree_single.xul rename : toolkit/content/tests/widgets/test_tree_view.xul => toolkit/content/tests/chrome/test_tree_view.xul rename : toolkit/content/tests/widgets/window_popup_attribute.xul => toolkit/content/tests/chrome/window_popup_attribute.xul rename : toolkit/content/tests/widgets/window_popup_button.xul => toolkit/content/tests/chrome/window_popup_button.xul rename : toolkit/content/tests/widgets/xul_selectcontrol.js => toolkit/content/tests/chrome/xul_selectcontrol.js
2011-06-24 09:39:13 -07:00
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=317422
-->
<window title="Mozilla Bug 317422"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
Bug 508710 - moving toolkit/content/tests/widgets/*.xul from mochitest to mochitest-chrome. r=enn, a=test-only --HG-- rename : toolkit/content/tests/widgets/frame_popupremoving_frame.xul => toolkit/content/tests/chrome/frame_popupremoving_frame.xul rename : toolkit/content/tests/widgets/popup_childframe_node.xul => toolkit/content/tests/chrome/popup_childframe_node.xul rename : toolkit/content/tests/widgets/popup_trigger.js => toolkit/content/tests/chrome/popup_trigger.js rename : toolkit/content/tests/widgets/test_bug360220.xul => toolkit/content/tests/chrome/test_bug360220.xul rename : toolkit/content/tests/widgets/test_bug365773.xul => toolkit/content/tests/chrome/test_bug365773.xul rename : toolkit/content/tests/widgets/test_bug382990.xul => toolkit/content/tests/chrome/test_bug382990.xul rename : toolkit/content/tests/widgets/test_bug457632.xul => toolkit/content/tests/chrome/test_bug457632.xul rename : toolkit/content/tests/widgets/test_bug460942.xul => toolkit/content/tests/chrome/test_bug460942.xul rename : toolkit/content/tests/widgets/test_bug509732.xul => toolkit/content/tests/chrome/test_bug509732.xul rename : toolkit/content/tests/widgets/test_bug554279.xul => toolkit/content/tests/chrome/test_bug554279.xul rename : toolkit/content/tests/widgets/test_bug557987.xul => toolkit/content/tests/chrome/test_bug557987.xul rename : toolkit/content/tests/widgets/test_bug562554.xul => toolkit/content/tests/chrome/test_bug562554.xul rename : toolkit/content/tests/widgets/test_button.xul => toolkit/content/tests/chrome/test_button.xul rename : toolkit/content/tests/widgets/test_closemenu_attribute.xul => toolkit/content/tests/chrome/test_closemenu_attribute.xul rename : toolkit/content/tests/widgets/test_colorpicker_popup.xul => toolkit/content/tests/chrome/test_colorpicker_popup.xul rename : toolkit/content/tests/widgets/test_contextmenu_list.xul => toolkit/content/tests/chrome/test_contextmenu_list.xul rename : toolkit/content/tests/widgets/test_focus_anons.xul => toolkit/content/tests/chrome/test_focus_anons.xul rename : toolkit/content/tests/widgets/test_hiddenitems.xul => toolkit/content/tests/chrome/test_hiddenitems.xul rename : toolkit/content/tests/widgets/test_hiddenpaging.xul => toolkit/content/tests/chrome/test_hiddenpaging.xul rename : toolkit/content/tests/widgets/test_menu.xul => toolkit/content/tests/chrome/test_menu.xul rename : toolkit/content/tests/widgets/test_menu_hide.xul => toolkit/content/tests/chrome/test_menu_hide.xul rename : toolkit/content/tests/widgets/test_menuitem_blink.xul => toolkit/content/tests/chrome/test_menuitem_blink.xul rename : toolkit/content/tests/widgets/test_menulist.xul => toolkit/content/tests/chrome/test_menulist.xul rename : toolkit/content/tests/widgets/test_menulist_keynav.xul => toolkit/content/tests/chrome/test_menulist_keynav.xul rename : toolkit/content/tests/widgets/test_notificationbox.xul => toolkit/content/tests/chrome/test_notificationbox.xul rename : toolkit/content/tests/widgets/test_panelfrommenu.xul => toolkit/content/tests/chrome/test_panelfrommenu.xul rename : toolkit/content/tests/widgets/test_popup_attribute.xul => toolkit/content/tests/chrome/test_popup_attribute.xul rename : toolkit/content/tests/widgets/test_popup_button.xul => toolkit/content/tests/chrome/test_popup_button.xul rename : toolkit/content/tests/widgets/test_popup_coords.xul => toolkit/content/tests/chrome/test_popup_coords.xul rename : toolkit/content/tests/widgets/test_popup_keys.xul => toolkit/content/tests/chrome/test_popup_keys.xul rename : toolkit/content/tests/widgets/test_popup_preventdefault.xul => toolkit/content/tests/chrome/test_popup_preventdefault.xul rename : toolkit/content/tests/widgets/test_popup_recreate.xul => toolkit/content/tests/chrome/test_popup_recreate.xul rename : toolkit/content/tests/widgets/test_popup_scaled.xul => toolkit/content/tests/chrome/test_popup_scaled.xul rename : toolkit/content/tests/widgets/test_popup_tree.xul => toolkit/content/tests/chrome/test_popup_tree.xul rename : toolkit/content/tests/widgets/test_popuphidden.xul => toolkit/content/tests/chrome/test_popuphidden.xul rename : toolkit/content/tests/widgets/test_popupincontent.xul => toolkit/content/tests/chrome/test_popupincontent.xul rename : toolkit/content/tests/widgets/test_popupremoving.xul => toolkit/content/tests/chrome/test_popupremoving.xul rename : toolkit/content/tests/widgets/test_popupremoving_frame.xul => toolkit/content/tests/chrome/test_popupremoving_frame.xul rename : toolkit/content/tests/widgets/test_position.xul => toolkit/content/tests/chrome/test_position.xul rename : toolkit/content/tests/widgets/test_progressmeter.xul => toolkit/content/tests/chrome/test_progressmeter.xul rename : toolkit/content/tests/widgets/test_props.xul => toolkit/content/tests/chrome/test_props.xul rename : toolkit/content/tests/widgets/test_radio.xul => toolkit/content/tests/chrome/test_radio.xul rename : toolkit/content/tests/widgets/test_richlist_direction.xul => toolkit/content/tests/chrome/test_richlist_direction.xul rename : toolkit/content/tests/widgets/test_scale.xul => toolkit/content/tests/chrome/test_scale.xul rename : toolkit/content/tests/widgets/test_scrollbar.xul => toolkit/content/tests/chrome/test_scrollbar.xul rename : toolkit/content/tests/widgets/test_sorttemplate.xul => toolkit/content/tests/chrome/test_sorttemplate.xul rename : toolkit/content/tests/widgets/test_statusbar.xul => toolkit/content/tests/chrome/test_statusbar.xul rename : toolkit/content/tests/widgets/test_tabbox.xul => toolkit/content/tests/chrome/test_tabbox.xul rename : toolkit/content/tests/widgets/test_tabindex.xul => toolkit/content/tests/chrome/test_tabindex.xul rename : toolkit/content/tests/widgets/test_textbox_emptytext.xul => toolkit/content/tests/chrome/test_textbox_emptytext.xul rename : toolkit/content/tests/widgets/test_textbox_number.xul => toolkit/content/tests/chrome/test_textbox_number.xul rename : toolkit/content/tests/widgets/test_textbox_search.xul => toolkit/content/tests/chrome/test_textbox_search.xul rename : toolkit/content/tests/widgets/test_timepicker.xul => toolkit/content/tests/chrome/test_timepicker.xul rename : toolkit/content/tests/widgets/test_toolbar.xul => toolkit/content/tests/chrome/test_toolbar.xul rename : toolkit/content/tests/widgets/test_tooltip.xul => toolkit/content/tests/chrome/test_tooltip.xul rename : toolkit/content/tests/widgets/test_tooltip_noautohide.xul => toolkit/content/tests/chrome/test_tooltip_noautohide.xul rename : toolkit/content/tests/widgets/test_tree.xul => toolkit/content/tests/chrome/test_tree.xul rename : toolkit/content/tests/widgets/test_tree_single.xul => toolkit/content/tests/chrome/test_tree_single.xul rename : toolkit/content/tests/widgets/test_tree_view.xul => toolkit/content/tests/chrome/test_tree_view.xul rename : toolkit/content/tests/widgets/window_popup_attribute.xul => toolkit/content/tests/chrome/window_popup_attribute.xul rename : toolkit/content/tests/widgets/window_popup_button.xul => toolkit/content/tests/chrome/window_popup_button.xul rename : toolkit/content/tests/widgets/xul_selectcontrol.js => toolkit/content/tests/chrome/xul_selectcontrol.js
2011-06-24 09:39:13 -07:00
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<style xmlns="http://www.w3.org/1999/xhtml">
/* This makes the richlistbox about 4.5 rows high */
richlistitem {
height: 30px;
}
richlistbox {
height: 135px;
}
</style>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=317422"
target="_blank">Mozilla Bug 317422</a>
</body>
<richlistbox id="richlistbox" seltype="multiple">
<richlistitem id="richlistbox_item1"><label value="Item 1"/></richlistitem>
<richlistitem id="richlistbox_item2"><label value="Item 2"/></richlistitem>
<richlistitem id="richlistbox_item3" hidden="true"><label value="Item 3"/></richlistitem>
<richlistitem id="richlistbox_item4"><label value="Item 4"/></richlistitem>
<richlistitem id="richlistbox_item5" collapsed="true"><label value="Item 5"/></richlistitem>
<richlistitem id="richlistbox_item6"><label value="Item 6"/></richlistitem>
<richlistitem id="richlistbox_item7"><label value="Item 7"/></richlistitem>
<richlistitem id="richlistbox_item8"><label value="Item 8"/></richlistitem>
<richlistitem id="richlistbox_item9"><label value="Item 9"/></richlistitem>
<richlistitem id="richlistbox_item10"><label value="Item 10"/></richlistitem>
<richlistitem id="richlistbox_item11"><label value="Item 11"/></richlistitem>
<richlistitem id="richlistbox_item12"><label value="Item 12"/></richlistitem>
<richlistitem id="richlistbox_item13"><label value="Item 13"/></richlistitem>
<richlistitem id="richlistbox_item14"><label value="Item 14"/></richlistitem>
<richlistitem id="richlistbox_item15" hidden="true"><label value="Item 15"/></richlistitem>
</richlistbox>
<listbox id="listbox" seltype="multiple" rows="5">
<listitem id="listbox_item1" label="Item 1"/>
<listitem id="listbox_item2" label="Item 2"/>
<listitem id="listbox_item3" label="Item 3" hidden="true"/>
<listitem id="listbox_item4" label="Item 4"/>
<listitem id="listbox_item5" label="Item 5" hidden="true"/>
<listitem id="listbox_item6" label="Item 6"/>
<listitem id="listbox_item7" label="Item 7"/>
<listitem id="listbox_item8" label="Item 8"/>
<listitem id="listbox_item9" label="Item 9"/>
<listitem id="listbox_item10" label="Item 10"/>
<listitem id="listbox_item11" label="Item 11"/>
<listitem id="listbox_item12" label="Item 12"/>
<listitem id="listbox_item13" label="Item 13"/>
<listitem id="listbox_item14" label="Item 14"/>
<listitem id="listbox_item15" label="Item 15" hidden="true"/>
</listbox>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
/** Test for Bug 317422 **/
SimpleTest.waitForExplicitFinish();
function testRichlistbox()
{
var id = "richlistbox";
var listbox = document.getElementById(id);
listbox.focus();
listbox.selectedIndex = 0;
sendKey("PAGE_DOWN");
is(listbox.selectedItem.id, id + "_item7", id + ": Page down should go to the item one visible page away");
is(listbox.getIndexOfFirstVisibleRow(), 6, id + ": Page down should have scrolled down a visible page");
sendKey("PAGE_DOWN");
is(listbox.selectedItem.id, id + "_item11", id + ": Second page down should go to the item two visible pages away");
is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Second page down should not scroll beyond the end");
sendKey("PAGE_DOWN");
is(listbox.selectedItem.id, id + "_item14", id + ": Third page down should go to the last visible item");
is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Third page down should not have scrolled at all");
sendKey("PAGE_UP");
is(listbox.selectedItem.id, id + "_item10", id + ": Page up should go to the item one visible page away");
is(listbox.getIndexOfFirstVisibleRow(), 5, id + ": Page up should scroll up a visible page");
sendKey("PAGE_UP");
is(listbox.selectedItem.id, id + "_item6", id + ": Second page up should go to the item two visible pages away");
is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Second page up should not scroll beyond the start");
sendKey("PAGE_UP");
is(listbox.selectedItem.id, id + "_item1", id + ": Third page up should return to the first visible item");
is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Third page up should not have scrolled at all");
}
function testListbox()
{
var id = "listbox";
var listbox = document.getElementById(id);
// Check that a scrollbar is visible by comparing the width of the listitem
// with the width of the listbox. This is a simple way to do this without
// checking the anonymous content.
ok(listbox.firstChild.getBoundingClientRect().width < listbox.getBoundingClientRect().width - 10,
id + ": Scrollbar visible");
var rowHeight = listbox.firstChild.getBoundingClientRect().height;
listbox.focus();
listbox.selectedIndex = 0;
sendKey("PAGE_DOWN");
is(listbox.selectedItem.id, id + "_item8", id + ": Page down should go to the item one visible page away");
is(listbox.getIndexOfFirstVisibleRow(), 7, id + ": Page down should have scrolled down a visible page");
sendKey("PAGE_DOWN");
is(listbox.selectedItem.id, id + "_item13", id + ": Second page down should go to the item two visible pages away");
is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Second page down should not scroll beyond the end");
sendKey("PAGE_DOWN");
is(listbox.selectedItem.id, id + "_item14", id + ": Third page down should go to the last visible item");
is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Third page down should not have scrolled at all");
sendKey("PAGE_UP");
is(listbox.selectedItem.id, id + "_item9", id + ": Page up should go to the item one visible page away");
// the listScrollbox seems to go haywire when scrolling up with hidden listitems
todo_is(listbox.getIndexOfFirstVisibleRow(), 3, id + ": Page up should scroll up a visible page");
sendKey("PAGE_UP");
is(listbox.selectedItem.id, id + "_item2", id + ": Second page up should go to the item two visible pages away");
is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Second page up should not scroll beyond the start");
sendKey("PAGE_UP");
is(listbox.selectedItem.id, id + "_item1", id + ": Third page up should return to the first visible item");
is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Third page up should not have scrolled at all");
var scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight;
is(scrollHeight, rowHeight * 15, id + ": scrollHeight when rows set");
listbox.minHeight = 50;
scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight;
is(scrollHeight, rowHeight * 15, id + ": scrollHeight when rows and minimium height set");
listbox.removeAttribute("rows");
var availHeight = document.getAnonymousNodes(listbox)[1].lastChild.getBoundingClientRect().height;
// The listbox layout adds this extra height in GetPrefSize. Not sure what it's for though.
var e = (rowHeight * 15 - availHeight) % rowHeight;
var extraHeight = (e == 0) ? 0 : rowHeight - e;
scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight;
is(scrollHeight, rowHeight * 15 + extraHeight, id + ": scrollHeight when minimium height set");
listbox.removeAttribute("minheight");
scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight;
is(scrollHeight, rowHeight * 15 + extraHeight, id + ": scrollHeight");
}
window.onload = function runTests() {
testRichlistbox();
testListbox();
SimpleTest.finish();
};
]]></script>
</window>