OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Script @type: JavaScript types</title> |
| 3 <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> |
| 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguage
s"> |
| 5 <script src="../../../../../../resources/testharness.js"></script> |
| 6 <script src="../../../../../../resources/testharnessreport.js"></script> |
| 7 <div id="log"></div> |
| 8 <script> |
| 9 function testAttribute(attr, val, shouldRun) { |
| 10 test(function() { |
| 11 assert_false(ran, "ran variable not reset"); |
| 12 var script = document.createElement("script"); |
| 13 script.setAttribute(attr, val); |
| 14 script.textContent = "ran = true;" |
| 15 document.body.appendChild(script); |
| 16 assert_equals(ran, shouldRun); |
| 17 }, "Script should" + (shouldRun ? "" : "n't") + " run with " + attr + "=" + fo
rmat_value(val)); |
| 18 ran = false |
| 19 } |
| 20 function testType(type) { |
| 21 testAttribute("type", type, true); |
| 22 } |
| 23 function testLanguage(lang) { |
| 24 testAttribute("language", lang, true); |
| 25 } |
| 26 function testTypeIgnored(type) { |
| 27 testAttribute("type", type, false); |
| 28 } |
| 29 function testLanguageIgnored(lang) { |
| 30 testAttribute("language", lang, false); |
| 31 } |
| 32 var application = [ |
| 33 "ecmascript", |
| 34 "javascript", |
| 35 "x-ecmascript", |
| 36 "x-javascript" |
| 37 ]; |
| 38 var text = [ |
| 39 "ecmascript", |
| 40 "javascript", |
| 41 "javascript1.0", |
| 42 "javascript1.1", |
| 43 "javascript1.2", |
| 44 "javascript1.3", |
| 45 "javascript1.4", |
| 46 "javascript1.5", |
| 47 "jscript", |
| 48 "livescript", |
| 49 "x-ecmascript", |
| 50 "x-javascript" |
| 51 ]; |
| 52 var spaces = [" ", "\t", "\n", "\r", "\f"]; |
| 53 |
| 54 var ran = false; |
| 55 |
| 56 // Type attribute |
| 57 |
| 58 testType(""); |
| 59 testTypeIgnored(" "); |
| 60 |
| 61 application.map(function(t) { return "application/" + t; }).forEach(testType); |
| 62 application.map(function(t) { return ("application/" + t).toUpperCase(); }).forE
ach(testType); |
| 63 |
| 64 spaces.forEach(function(s) { |
| 65 application.map(function(t) { return "application/" + t + s; }).forEach(testTy
pe); |
| 66 application.map(function(t) { return s + "application/" + t; }).forEach(testTy
pe); |
| 67 }) |
| 68 |
| 69 application.map(function(t) { return "application/" + t + "\0"; }).forEach(testT
ypeIgnored); |
| 70 application.map(function(t) { return "application/" + t + "\0foo"; }).forEach(te
stTypeIgnored); |
| 71 |
| 72 text.map(function(t) { return "text/" + t; }).forEach(testType); |
| 73 text.map(function(t) { return ("text/" + t).toUpperCase(); }).forEach(testType); |
| 74 |
| 75 spaces.forEach(function(s) { |
| 76 text.map(function(t) { return "text/" + t + s; }).forEach(testType); |
| 77 text.map(function(t) { return s + "text/" + t; }).forEach(testType); |
| 78 }) |
| 79 |
| 80 text.map(function(t) { return "text/" + t + "\0"; }).forEach(testTypeIgnored); |
| 81 text.map(function(t) { return "text/" + t + "\0foo"; }).forEach(testTypeIgnored)
; |
| 82 |
| 83 // Language attribute |
| 84 |
| 85 testLanguage(""); |
| 86 testLanguageIgnored(" "); |
| 87 |
| 88 text.forEach(testLanguage); |
| 89 text.map(function(t) { return t.toUpperCase(); }).forEach(testLanguage); |
| 90 |
| 91 text.map(function(t) { return t + " "; }).forEach(testLanguageIgnored); |
| 92 text.map(function(t) { return " " + t; }).forEach(testLanguageIgnored); |
| 93 text.map(function(t) { return t + "xyz"; }).forEach(testLanguageIgnored); |
| 94 text.map(function(t) { return "xyz" + t; }).forEach(testLanguageIgnored); |
| 95 |
| 96 text.map(function(t) { return t + "\0"; }).forEach(testLanguageIgnored); |
| 97 text.map(function(t) { return t + "\0foo"; }).forEach(testLanguageIgnored); |
| 98 </script> |
OLD | NEW |