Bug 1472555 - Part 3 - Convert Toolkit tests to use the "richlistbox" element. r=bgrins
MozReview-Commit-ID: By1FhB70wOh
--- a/toolkit/content/tests/chrome/test_hiddenitems.xul
+++ b/toolkit/content/tests/chrome/test_hiddenitems.xul
@@ -19,27 +19,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<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" hidden="true"><label value="Item 7"/></richlistitem>
</richlistbox>
-
- <listbox id="listbox" seltype="multiple">
- <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" collapsed="true"/>
- <listitem id="listbox_item6" label="Item 6"/>
- <listitem id="listbox_item7" label="Item 7" hidden="true"/>
- </listbox>
-
+
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
/** Test for Bug 317422 **/
SimpleTest.waitForExplicitFinish();
function testListbox(id)
{
@@ -77,13 +67,12 @@ function testListbox(id)
sendKey("PAGE_DOWN");
is(listbox.selectedItem.id, id + "_item6", id + ": Page down should go to the last visible item");
sendKey("PAGE_UP");
is(listbox.selectedItem.id, id + "_item1", id + ": Page up should go to the first visible item");
}
window.onload = function runTests() {
testListbox("richlistbox");
- testListbox("listbox");
SimpleTest.finish();
};
]]></script>
</window>
--- a/toolkit/content/tests/chrome/test_hiddenpaging.xul
+++ b/toolkit/content/tests/chrome/test_hiddenpaging.xul
@@ -37,35 +37,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<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()
{
@@ -88,74 +70,14 @@ function testRichlistbox()
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);
-
- if (!window.matchMedia("(-moz-overlay-scrollbars)").matches) {
- // 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>
--- a/toolkit/content/tests/chrome/test_menulist.xul
+++ b/toolkit/content/tests/chrome/test_menulist.xul
@@ -13,32 +13,32 @@
<vbox id="scroller" style="overflow: auto" height="60">
<menulist id="menulist" onpopupshown="test_menulist_open(this, this.parentNode)"
onpopuphidden="$('menulist-in-listbox').open = true;">
<menupopup id="menulist-popup"/>
</menulist>
<button label="Two"/>
<button label="Three"/>
</vbox>
-<listbox id="scroller-in-listbox" style="overflow: auto" height="60">
- <listitem allowevents="true">
+<richlistbox id="scroller-in-listbox" style="overflow: auto" height="60">
+ <richlistitem allowevents="true">
<menulist id="menulist-in-listbox" onpopupshown="test_menulist_open(this, this.parentNode.parentNode)"
onpopuphidden="SimpleTest.executeSoon(checkScrollAndFinish)">
<menupopup id="menulist-in-listbox-popup">
<menuitem label="One" value="one"/>
<menuitem label="Two" value="two"/>
</menupopup>
</menulist>
- </listitem>
- <listitem label="Two"/>
- <listitem label="Three"/>
- <listitem label="Four"/>
- <listitem label="Five"/>
- <listitem label="Six"/>
-</listbox>
+ </richlistitem>
+ <richlistitem><label value="Two"/></richlistitem>
+ <richlistitem><label value="Three"/></richlistitem>
+ <richlistitem><label value="Four"/></richlistitem>
+ <richlistitem><label value="Five"/></richlistitem>
+ <richlistitem><label value="Six"/></richlistitem>
+</richlistbox>
<hbox>
<menulist id="menulist-size">
<menupopup>
<menuitem label="Menuitem Label" width="200"/>
</menupopup>
</menulist>
</hbox>
--- a/toolkit/content/tests/chrome/test_mousescroll.xul
+++ b/toolkit/content/tests/chrome/test_mousescroll.xul
@@ -26,28 +26,16 @@ https://bugzilla.mozilla.org/show_bug.cg
<richlistitem id="richlistbox_item3"><label value="Item 3"/></richlistitem>
<richlistitem id="richlistbox_item4"><label value="Item 4"/></richlistitem>
<richlistitem id="richlistbox_item5"><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>
</richlistbox>
- <listbox id="listbox" rows="2">
- <listitem id="listbox_item0" label="Item 0" hidden="true"/>
- <listitem id="listbox_item1" label="Item 1"/>
- <listitem id="listbox_item2" label="Item 2"/>
- <listitem id="listbox_item3" label="Item 3"/>
- <listitem id="listbox_item4" label="Item 4"/>
- <listitem id="listbox_item5" label="Item 5"/>
- <listitem id="listbox_item6" label="Item 6"/>
- <listitem id="listbox_item7" label="Item 7"/>
- <listitem id="listbox_item8" label="Item 8"/>
- </listbox>
-
<box orient="horizontal">
<arrowscrollbox id="hscrollbox" clicktoscroll="true" orient="horizontal"
smoothscroll="false" style="max-width:80px;" flex="1">
<hbox style="width:40px; height:20px; background:black;" hidden="true"/>
<hbox style="width:40px; height:20px; background:white;"/>
<hbox style="width:40px; height:20px; background:black;"/>
<hbox style="width:40px; height:20px; background:white;"/>
<hbox style="width:40px; height:20px; background:black;"/>
@@ -105,60 +93,16 @@ function sendWheelAndWait(aScrollTaget,
sendWheelAndPaint(aScrollTaget, aX, aY, aEvent, ()=>{
// sendWheelAndPaint may wait not enough for <scrollbox>.
// Let's check the position before using is() for avoiding random orange.
// So, this test may detect regressions with timeout.
continueTestsIfScrolledAsExpected(aChecker);
});
}
-function* testListbox(id)
-{
- var listbox = document.getElementById(id);
-
- function* helper(aStart, aDelta, aIntDelta, aDeltaMode)
- {
- listbox.scrollToIndex(aStart);
- var expectedPos = aStart;
- if (aIntDelta) {
- if (aDeltaMode == WheelEvent.DOM_DELTA_PAGE) {
- expectedPos += aIntDelta > 0 ? listbox.getNumberOfVisibleRows() :
- -listbox.getNumberOfVisibleRows();
- } else {
- expectedPos += aIntDelta;
- }
- }
- yield sendWheelAndWait(listbox, 10, 10,
- { deltaMode: aDeltaMode, deltaY: aDelta,
- lineOrPageDeltaY: aIntDelta },
- ()=>{ return listbox.getIndexOfFirstVisibleRow() == expectedPos; });
- is(listbox.getIndexOfFirstVisibleRow(), expectedPos,
- "testListbox(" + id + "): vertical, starting " + aStart +
- " delta " + aDelta + " lineOrPageDelta " + aIntDelta +
- " aDeltaMode " + aDeltaMode);
-
- // Check that horizontal scrolling has no effect
- listbox.scrollToIndex(aStart);
- yield sendWheelAndWait(listbox, 10, 10,
- { deltaMode: aDeltaMode, deltaX: aDelta,
- lineOrPageDeltaX: aIntDelta }, ()=>{ return true; });
- is(listbox.getIndexOfFirstVisibleRow(), aStart,
- "testListbox(" + id + "): horizontal, starting " + aStart +
- " delta " + aDelta + " lineOrPageDelta " + aIntDelta +
- " aDeltaMode " + aDeltaMode);
- }
- for (let i = 0; i < deltaModes.length; i++) {
- let delta = (deltaModes[i] == WheelEvent.DOM_DELTA_PIXEL) ? 5.0 : 0.3;
- yield* helper(5, -delta, 0, deltaModes[i]);
- yield* helper(5, -delta, -1, deltaModes[i]);
- yield* helper(5, delta, 1, deltaModes[i]);
- yield* helper(5, delta, 0, deltaModes[i]);
- }
-}
-
function* testRichListbox(id)
{
var listbox = document.getElementById(id);
function* helper(aStart, aDelta, aIntDelta, aDeltaMode) {
listbox.scrollToIndex(aStart);
let event = {
@@ -355,15 +299,14 @@ async function prepareRunningTests()
false]]});
runTests();
}
function* testBody()
{
yield* testRichListbox("richlistbox");
- yield* testListbox("listbox");
yield* testArrowScrollbox("hscrollbox");
yield* testArrowScrollbox("vscrollbox");
}
]]></script>
</window>
--- a/toolkit/content/tests/chrome/test_tabindex.xul
+++ b/toolkit/content/tests/chrome/test_tabindex.xul
@@ -34,19 +34,19 @@
<checkbox id="t3" style="-moz-user-focus: ignore;" label="Four" tabindex="1"/>
</hbox>
<hbox>
<textbox id="t10" idmod="t5" style="-moz-user-focus: ignore;" size="3"/>
<textbox id="no5" style="-moz-user-focus: ignore;" size="3" tabindex="-1"/>
<textbox id="t11" idmod="t6" style="-moz-user-focus: ignore;" size="3" tabindex="0"/>
<textbox id="t4" idmod="t2" style="-moz-user-focus: ignore;" size="3" tabindex="1"/>
</hbox>
-<listbox id="t12" idmod="t7">
- <listitem label="Item One"/>
-</listbox>
+<richlistbox id="t12" idmod="t7">
+ <richlistitem><label value="Item One"/></richlistitem>
+</richlistbox>
<hbox>
<!-- the tabindex attribute does not apply to non-controls, so it
should be treated as -1 for non-focusable dropmarkers, and 0
for focusable dropmarkers. Thus, the first four dropmarkers
are not in the tab order, and the last four dropmarkers should
be in the tab order just after the listbox above.
-->