| <script> |
| function log(msg) |
| { |
| document.getElementById('log').appendChild(document.createTextNode(msg + '\n')); |
| } |
| |
| function appendChildText(node, text) |
| { |
| if (node.canHaveChildren == null || node.canHaveChildren) { |
| node.appendChild(document.createTextNode(text)); |
| } else { |
| // IE doesn't allow script nodes to have children. We must use the |
| // .text property instead. |
| node.text = text; |
| } |
| } |
| |
| function createScriptElement(type, language) |
| { |
| var script = document.createElement('script'); |
| |
| var typeStr; |
| if (type == null) { |
| typeStr = 'unspecified'; |
| } else { |
| typeStr = '\\"' + type + '\\"'; |
| script.setAttribute('type', type); |
| } |
| |
| var languageStr; |
| if (language == null) { |
| languageStr = 'unspecified'; |
| } else { |
| languageStr = '\\"' + language + '\\"'; |
| script.setAttribute('language', language); |
| } |
| |
| var text = 'log("Type: ' + typeStr + ', Language: ' + languageStr + '");'; |
| appendChildText(script, text); |
| |
| return script; |
| } |
| |
| function test() |
| { |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| var types = [ |
| null, |
| "", |
| "text/javascript", |
| "text/ecmascript", |
| "application/javascript", |
| "application/ecmascript", |
| "application/x-javascript", |
| "text/javascript1.0", |
| "text/javascript1.1", |
| "text/javascript1.2", |
| "text/javascript1.3", |
| "text/javascript1.4", |
| "text/javascript1.5", |
| "text/javascript1.6", |
| "text/javascript1.7", |
| "text/javascript1.8", |
| "text/javascript1.9", |
| "text/jscript", |
| "text/livescript", |
| "text/x-ebayScript", |
| " text/javascript", |
| "text/javascript ", |
| " text/javascript ", |
| " ", |
| "abcdefg" |
| ]; |
| |
| var languages = [ |
| "", |
| "javascript", |
| "javascript1.0", |
| "javascript1.1", |
| "javascript1.2", |
| "javascript1.3", |
| "javascript1.4", |
| "javascript1.5", |
| "javascript1.6", |
| "javascript1.7", |
| "javascript1.8", |
| "javascript1.9", |
| "ecmascript", |
| "livescript", |
| "jscript", |
| "ebayScript", |
| " ", |
| " javascript", |
| "javascript ", |
| " javascript ", |
| "abcdefg" |
| ]; |
| |
| for (var i = 0; i < types.length; ++i) |
| document.body.appendChild(createScriptElement(types[i], null)); |
| |
| for (var i = 0; i < languages.length; ++i) |
| document.body.appendChild(createScriptElement(null, languages[i])); |
| |
| for (var i = 0; i < languages.length; ++i) |
| document.body.appendChild(createScriptElement("", languages[i])); |
| |
| log('When a type is specified, the language attribute should be ignored.'); |
| for (var i = 0; i < languages.length; ++i) |
| document.body.appendChild(createScriptElement("text/javascript", languages[i])); |
| } |
| </script> |
| <body onload="test();"> |
| <p>This page tests the allowed values for the type and language attributes |
| of the <script> tag. Below you will see the allowed values.</p> |
| |
| <pre id="log"></pre> |
| </body> |