зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1472555 - Part 3 - Convert Toolkit tests to use the "richlistbox" element. r=bgrins
MozReview-Commit-ID: By1FhB70wOh --HG-- extra : rebase_source : 629275e04d7ffef82307f32dee219771e18617f4
This commit is contained in:
Родитель
4999d683f4
Коммит
84701651c4
|
@ -24,17 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=317422
|
|||
<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[
|
||||
|
||||
|
@ -82,7 +72,6 @@ function testListbox(id)
|
|||
|
||||
window.onload = function runTests() {
|
||||
testListbox("richlistbox");
|
||||
testListbox("listbox");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
]]></script>
|
||||
|
|
|
@ -42,25 +42,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=317422
|
|||
<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[
|
||||
|
||||
|
@ -93,68 +75,8 @@ function testRichlistbox()
|
|||
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>
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
<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">
|
||||
|
@ -27,13 +27,13 @@
|
|||
<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">
|
||||
|
|
|
@ -31,18 +31,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=378028
|
|||
<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">
|
||||
|
@ -110,50 +98,6 @@ function sendWheelAndWait(aScrollTaget, aX, aY, aEvent, 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);
|
||||
|
@ -360,7 +304,6 @@ async function prepareRunningTests()
|
|||
function* testBody()
|
||||
{
|
||||
yield* testRichListbox("richlistbox");
|
||||
yield* testListbox("listbox");
|
||||
yield* testArrowScrollbox("hscrollbox");
|
||||
yield* testArrowScrollbox("vscrollbox");
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@
|
|||
<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
|
||||
|
|
Загрузка…
Ссылка в новой задаче