| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> |
| 3 |
|
| 4 |
<!--======================================================================--> |
| 5 |
<!--= Copyright 2000 World Wide Web Consortium, (Massachusetts =--> |
| 6 |
<!--= Institute of Technology, Institut National de Recherche en =--> |
| 7 |
<!--= Informatique et en Automatique, Keio University). All Rights =--> |
| 8 |
<!--= Reserved. See http://www.w3.org/Consortium/Legal/. =--> |
| 9 |
<!--======================================================================--> |
| 10 |
<!-- ===================================================================== --> |
| 11 |
<!-- --> |
| 12 |
<!-- dom-eventListener-BE-04.svg --> |
| 13 |
<!-- renamed for 1.1 suite to interact-dom-01-f.svg --> |
| 14 |
<!-- --> |
| 15 |
<!-- Tests DOM events support. The test uses ECMA Script --> |
| 16 |
<!-- --> |
| 17 |
<!-- Author : Vincent Hardy 06-08-2000 --> |
| 18 |
<!-- 1.1 revision by Vincent Hardy --> |
| 19 |
<!-- --> |
| 20 |
<!-- History: --> |
| 21 |
<!-- 06 08 2000, VH, created --> |
| 22 |
<!-- 30-oct-2000, LH, corrected "\" to "/" in "text/ecmascript"; ser#2 --> |
| 23 |
<!-- 16-nov-2000, CJ, corrected infinite loop in mutationEventDetected --> |
| 24 |
<!-- 12-dec-2000, JF, replace mutation event logic with more explicit --> |
| 25 |
<!-- test to ensure event listener is removed. --> |
| 26 |
<!-- --> |
| 27 |
<!-- ===================================================================== --> |
| 28 |
<!--======================================================================--> |
| 29 |
<!--= Note. After October 2000, revision history is kept as CVS 'commit' =--> |
| 30 |
<!--= log messages, and therefore is no longer in the preceding preamble.=--> |
| 31 |
<!--======================================================================--> |
| 32 |
|
| 33 |
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-root" width="480" height="360" onload="initTest(evt)"> |
| 34 |
<SVGTestCase xmlns="http://www.w3.org/2000/02/svg/testSuite/description/"> |
| 35 |
<OperatorScript> |
| 36 |
<Paragraph> |
| 37 |
Verify basic support for DOM event listener registration. The root svg element |
| 38 |
has an onload handler where a click event listener is registered on group element 'Start Button'. |
| 39 |
</Paragraph> |
| 40 |
<Paragraph> |
| 41 |
If UI events listener registration is supported (and UI events), |
| 42 |
when the user clicks on the button a text node is inserted reading "UI Event Listeners supported". |
| 43 |
</Paragraph> |
| 44 |
<Paragraph> |
| 45 |
At the end of the test, the start test button in changed to pink, |
| 46 |
and the click event listener is removed from the the start button. |
| 47 |
</Paragraph> |
| 48 |
<Paragraph> |
| 49 |
Subsequent clicks on the start button should cause no effect if |
| 50 |
the event listener has been removed successfully. |
| 51 |
If additional lines of text appear in the document that say "UI Event Listeners supported", |
| 52 |
then the implementation has not successfully removed the event listener. |
| 53 |
</Paragraph> |
| 54 |
<Paragraph> |
| 55 |
After clicking at least once on the button, |
| 56 |
the rendered image should be exactly as the reference image, except for |
| 57 |
differences in text display. |
| 58 |
</Paragraph> |
| 59 |
</OperatorScript> |
| 60 |
</SVGTestCase> |
| 61 |
|
| 62 |
|
| 63 |
<title id="test-title">interact-dom-01-f</title> |
| 64 |
<desc id="test-desc">Checks if DOM/ECMA Script binding is supported. Checks that the DOM API |
| 65 |
supports event listener registration/unregistration.</desc> |
| 66 |
<!--======================================================================--> |
| 67 |
<!--Content of Test Case follows... =====================--> |
| 68 |
<!--======================================================================--> |
| 69 |
<g id="test-body-content"> |
| 70 |
|
| 71 |
<script type="text/ecmascript"><![CDATA[ |
| 72 |
|
| 73 |
var svg_ns = "http://www.w3.org/2000/svg" |
| 74 |
var doc; |
| 75 |
var content; |
| 76 |
var startButton; |
| 77 |
var buttonRect; |
| 78 |
var yLocation = 100; |
| 79 |
// |
| 80 |
// onload handler for top level svg element. Sets a UI event listener for |
| 81 |
// the test start button. |
| 82 |
// |
| 83 |
function initTest(evt){ |
| 84 |
// Get Document |
| 85 |
var target = evt.target; |
| 86 |
doc = target.ownerDocument; |
| 87 |
content = doc.getElementById("test-body-content"); |
| 88 |
|
| 89 |
// Get start rect and add a UI listener |
| 90 |
startButton = doc.getElementById("startButton"); |
| 91 |
buttonRect = doc.getElementById("buttonRect"); |
| 92 |
startButton.addEventListener("click", uiEventDetected, false); |
| 93 |
} |
| 94 |
|
| 95 |
// |
| 96 |
// click handler for 'startButton' rect element. |
| 97 |
// |
| 98 |
function uiEventDetected(evt) { |
| 99 |
// |
| 100 |
// Add an element to show that UI event was detected |
| 101 |
// |
| 102 |
var newText = doc.createElementNS(svg_ns, 'text'); |
| 103 |
newText.setAttribute('x', '50'); |
| 104 |
newText.setAttribute('y', yLocation); |
| 105 |
var message = "UI Event Listeners supported"; |
| 106 |
var textContent = doc.createTextNode(message); |
| 107 |
newText.appendChild(textContent); |
| 108 |
content.appendChild(newText); |
| 109 |
|
| 110 |
startButton.removeEventListener("click", uiEventDetected, false); |
| 111 |
|
| 112 |
// Make start button pink |
| 113 |
buttonRect.setAttribute("fill", "#ff8888"); |
| 114 |
buttonRect.setAttribute("stroke", "black"); |
| 115 |
|
| 116 |
// If test does not successfully remove the event listener, then |
| 117 |
// a second click will cause a subsequent text string to appear 50 units |
| 118 |
// below the first new text string. |
| 119 |
yLocation = yLocation + 50; |
| 120 |
} |
| 121 |
|
| 122 |
]]></script> |
| 123 |
|
| 124 |
<!-- ===================================================================== --> |
| 125 |
<!-- Start button --> |
| 126 |
<!-- ===================================================================== --> |
| 127 |
<g id="startButton"> |
| 128 |
<rect id="buttonRect" x="10" y="50" width="80" height="20" fill="#dddddd" stroke="black" /> |
| 129 |
<text x="15" y="65">Start Test</text> |
| 130 |
</g> |
| 131 |
|
| 132 |
</g> |
| 133 |
<!--======================================================================--> |
| 134 |
<!--Legend and frame: Title, suite and SVG document serialization====--> |
| 135 |
<!--======================================================================--> |
| 136 |
<g id="test-legend" fill="black" font-family="Helvetica" font-size="10" > |
| 137 |
<rect x="10" y="300" width="275" height="50" fill="none" stroke="#000000" /> |
| 138 |
<path fill="none" stroke="#000000" d="M10 315 h275 M205 315 v35 M10 336 h195 M205 332 h80"/> |
| 139 |
<text x="25" y="311">Scalable Vector Graphics (SVG) v1.1 Conformance Suite</text> |
| 140 |
<a xlink:href="copyright-documents-19990405.html"> |
| 141 |
<text x="12" y="347" fill="blue" >Copyright 2002 W3C. All Rights Reserved.</text> |
| 142 |
</a> |
| 143 |
<text font-size="12" x="35" y="330">interact-dom-01-f</text> |
| 144 |
<text font-size="10" x="210" y="327">$Revision: 1.1 $</text> |
| 145 |
<text font-size="10" x="210" y="345">Release 1.0</text> |
| 146 |
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000" /> |
| 147 |
</g> |
| 148 |
</svg> |