TestCoverage/15-Scripting

From SVG
Jump to: navigation, search

This page is an archive of the previous Group's wiki from http://www.w3.org/Graphics/SVG/Group/wiki.


Test Coverage for SVG Tiny 1.2 Chapter 15: Scripting

[1]

Legend:

 - is a comment or note
  is an assertion or feature that is fully covered in the test suite
 # is an assertion or feature that is partially or not covered in the test suite

15.1 Specifying the scripting language

# "The 'contentScriptType' attribute on the 'svg' element specifies the default scripting language for the given document fragment."
 - might be marked as struct-svg

15.2 The 'script' element

  "If a script element has both an xlink:href attribute and child character data, the executable content for the script is retrieved from the IRI of the xlink:href attribute, and the child content is not added to the scripting context."
 - script-element-201-t.svg


# "Thus, an ECMAScript function defined within any script element must be in the "global" scope of the entire document to which the script belongs."
- This is tested indirectly, and relied upon in many tests.


# "The global object must have all the methods and attributes from the SVGGlobal interface."


# "It [the global object] must be made available from an SVGDocument through the global attribute."


 "Event listeners attached through event attributes and handler elements are also evaluated using the global scope of the document in which they are defined."
 - Partially tested script-element-202-t.svg


# "For compiled languages (such as Java) that don't have a notion of "global scope", each script element, in effect, provides a 

separate scope object. This scope object must perform an initialization as described in the uDOM chapter and serves as event listener factory for the handler element."


 "The script element is added to the DOM tree. This may be a result of parsing the original document, or as an addition to the DOM via script or other means. (Note: script elements are not processed until they are added to the DOM tree.)"
 - script-element-202-t.svg


# "The script element is resolved, i.e. if the script element references an external resource the resource is retrieved."
 - Test on various server mimetypes that are not application/ecmascript and with or without gzip


# "5. The load event is raised."


# "Removing or altering a script element after the script-content is in the scripting context and available for execution will not prevent the script from executing nor the associated load event from being raised."
- Tested partially by script-element-203-t.svg.


# "Removing or altering a script element before the script-content is in the scripting context will prevent the script from executing, the script-content will not be added to the scripting context and the associated load event will not be raised."
- Tested partially by script-element-203-t.svg.


 "Altering the xlink:href on a script element in the DOM tree has no effect; loading of the referenced resource is not required, it must not be added to the scripting context and a load event must not be raised, even if the initial script-content had not been made fully available for execution."
- Tested by script-element-203-t.svg.


# application/ecmascript: "SVG implementations that load external resources through protocols such as HTTP that support content coding must accept external script files that have been encoded using gzip compression (flagged using "Content-Encoding: gzip" for HTTP)."


# application/java-archive: "This type of executable content must be an external resource that contains a Java JAR archive. The manifest file in the JAR archive must have an entry named SVG-Handler-Class. The entry's value must be a fully-qualified Java class name for a class contained in this archive. The user agent must instantiate the class from the JAR file and cast it to the EventListenerInitializer2 interface. Then the initializeEventListeners method must be called with the script element object itself as a parameter. If a class listed in SVG-Handler-Class does not implement EventListenerInitializer2, it is an error."


# "Implementations must also accept the script type "text/ecmascript" for backwards compatibility with SVG 1.1."


# Test various type attributes on <script>


 Test that xlink:href is not animatable on <script>
- Tested by http://dev.w3.org/SVG/profiles/1.2T/test/svg/script-element-203-t.svg


# Test reference restrictions on <script>

15.3 XML Events

# Read XML Events 1 spec and make up some nice tests


# Test all events ("The list of events supported by SVG Tiny 1.2 is given in the Interactivity chapter.")

15.4 The listener element

 "The 'listener' element from XML Events [XML-EVENTS] must be supported."
- This is tested by many of the testcases in the testsuite.


# "Whenever the attributes of a listener element are modified, the corresponding event listener is removed and a new one is created."


# "When listener elements are added or removed, the event listener is added or removed respectively."


 "Please note that the 'listener' element must be specified in the XML Events namespace, and that an element in the SVG namespace with 'listener' as its local name must not be understood as being the element described in this chapter."
- This is partially tested by script-listener-203-t.svg. 


# "Furthermore, the XML Events attributes that are available on other elements only when they are in the XML Events namespace, are only available on this element when they are in no namespace."
- This is partially tested by script-listener-203-t.svg.


# "The 'observer' attribute is defined in XML Events. This attribute is an IDREF as defined in XML Events. Note that if the 'observer' attribute is not present, the observer is the parent of the 'listener' element."
- Partially tested by script-listener-201-t.svg.


# "The 'target' attribute is defined in XML Events. This attribute is an IDREF as defined in XML Events."


# "The 'handler' attribute is defined in XML Events. This attribute is an IRI reference as defined in XML Events. Restrictions specified in this chapter as to which IRIs are acceptable must be a enforced"
- This is partially tested by script-listener-202-t.svg.


# "The 'phase' attribute is defined in XML Events. Support for the capture phase is not required in SVG Tiny 1.2, implementations that do not support it must process this attribute as if it had not been specified."
- This is difficult to test since it's not a requirement.


 "The 'propagate' attribute is defined in XML Events."
- Tested by script-listener-204-t.svg


 "The 'defaultAction' attribute is defined in XML Events."
- Tested by script-listener-204-t.svg


# Test that attributes are not animatable on <listener>

15.5 The handler element

# "However, where the script element executes its contents when it is loaded, the handler element must only execute its contents in response to an event."
- While this is not tested separately, it is relied on in many tests.


# "Whenever the type or ev:event attributes of a handler element are modified, the corresponding event listener is removed and a new one is created."


# "When the xlink:href attribute is modified or the content of the handler element is modified, the existing event listener is preserved, but the user agent must execute the updated handler logic."
- Tested in http://dev.w3.org/cvsweb/SVG/profiles/1.2T/test/svg/script-handle-203-t.svg.


# "When handler elements are added or removed, the corresponding event listener is added or removed respectively."
- Addition is tested in http://dev.w3.org/cvsweb/SVG/profiles/1.2T/test/svg/script-handle-203-t.svg.


 "In ECMAScript, the element with which the event listener is registered ( the observer ) is pushed into the scope chain and is bound to the this keyword"
- Tested in http://dev.w3.org/cvsweb/SVG/profiles/1.2T/test/svg/script-handle-203-t.svg.


# "The 'evt' parameter shown above is an Event object corresponding to the event that has triggered the handler. An 'event' variable can be used instead of 'evt' ('event' is an alias to 'evt')."


 "xlink:href = "<XMLRI>"

If this attribute is present, then the script content of the handler element must be loaded from this resource and what content the handler element may have must not be executable."

- Tested in http://dev.w3.org/cvsweb/SVG/profiles/1.2T/test/svg/script-handle-203-t.svg.


# "For compiled languages, the xlink:href attribute must reference a script element that itself references a JAR archive holding a manifest with an SVG-Handler-Class entry pointing to an EventListenerInitializer2 implementation."

15.6 Event handling

# "Events must cause scripts to execute when either of the following has occurred:

Events are assigned to particular elements and connected with script through the handler element. The script is executed when the given event occurs. Event listeners as described in "Document Object Model Events" [DOM3Events] are defined which are invoked when a given event happens on a given object"


15.7 Processing inline executable content

# "If the type of the content, obtained either through the type attribute, the 'contentScriptType' attribute, or the default is not known by the user-agent, then the content must ignored and no further processing takes place."


# "If the type of the content is an XML media type [RFC3023], then the entire subtree of the executable element must be passed on untouched to the script engine."