interact-dom-01-b
|
SVG Image
|
PNG Image
|
interact-dom-01-b
Checks if DOM/ECMA Script binding is supported. Checks that the DOM API
supports event listener registration/unregistration.
var svg_ns = "http://www.w3.org/2000/svg"
var doc;
var content;
var startButton;
var buttonRect;
var yLocation = 280;
//
// onload handler for top level svg element. Sets a UI event listener for
// the test start button.
//
function initTest(evt){
// Get Document
var target = evt.target;
doc = target.ownerDocument;
content = doc.getElementById("test-body-content");
// Get start rect and add a UI listener
startButton = doc.getElementById("startButton");
buttonRect = doc.getElementById("buttonRect");
startButton.addEventListener("click", uiEventDetected, false);
}
//
// click handler for 'startButton' rect element.
//
function uiEventDetected(evt) {
//
// Add an element to show that UI event was detected
//
var newText = doc.createElementNS(svg_ns, 'text');
newText.setAttribute('x', '5');
newText.setAttribute('y', yLocation);
newText.setAttribute('font-size', '40');
var message = "Event Listeners supported";
var textContent = doc.createTextNode(message);
newText.appendChild(textContent);
content.appendChild(newText);
startButton.removeEventListener("click", uiEventDetected, false);
// Make start button pink
buttonRect.setAttribute("fill", "#ff8888");
buttonRect.setAttribute("stroke", "black");
// If test does not successfully remove the event listener, then
// a second click will cause a subsequent text string to appear 50 units
// below the first new text string.
yLocation = yLocation + 50;
}
Start Test
$Revision: 1.2 $
|
|
|
Verify basic support for DOM event listener registration. The root svg element
has an onload handler where a click event listener is registered on group element 'Start Button'.
If UI events listener registration is supported (and UI events),
when the user clicks on the button a text node is inserted reading "Event Listeners supported".
At the end of the test, the start test button in changed to pink,
and the click event listener is removed from the the start button.
Subsequent clicks on the start button should cause no effect if
the event listener has been removed successfully.
If additional lines of text appear in the document that say "Event Listeners supported",
then the implementation has not successfully removed the event listener.
After clicking at least once on the button,
the rendered image should be exactly as the reference image, except for
differences in text display.