| 1 |
<svg version="1.1" baseProfile="basic" id="svg-root" |
| 2 |
width="100%" height="100%" viewBox="0 0 480 360" onload="initTest(evt)" |
| 3 |
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 4 |
<!--======================================================================--> |
| 5 |
<!--= SVG 1.1 2nd Edition Test Case =--> |
| 6 |
<!--======================================================================--> |
| 7 |
<!--= Copyright 2009 World Wide Web Consortium, (Massachusetts =--> |
| 8 |
<!--= Institute of Technology, European Research Consortium for =--> |
| 9 |
<!--= Informatics and Mathematics (ERCIM), Keio University). =--> |
| 10 |
<!--= All Rights Reserved. =--> |
| 11 |
<!--= See http://www.w3.org/Consortium/Legal/. =--> |
| 12 |
<!--======================================================================--> |
| 13 |
<d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/" |
| 14 |
template-version="1.4" reviewer="SVGWG" author="Vincent Hardy" status="accepted" |
| 15 |
version="$Revision: 1.8 $" testname="$RCSfile: interact-dom-01-b.svg,v $"> |
| 16 |
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/interact.html#DOMInterfaces"> |
| 17 |
<p> |
| 18 |
Verify basic support for DOM event listener registration. The root svg element |
| 19 |
has an onload handler where a click event listener is registered on group element 'Start Button'. |
| 20 |
</p> |
| 21 |
<p> |
| 22 |
If UI events listener registration is supported (and UI events), |
| 23 |
when the user clicks on the button a text node is inserted reading "Event Listeners supported". |
| 24 |
</p> |
| 25 |
<p> |
| 26 |
At the end of the test, the start test button is changed to green, |
| 27 |
and the click event listener is removed from the the start button. |
| 28 |
</p> |
| 29 |
<p> |
| 30 |
Subsequent clicks on the start button should cause no effect if |
| 31 |
the event listener has been removed successfully. |
| 32 |
If additional lines of text appear in the document that say "Event Listeners supported", |
| 33 |
then the implementation has not successfully removed the event listener. |
| 34 |
</p> |
| 35 |
</d:testDescription> |
| 36 |
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml"> |
| 37 |
<p>This test requires user interaction. Run the test, then click on the grey rectangle. |
| 38 |
If it turns green, click it again. |
| 39 |
</p> |
| 40 |
</d:operatorScript> |
| 41 |
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml"> |
| 42 |
<p> |
| 43 |
After clicking once on the button, the rectangle should have a green fill |
| 44 |
and the text "Event listeners supported" should appear, once. |
| 45 |
|
| 46 |
</p> |
| 47 |
</d:passCriteria> |
| 48 |
</d:SVGTestCase> |
| 49 |
<title id="test-title">$RCSfile: interact-dom-01-b.svg,v $</title> |
| 50 |
<defs> |
| 51 |
<font-face font-family="SVGFreeSansASCII" unicode-range="U+0-7F"> |
| 52 |
<font-face-src> |
| 53 |
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/> |
| 54 |
</font-face-src> |
| 55 |
</font-face> |
| 56 |
</defs> |
| 57 |
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18"> |
| 58 |
|
| 59 |
<script type="text/ecmascript"> |
| 60 |
<![CDATA[ |
| 61 |
|
| 62 |
var svg_ns = "http://www.w3.org/2000/svg" |
| 63 |
var doc; |
| 64 |
var content; |
| 65 |
var startButton; |
| 66 |
var buttonRect; |
| 67 |
var yLocation = 280; |
| 68 |
// |
| 69 |
// onload handler for top level svg element. Sets a UI event listener for |
| 70 |
// the test start button. |
| 71 |
// |
| 72 |
function initTest(evt){ |
| 73 |
// Get Document |
| 74 |
var target = evt.target; |
| 75 |
doc = target.ownerDocument; |
| 76 |
content = doc.getElementById("test-body-content"); |
| 77 |
|
| 78 |
// Get start rect and add a UI listener |
| 79 |
startButton = doc.getElementById("startButton"); |
| 80 |
buttonRect = doc.getElementById("buttonRect"); |
| 81 |
startButton.addEventListener("click", uiEventDetected, false); |
| 82 |
} |
| 83 |
|
| 84 |
// |
| 85 |
// click handler for 'startButton' rect element. |
| 86 |
// |
| 87 |
function uiEventDetected(evt) { |
| 88 |
// |
| 89 |
// Add an element to show that UI event was detected |
| 90 |
// |
| 91 |
var newText = doc.createElementNS(svg_ns, 'text'); |
| 92 |
newText.setAttribute('x', '5'); |
| 93 |
newText.setAttribute('y', yLocation); |
| 94 |
newText.setAttribute('font-size', '40'); |
| 95 |
var message = "Event Listeners supported"; |
| 96 |
var textContent = doc.createTextNode(message); |
| 97 |
newText.appendChild(textContent); |
| 98 |
content.appendChild(newText); |
| 99 |
|
| 100 |
startButton.removeEventListener("click", uiEventDetected, false); |
| 101 |
|
| 102 |
// Make start button green |
| 103 |
buttonRect.setAttribute("fill", "#88ff88"); |
| 104 |
buttonRect.setAttribute("stroke", "black"); |
| 105 |
|
| 106 |
// If test does not successfully remove the event listener, then |
| 107 |
// a second click will cause a subsequent text string to appear 50 units |
| 108 |
// below the first new text string. |
| 109 |
yLocation = yLocation + 50; |
| 110 |
} |
| 111 |
|
| 112 |
]]> |
| 113 |
</script> |
| 114 |
|
| 115 |
<!-- ===================================================================== --> |
| 116 |
<!-- Start button --> |
| 117 |
<!-- ===================================================================== --> |
| 118 |
<g id="startButton"> |
| 119 |
<rect id="buttonRect" x="65" y="20" width="350" height="200" fill="#dddddd" stroke="black"/> |
| 120 |
<text font-size="54" x="120" y="130">Start Test</text> |
| 121 |
</g> |
| 122 |
</g> |
| 123 |
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32"> |
| 124 |
<text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.8 $</text> |
| 125 |
</g> |
| 126 |
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/> |
| 127 |
<!-- comment out this watermark once the test is approved --> |
| 128 |
<!--<g id="draft-watermark"> |
| 129 |
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/> |
| 130 |
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240" |
| 131 |
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> |
| 132 |
</g>--> |
| 133 |
</svg> |