<?xml version="1.0"?>
<!DOCTYPE testsuite SYSTEM "http://www.w3.org/WAI/UA/TS/dtd/uaag-testsuite-2.dtd">


<testsuite id="ts0102-onclick-multiple-events">
	
	<metaInfo>
		<testTitle>Multiple Event Handlers for ONCLICK and ONDBCLICK</testTitle>
		<shortTitle>ONCLICK and ONDBCLICK for multiple event handlers</shortTitle>
		<testElement>
			<elementName>ONCLICK</elementName>
			<hlink href="http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.3">&hspec; ONCLICK</hlink>
		</testElement>
		<testElement>
			<elementName>ONDBCLICK</elementName>
			<hlink href="http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.3">&hspec; ONDBCLICK</hlink>
		</testElement>		
		<creator>Colin Koteles</creator>				
		<creator>Dominique Kilman</creator>
		
				
		<metaElement></metaElement>
		<testStyle></testStyle>
	</metaInfo>
	
	<requirementInfo>
   	<checkpoints>
      	<checkpoint xref="tech-device-independent-handlers">
         	<provisions>
            	<provision xref="tech-device-independent-handlers-2"/>
            </provisions>
         </checkpoint>
      </checkpoints>
 	</requirementInfo>
	
	<content>
		
		
		
		<test section="1">
			<procedure>
				<list>
					<item>Using the keyboard or an assistive technology that emulates the keyboard,
					navigate to either image and activate both ONCLICK events and both ONDBLCLICK events
					to change the color of both stars.</item>
				</list>
			</procedure>
			<testCode>
				<table border="1" summary="Table to test two event handlers associated with onclick and ondblclick events">
					<tr><td>
						<img id="star1" ondblclick="imgChange('../images/starPink.gif'); imgChange2('../images/starPink.gif')" onclick="imgChange('../images/starRed.gif'); imgChange2('../images/starRed.gif')" src="../images/starYel.gif" width="35" height="35" alt="star" border="0" name="star1"/>
					</td><td>
						<img id="star2" ondblclick="imgChange('../images/starPink.gif'); imgChange2('../images/starPink.gif')" onclick="imgChange('../images/starRed.gif'); imgChange2('../images/starRed.gif')" src="../images/starYel.gif" width="35" height="35" alt="star" border="0" name="star2"/>
					</td></tr>				
				</table>
			</testCode>
      	<exResults>
				<list>
					<item>Both images change to a red star on single-click keyboard command</item>
					<item>Both images change to a pink star on double-click keyboard command</item>					
				</list>
			</exResults>
			<sourcescript>
					function imgChange( img ) 
					{
   					document.star1.src = img
					}
					function imgChange2( img ) 
					{
   					document.star2.src = img
					}									
			</sourcescript>
		</test>
		
		<test section="2">
			<procedure>
				<list>
					<item>Using the keyboard or an assistive technology that emulates the keyboard, navigate to the text input box.</item>
					<item>Using the keyboard or an assistive technology that emulates the keyboard, clear the text input box and change the input box background color with ONCLICK.</item>					
				</list>
			</procedure>
			<testCode>
				<form action="../action/return.html" method="get" enctype="application/x-www-form-urlencoded" name="form1">
					<input type="text" style="background-color: #ffffff;" onclick="clearText(this); changeInColor(this)" value="Click here to clear text" name="text1"/> 
				</form>
			</testCode>
      	<exResults>
				<list>
					<item>Text in input box is cleared</item>
					<item>The background color of the input box changes</item>					
				</list>
			</exResults>
			<sourcescript>
					function clearText(thefield)
					{
						if (thefield.defaultValue == thefield.value)
										thefield.value = ""
      				else 
							thefield.value = thefield.defaultValue
					}
					function changeInColor(thefield) 
					{
						if (thefield.defaultValue == thefield.value)
						 	document.form1.text1.style.background= "#ffffff"
						else
						 	document.form1.text1.style.background= "#ffcccc"
					}							 						
			</sourcescript>
		</test>
		
		<test section="3">
			<procedure>
				<list>
					<item>Using the keyboard or an assistive technology that emulates the keyboard, navigate to the text input box.</item>
					<item>Using the keyboard or an assistive technology that emulates the keyboard, activate both ONDBCLICK functions associated with the text input box.</item>					
				</list>
			</procedure>
			<testCode>
				<form action="../action/return.html" method="get" enctype="application/x-www-form-urlencoded" name="form2">
					<label for="text2">Double-click on the text box to activate the event handlers:&nbsp;</label> 
					<input type="text" id="text2" name="text2" style="background-color: #ffffff;" ondblclick="showText(this); changeInColor2(this)"/>
				</form>
			</testCode>
      	<exResults>
				<list>
					<item>The text "Passes the Test" appears in the text box upon double-click</item>
					<item>The background color of the text input box changes color upon double-click</item>					
				</list>
			</exResults>
			<sourcescript>
					function showText(thefield)
					{
						if (thefield.defaultValue == thefield.value)
								thefield.value = "Passed the test"
      				else
           					thefield.value = ""
					}
					function changeInColor2(thefield) 
					{
						if (thefield.defaultValue == thefield.value)
						 		document.form2.text2.style.background= "#ffffff"
						else
						 		document.form2.text2.style.background= "#ffcccc"
					}					 									
			</sourcescript>
		</test>				
						
	</content>

</testsuite>