HTML 4.01 Test Suite - Assertions

Testable Assertions: Section 18 Scripts


Valid HTML 4.01!


18 Scripts - Animated Documents and Smart Forms

Assertion 18.1-1

Reference: Section 18.1
(may) A client-side script is a program that may accompany an HTML document or be embedded directly in it. The program executes on the client's machine when the document loads, or at some other time such as when a link is activated. HTML's support for scripts is independent of the scripting language.
Tests: None

Assertion 18.1-2

Reference: Section 18.1
(author)(informative) Scripts offer authors a means to extend HTML documents in highly active and interactive ways.
Tests: None

Assertion 18.1-3

Reference: Section 18.1
(author)(may) There are two types of scripts authors may attach to an HTML document: 1. Those that are executed one time when the document is loaded by the user agent. Scripts that appear within a SCRIPT element are executed when the document is loaded. For user agents that cannot or will not handle scripts, authors may include alternate content via the NOSCRIPT element. 2. Those that are executed every time a specific event occurs. These scripts may be assigned to a number of elements via the intrinsic event attributes.
Tests: None

Assertion 18.2.1-1

Reference: Section 18.2.1
(author)(must) Start tags and End tags for script elements are required.
Tests: None

Assertion 18.2.1-2

Reference: Section 18.2.1
(must) SCRIPT: src = uri [CT] This attribute specifies the location of an external script.
Tests: 18_2_1-BF-01.html

Assertion 18.2.1-3

Reference: Section 18.2.1
(must) SCRIPT: type = content-type [CI] This attribute specifies the scripting language of the element's contents and overrides the default scripting language. The scripting language is specified as a content type (e.g., "text/javascript").
Tests: 18_2_1-BF-01.html

Assertion 18.2.1-4

Reference: Section 18.2.1
(author)(must) Authors must supply a value for this attribute (SCRIPT: type = content-type [CI]).. There is no default value for this attribute.
Tests: None

Assertion 18.2.1-5

Reference: Section 18.2.1
(must)(deprecated) SCRIPT: language = cdata [CI] Deprecated. This attribute specifies the scripting language of the contents of this element. Its value is an identifier for the language, but since these identifiers are not standard, this attribute has been deprecated in favor of type.
Tests: None

Assertion 18.2.1-6

Reference: Section 18.2.1
(must) SCRIPT: defer [CI] When set, this boolean attribute provides a hint to the user agent that the script is not going to generate any document content (e.g., no "document.write" in javascript) and thus, the user agent can continue parsing and rendering.
Tests: 18_2_1-BF-02.html

Assertion 18.2.1-7

Reference: Section 18.2.1
(must) The SCRIPT element places a script within a document. This element may appear any number of times in the HEAD or BODY of an HTML document.
Tests: None

Assertion 18.2.1-8

Reference: Section 18.2.1
(may) The script may be defined within the contents of the SCRIPT element or in an external file.
Tests: None

Assertion 18.2.1-9

Reference: Section 18.2.1
(must) If the src attribute is not set, user agents must interpret the contents of the element as the script.
Tests: 18_2_1-BF-03.html

Assertion 18.2.1-10

Reference: Section 18.2.1
(must) If the src has a URI value, user agents must ignore the element's contents and retrieve the script via the URI.
Tests: 18_2_1-BF-03.html

Assertion 18.2.1-11

Reference: Section 18.2.1
(informative) The charset attribute refers to the character encoding of the script designated by the src attribute; it does not concern the content of the SCRIPT element.
Tests: None

Assertion 18.2.1-12

Reference: Section 18.2.1
(must) Scripts are evaluated by script engines that must be known to a user agent.
Tests: None

Assertion 18.2.1-13

Reference: Section 18.2.1
(should) The syntax of script data depends on the scripting language.
Tests: None

Assertion 18.2.2-1

Reference: Section 18.2.2
(author)(must) As HTML does not rely on a specific scripting language, document authors must explicitly tell user agents the language of each script.
Tests: None

Assertion 18.2.2-2

Reference: Section 18.2.2
(must) Specifying the scripting language may be done either through a default declaration or a local declaration.
Tests: None

Assertion 18.2.2-3

Reference: Section 18.2.2
(author)(should) Authors should specify the default scripting language for all scripts in a document by including the META declaration in the HEAD.
Tests: None

Assertion 18.2.2-4

Reference: Section 18.2.2
(should) In the absence of a META declaration, the default can be set by a "Content-Script-Type" HTTP header.
Tests: None

Assertion 18.2.2-5

Reference: Section 18.2.2
(should) User agents should determine the default scripting language for a document according to the following steps (highest to lowest priority): 1. If any META declarations specify the "Content-Script-Type", the last one in the character stream determines the default scripting language. 2. Otherwise, if any HTTP headers specify the "Content-Script-Type", the last one in the character stream determines the default scripting language.
Tests: None

Assertion 18.2.2-6

Reference: Section 18.2.2
(author)(must) Documents that do not specify default scripting language information and that contain elements that specify an intrinsic event script are incorrect.
Tests: None

Assertion 18.2.2-7

Reference: Section 18.2.2
(may) User agents may still attempt to interpret incorrectly specified scripts but are not required to.
Tests: None

Assertion 18.2.2-8

Reference: Section 18.2.2
(author)(should) Authoring tools should generate default scripting language information to help authors avoid creating incorrect documents.
Tests: None

Assertion 18.2.2-9

Reference: Section 18.2.2
(author)(must) The type attribute must be specified for each SCRIPT element instance in a document.
Tests: None

Assertion 18.2.2-9

Reference: Section 18.2.2
(must) The value of the type attribute for a SCRIPT element overrides the default scripting language for that element.
Tests: None

Assertion 18.2.2-10

Reference: Section 18.2.2
(informative) Each scripting language has its own conventions for referring to HTML objects from within a script. This specification does not define a standard mechanism for referring to HTML objects.
Tests: None

Assertion 18.2.2-11

Reference: Section 18.2.2
(should) Scripts should refer to an element according to its assigned name. Scripting engines should observe the precedence rules (described in 18.2.3)when identifying an element: a name attribute takes precedence over an id if both are set. Otherwise, one or the other may be used.
Tests: None

Assertion 18.2.3-1

Reference: Section 18.2.3
(author)(informative) Authors of HTML documents are advised that changes are likely to occur in the realm of intrinsic events (e.g., how scripts are bound to events). Research in this realm is carried on by members of the W3C Document Object Model Working Group (see the W3C Web Site at http://www.w3.org/ for more information).
Tests: None

Assertion 18.2.3-2

Reference: Section 18.2.3
(must) Intrinsic events: onload = script [CT] The onload event occurs when the user agent finishes loading a window or all frames within a FRAMESET.
Tests: 18_2_3-BF-13.html

Assertion 18.2.3-3

Reference: Section 18.2.3
(must) Intrinsic events: onload = script [CT] This attribute may be used with BODY and FRAMESET elements.
Tests: None

Assertion 18.2.3-4

Reference: Section 18.2.3
(must) Intrinsic events: onunload = script [CT] The onunload event occurs when the user agent removes a document from a window or frame.
Tests: 18_2_3-BF-14.html

Assertion 18.2.3-5

Reference: Section 18.2.3
(must) Intrinsic events: onunload = script [CT] This attribute may be used with BODY and FRAMESET elements.
Tests: None

Assertion 18.2.3-6

Reference: Section 18.2.3-6
(must) Intrinsic events: onclick = script [CT] The onclick event occurs when the pointing device button is clicked over an element.
Tests: None

Assertion 18.2.3-7

Reference: Section 18.2.3
(must) Intrinsic events: onclick = script [CT] This attribute may be used with most elements.
Tests: None

Assertion 18.2.3-8

Reference: Section 18.2.3
(must) Intrinsic events: ondblclick = script [CT] The ondblclick event occurs when the pointing device button is double clicked over an element.
Tests: 18_2_3-BF-02.html

Assertion 18.2.3-9

Reference: Section 18.2.3
(must) Intrinsic events: ondblclick = script [CT] (This attribute may be used with most elements.
Tests: None

Assertion 18.2.3-10

Reference: Section 18.2.3
(must) Intrinsic events: onmousedown = script [CT] The onmousedown event occurs when the pointing device button is pressed over an element.
Tests: 18_2_3-BF-03.html

Assertion 18.2.3-11

Reference: Section 18.2.3
(must) Intrinsic events: onmousedown = script [CT] This attribute may be used with most elements.
Tests: None

Assertion 18.2.3-12

Reference: Section 18.2.3
(must) Intrinsic events: onmouseup = script [CT] The onmouseup event occurs when the pointing device button is released over an element.
Tests: 18_2_3-BF-04.html

Assertion 18.2.3-13

Reference: Section 18.2.3
(must) Intrinsic events: onmouseup = script [CT] This attribute may be used with most elements.
Tests: None

Assertion 18.2.3-14

Reference: Section 18.2.3
(must) Intrinsic events: onmouseover = script [CT] The onmouseover event occurs when the pointing device is moved onto an element.
Tests: 18_2_3-BF-05.html

Assertion 18.2.3-15

Reference: Section 18.2.3
(must) Intrinsic events: onmouseover = script [CT] This attribute may be used with most elements.
Tests: None

Assertion 18.2.3-16

Reference: Section 18.2.3
(must) Intrinsic events: onmousemove = script [CT] The onmousemove event occurs when the pointing device is moved while it is over an element.
Tests: 18_2_3-BF-16.html

Assertion 18.2.3-17

Reference: Section 18.2.3
(must) Intrinsic events: onmousemove = script [CT]This attribute may be used with most elements.
Tests: None

Assertion 18.2.3-18

Reference: Section 18.2.3
(must) Intrinsic events: onmouseout = script [CT] The onmouseout event occurs when the pointing device is moved away from an element.
Tests: 18_2_3-BF-06.html

Assertion 18.2.3-19

Reference: Section 18.2.3
(must) Intrinsic events: onmouseout = script [CT] This attribute may be used with most elements.
Tests: None

Assertion 18.2.3-20

Reference: Section 18.2.3
(must) Intrinsic events: onfocus = script [CT] The onfocus event occurs when an element receives focus either by the pointing device or by tabbing navigation.
Tests: 18_2_3-BF-07.html

Assertion 18.2.3-21

Reference: Section 18.2.3
(must) Intrinsic events: onfocus = script [CT] This attribute may be used with the following elements: A, AREA, LABEL, INPUT, SELECT, TEXTAREA, and BUTTON.
Tests: None

Assertion 18.2.3-22

Reference: Section 18.2.3
(must) Intrinsic events: onblur = script [CT] The onblur event occurs when an element loses focus either by the pointing device or by tabbing navigation.
Tests: 18_2_3-BF-08.html

Assertion 18.2.3-23

Reference: Section 18.2.3
(must) Intrinsic events: onblur = script [CT] This attribute may be used with the same elements as onfocus.
Tests: None

Assertion 18.2.3-24

Reference: Section 18.2.3
(must) Intrinsic events: onkeypress = script [CT] The onkeypress event occurs when a key is pressed and released over an element.
Tests: 18_2_3-BF-09.html

Assertion 18.2.3-25

Reference: Section 18.2.3
(must) Intrinsic events: onkeypress = script [CT] This attribute may be used with most elements.
Tests: None

Assertion 18.2.3-26

Reference: Section 18.2.3
(must) Intrinsic events: onkeydown = script [CT] The onkeydown event occurs when a key is pressed down over an element.
Tests: 18_2_3-BF-15.html

Assertion 18.2.3-27

Reference: Section 18.2.3
(must) Intrinsic events: onkeydown = script [CT] This attribute may be used with most elements.
Tests: None

Assertion 18.2.3-28

Reference: Section 18.2.3
(must) Intrinsic events: onkeyup = script [CT] The onkeyup event occurs when a key is released over an element.
Tests: 18_2_3-BF-10.html

Assertion 18.2.3-29

Reference: Section 18.2.3
(must) Intrinsic events: onkeyup = script [CT] This attribute may be used with most elements.
Tests: None

Assertion 18.2.3-30

Reference: Section 18.2.3
(must) Intrinsic events: onsubmit = script [CT] The onsubmit event occurs when a form is submitted.
Tests: 18_2_3-BF-11.html

Assertion 18.2.3-31

Reference: Section 18.2.3
(must) Intrinsic events: onsubmit = script [CT] It only applies to the FORM element.
Tests: None

Assertion 18.2.3-32

Reference: Section 18.2.3
(must) Intrinsic events: onreset = script [CT] The onreset event occurs when a form is reset.
Tests: 18_2_3-BF-12.html

Assertion 18.2.3-33

Reference: Section 18.2.3
(must) Intrinsic events: onreset = script [CT] It only applies to the FORM element.
Tests: None

Assertion 18.2.3-34

Reference: Section 18.2.3
(must) Intrinsic events: onselect = script [CT] The onselect event occurs when a user selects some text in a text field.
Tests: None

Assertion 18.2.3-35

Reference: Section 18.2.3.
(must) Intrinsic events: onselect = script [CT] This attribute may be used with the INPUT and TEXTAREA elements.
Tests: None

Assertion 18.2.3-36

Reference: Section 18.2.3
(must) Intrinsic events: onchange = script [CT] The onchange event occurs when a control loses the input focus and its value has been modified since gaining focus.
Tests: None

Assertion 18.2.3-37

Reference: Section 18.2.3
(must) Intrinsic events: onchange = script [CT] This attribute applies to the following elements: INPUT, SELECT, and TEXTAREA.
Tests: None

Assertion 18.2.3-38

Reference: Section 18.2.3
(should) It is possible to associate an action with a certain number of events that occur when a user interacts with a user agent.
Tests: None

Assertion 18.2.3-39

Reference: Section 18.2.3
(must) Each of the "intrinsic events" takes a value that is a script.
Tests: None

Assertion 18.2.3-40

Reference: Section 18.2.3
(must) The script is executed whenever the event occurs for that element.
Tests: None

Assertion 18.2.3-41

Reference: Section 18.2.3
(must) The syntax of script data depends on the scripting language.
Tests: None

Assertion 18.2.3-42

Reference: Section 18.2.3
(must) Control elements such as INPUT, SELECT, BUTTON, TEXTAREA, and LABEL all respond to certain intrinsic events.
Tests: None

Assertion 18.2.3-43

Reference: Section 18.2.3
(may) When control elements do not appear within a form, they may be used to augment the graphical user interface of the document.
Tests: None

Assertion 18.2.3-44

Reference: Section 18.2.3
(must) "document.write" or equivalent statements in intrinsic event handlers create and write to a new document rather than modifying the current one.
Tests: None

Assertion 18.2.4-1

Reference: Section 18.2.4
(may) Scripts that are executed when a document is loaded may be able to modify the document's contents dynamically. The ability to do so depends on the scripting language itself (e.g., the "document.write" statement in the HTML object model supported by some vendors).
Tests: None

Assertion 18.2.4-2

Reference: Section 18.2.4
(may) The dynamic modification of a document may be modeled as follows: 1. All SCRIPT elements are evaluated in order as the document is loaded. 2. All script constructs within a given SCRIPT element that generate SGML CDATA are evaluated. Their combined generated text is inserted in the document in place of the SCRIPT element. 3. The generated CDATA is re-evaluated.
Tests: None

Assertion 18.2.4-3

Reference: Section 18.2.4
(must) HTML documents are constrained to conform to the HTML DTD both before and after processing any SCRIPT elements.
Tests: None

Assertion 18.3.1-1

Reference: Section 18.3.1
(author)(must) Start tags and End tags for NOSCRIPT are required.
Tests: None

Assertion 18.3.1-2

Reference: Section 18.3.1
(must) The NOSCRIPT element allows authors to provide alternate content when a script is not executed.
Tests: None

Assertion 18.3.1-3

Reference: Section 18.3.1
(should) The content of a NOSCRIPT element should only be rendered by a script-aware user agent in the following cases: 1. The user agent is configured not to evaluate scripts. 2. The user agent doesn't support a scripting language invoked by a SCRIPT element earlier in the document.
Tests: None

Assertion 18.3.1-4

Reference: Section 18.3.1
(must) User agents that do not support client-side scripts must render NONSCRIPT element's contents.
Tests: None

Assertion 18.3.2-1

Reference: Section 18.3.2
(informative) User agents that don't recognize the SCRIPT element will likely render that element's contents as text.
Tests: None

Assertion 18.3.2-2

Reference: Section 18.3.2
(should) Some scripting engines, including those for languages JavaScript, VBScript, and Tcl allow the script statements to be enclosed in an SGML comment. User agents that don't recognize the SCRIPT element will thus ignore the comment while smart scripting engines will understand that the script in comments should be executed.
Tests: None

Assertion 18.3.2-3

Reference: Section 18.3.2
(should) One of solution to the problem that user agents don't recognize the script element is to keep scripts in external documents and refer to them with the src attribute.
Tests: None

Assertion 18.3.2-4

Reference: Section 18.3.2
(should) The JavaScript engine allows the string "<!--" to occur at the start of a SCRIPT element, and ignores further characters until the end of the line. JavaScript interprets "//" as starting a comment extending to the end of the current line. This is needed to hide the string "-->" from the JavaScript parser.
Tests: None

Assertion 18.3.2-5

Reference: Section 18.3.2
(should) In VBScript, a single quote character causes the rest of the current line to be treated as a comment. It can therefore be used to hide the string "-->" from VBScript.
Tests: None

Assertion 18.3.2-6

Reference: Section 18.3.2
(should) In Tcl, the "#" character comments out the rest of the line.
Tests: None

Assertion 18.3.2-7

Reference: Section 18.3.2
(author)(should) Some browsers close comments on the first ">" character, so to hide script content from such browsers, you can transpose operands for relational and shift operators (e.g., use "y < x" rather than "x > y") or use scripting language-dependent escapes for ">".
Tests: None