gecko/layout/html/tests/formctls/base/select1_js.html

259 lines
9.0 KiB
HTML
Raw Normal View History

<HTML>
<HEAD>
<TITLE>Select Tests: JavaScript</TITLE>
<SCRIPT>
function typeTest(sel) {
if(sel.multiple && sel.type != "select-multi") {
alert("sel.type is '" + sel.type + "' instead of select-multi!");
} else if(sel.type != "select-one") {
alert("sel.type is '" + sel.type + "' instead of select-one!");
}
}
function selIndTest(sel) {
alert(sel.selectedIndex);
}
function selIndTestW(sel) {
sel.selectedIndex = 2;
}
function valueTest(sel) {
alert(sel.value);
}
function valueTestW(sel) {
sel.value = 4;
}
function lengthTest(sel) {
alert(sel.length);
}
function lengthTestW(sel) {
if(sel.length == 20) {
sel.length = 5;
} else {
sel.length = 20;
}
}
function formTest(sel) {
if(sel.form == null || sel.form.elements == null) {
alert("Select's form doesn't appear to be a form!");
}
}
// options is tested adequately in other tests
function disabledTest(sel) {
alert(sel.disabled);
}
function disabledTestW(sel) {
sel.disabled = !sel.disabled;
}
function multipleTest(sel) {
alert(sel.multiple);
}
function multipleTestW(sel) {
sel.multiple = !sel.multiple;
}
function nameTest(sel) {
alert(sel.name);
}
function nameTestW(sel) {
sel.name = sel.name + "x";
}
function sizeTest(sel) {
alert(sel.size);
}
function sizeTestW(sel) {
if(sel.size == 10) {
sel.size = -1;
} else if(sel.size == -1) {
sel.size = 0;
} else if(sel.size == 0) {
sel.size = 1;
} else {
sel.size = 10;
}
}
function hideTest(sel) {
sel.style.display = 'none';
}
function unhideTest(sel) {
sel.style.display = 'block';
}
</SCRIPT>
<BODY>
<H2>Select Tests: JavaScript</H2>
<TABLE BORDER=1>
<TR>
<TH>display: none init</TH>
<TD>
<B>Steps:</B> Click the buttons to view and set things. Start by viewing everything.<BR>
<B>Verify:</B> That everything behaves the same before and after clicking Unhide.
</TD>
</TR>
<TR>
<TH>JavaScript</TH>
<TD>
<B>Steps:</B> Click Unhide to view the select. Click the various buttons.<BR>
<B>Verify:</B> That they do what you'd expect.
</TD>
</TR>
<TR>
<TH>display: none JavaScript</TH>
<TD>
<B>Steps:</B> Click hide and try various JavaScript.<BR>
<B>Verify:</B> That they do what you'd expect, and unhide shows them properly.
</TD>
</TR>
</TABLE>
<BR>
<FORM NAME=mainform>
<INPUT TYPE=reset><BR><BR>
<TABLE BORDER=1>
<TR>
<TD><B>Dropdown</B><BR>
<INPUT TYPE=button onClick="typeTest(document.mainform.blah)" VALUE="type">
<INPUT TYPE=button onClick="formTest(document.mainform.blah)" VALUE="form"><BR>
<INPUT TYPE=button onClick="selIndTest(document.mainform.blah)" VALUE="selectedIndex">
<INPUT TYPE=button onClick="selIndTestW(document.mainform.blah)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="valueTest(document.mainform.blah)" VALUE="value">
<INPUT TYPE=button onClick="valueTestW(document.mainform.blah)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="lengthTest(document.mainform.blah)" VALUE="length">
<INPUT TYPE=button onClick="lengthTestW(document.mainform.blah)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="disabledTest(document.mainform.blah)" VALUE="disabled">
<INPUT TYPE=button onClick="disabledTestW(document.mainform.blah)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="multipleTest(document.mainform.blah)" VALUE="multiple">
<INPUT TYPE=button onClick="multipleTestW(document.mainform.blah)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="nameTest(document.mainform.blah)" VALUE="name">
<INPUT TYPE=button onClick="nameTestW(document.mainform.blah)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="sizeTest(document.mainform.blah)" VALUE="size">
<INPUT TYPE=button onClick="sizeTestW(document.mainform.blah)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="hideTest(document.mainform.blah)" VALUE="Hide">
<INPUT TYPE=button onClick="unhideTest(document.mainform.blah)" VALUE="Unhide"><BR>
<BR>
<SELECT NAME=blah STYLE="display: none">
<OPTION>1
<OPTION>2
<OPTION>3
<OPTION>4
<OPTION>5
<OPTION>6
<OPTION SELECTED>7
<OPTION>8
<OPTION SELECTED>9
<OPTION>10
</SELECT>
</TD>
<TD><B>Single w/Size</B><BR>
<INPUT TYPE=button onClick="typeTest(document.mainform.blah2)" VALUE="type">
<INPUT TYPE=button onClick="formTest(document.mainform.blah2)" VALUE="form"><BR>
<INPUT TYPE=button onClick="selIndTest(document.mainform.blah2)" VALUE="selectedIndex">
<INPUT TYPE=button onClick="selIndTestW(document.mainform.blah2)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="valueTest(document.mainform.blah2)" VALUE="value">
<INPUT TYPE=button onClick="valueTestW(document.mainform.blah2)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="lengthTest(document.mainform.blah2)" VALUE="length">
<INPUT TYPE=button onClick="lengthTestW(document.mainform.blah2)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="disabledTest(document.mainform.blah2)" VALUE="disabled">
<INPUT TYPE=button onClick="disabledTestW(document.mainform.blah2)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="multipleTest(document.mainform.blah2)" VALUE="multiple">
<INPUT TYPE=button onClick="multipleTestW(document.mainform.blah2)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="nameTest(document.mainform.blah2)" VALUE="name">
<INPUT TYPE=button onClick="nameTestW(document.mainform.blah2)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="sizeTest(document.mainform.blah2)" VALUE="size">
<INPUT TYPE=button onClick="sizeTestW(document.mainform.blah2)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="hideTest(document.mainform.blah2)" VALUE="Hide">
<INPUT TYPE=button onClick="unhideTest(document.mainform.blah2)" VALUE="Unhide"><BR>
<BR>
<SELECT NAME=blah2 SIZE=10 STYLE="display: none">
<OPTION>1
<OPTION>2
<OPTION>3
<OPTION>4
<OPTION>5
<OPTION>6
<OPTION SELECTED>7
<OPTION>8
<OPTION SELECTED>9
<OPTION>10
</SELECT>
</TD>
<TD><B>Multiple</B><BR>
<INPUT TYPE=button onClick="typeTest(document.mainform.blah3)" VALUE="type">
<INPUT TYPE=button onClick="formTest(document.mainform.blah3)" VALUE="form"><BR>
<INPUT TYPE=button onClick="selIndTest(document.mainform.blah3)" VALUE="selectedIndex">
<INPUT TYPE=button onClick="selIndTestW(document.mainform.blah3)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="valueTest(document.mainform.blah3)" VALUE="value">
<INPUT TYPE=button onClick="valueTestW(document.mainform.blah3)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="lengthTest(document.mainform.blah3)" VALUE="length">
<INPUT TYPE=button onClick="lengthTestW(document.mainform.blah3)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="disabledTest(document.mainform.blah3)" VALUE="disabled">
<INPUT TYPE=button onClick="disabledTestW(document.mainform.blah3)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="multipleTest(document.mainform.blah3)" VALUE="multiple">
<INPUT TYPE=button onClick="multipleTestW(document.mainform.blah3)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="nameTest(document.mainform.blah3)" VALUE="name">
<INPUT TYPE=button onClick="nameTestW(document.mainform.blah3)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="sizeTest(document.mainform.blah3)" VALUE="size">
<INPUT TYPE=button onClick="sizeTestW(document.mainform.blah3)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="hideTest(document.mainform.blah3)" VALUE="Hide">
<INPUT TYPE=button onClick="unhideTest(document.mainform.blah3)" VALUE="Unhide"><BR>
<BR>
<SELECT NAME=blah3 MULTIPLE SIZE=10 STYLE="display: none">
<OPTION>1
<OPTION>2
<OPTION>3
<OPTION>4
<OPTION>5
<OPTION>6
<OPTION SELECTED>7
<OPTION>8
<OPTION SELECTED>9
<OPTION>10
</SELECT>
</TD>
<TD><B>Optgroup</B><BR>
<INPUT TYPE=button onClick="typeTest(document.mainform.blah4)" VALUE="type">
<INPUT TYPE=button onClick="formTest(document.mainform.blah4)" VALUE="form"><BR>
<INPUT TYPE=button onClick="selIndTest(document.mainform.blah4)" VALUE="selectedIndex">
<INPUT TYPE=button onClick="selIndTestW(document.mainform.blah4)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="valueTest(document.mainform.blah4)" VALUE="value">
<INPUT TYPE=button onClick="valueTestW(document.mainform.blah4)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="lengthTest(document.mainform.blah4)" VALUE="length">
<INPUT TYPE=button onClick="lengthTestW(document.mainform.blah4)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="disabledTest(document.mainform.blah4)" VALUE="disabled">
<INPUT TYPE=button onClick="disabledTestW(document.mainform.blah4)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="multipleTest(document.mainform.blah4)" VALUE="multiple">
<INPUT TYPE=button onClick="multipleTestW(document.mainform.blah4)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="nameTest(document.mainform.blah4)" VALUE="name">
<INPUT TYPE=button onClick="nameTestW(document.mainform.blah4)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="sizeTest(document.mainform.blah4)" VALUE="size">
<INPUT TYPE=button onClick="sizeTestW(document.mainform.blah4)" VALUE="(set)"><BR>
<INPUT TYPE=button onClick="hideTest(document.mainform.blah4)" VALUE="Hide">
<INPUT TYPE=button onClick="unhideTest(document.mainform.blah4)" VALUE="Unhide"><BR>
<BR>
<SELECT NAME=blah4 MULTIPLE SIZE=10 STYLE="display: none">
<OPTGROUP label=first>
<OPTION>1
<OPTION>2
<OPTION>3
<OPTION>4
<OPTION>5
<OPTION>6
<OPTION SELECTED>7
<OPTION>8
</OPTGROUP>
<OPTGROUP label=second>
<OPTION SELECTED>9
<OPTION>10
</OPTGROUP>
<OPTION>11
</SELECT>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>