File: script-languages-02.html

package info (click to toggle)
iceweasel 38.8.0esr-1~deb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,578,008 kB
  • sloc: cpp: 4,134,345; ansic: 1,765,754; python: 324,651; java: 233,700; asm: 138,937; xml: 98,298; sh: 82,895; makefile: 21,621; perl: 17,235; objc: 4,014; yacc: 1,968; lex: 1,179; exp: 499; pascal: 479; lisp: 228; awk: 152; ruby: 82; sed: 43; csh: 31; ada: 16; php: 1
file content (98 lines) | stat: -rw-r--r-- 3,179 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<title>Script @type: JavaScript types</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testAttribute(attr, val, shouldRun) {
  test(function() {
    assert_false(ran, "ran variable not reset");
    var script = document.createElement("script");
    script.setAttribute(attr, val);
    script.textContent = "ran = true;"
    document.body.appendChild(script);
    assert_equals(ran, shouldRun);
  }, "Script should" + (shouldRun ? "" : "n't") + " run with " + attr + "=" + format_value(val));
  ran = false
}
function testType(type) {
  testAttribute("type", type, true);
}
function testLanguage(lang) {
  testAttribute("language", lang, true);
}
function testTypeIgnored(type) {
  testAttribute("type", type, false);
}
function testLanguageIgnored(lang) {
  testAttribute("language", lang, false);
}
var application = [
  "ecmascript",
  "javascript",
  "x-ecmascript",
  "x-javascript"
];
var text = [
  "ecmascript",
  "javascript",
  "javascript1.0",
  "javascript1.1",
  "javascript1.2",
  "javascript1.3",
  "javascript1.4",
  "javascript1.5",
  "jscript",
  "livescript",
  "x-ecmascript",
  "x-javascript"
];
var spaces = [" ", "\t", "\n", "\r", "\f"];

var ran = false;

// Type attribute

testType("");
testTypeIgnored(" ");

application.map(function(t) { return "application/" + t; }).forEach(testType);
application.map(function(t) { return ("application/" + t).toUpperCase(); }).forEach(testType);

spaces.forEach(function(s) {
  application.map(function(t) { return "application/" + t + s; }).forEach(testType);
  application.map(function(t) { return s + "application/" + t; }).forEach(testType);
})

application.map(function(t) { return "application/" + t + "\0"; }).forEach(testTypeIgnored);
application.map(function(t) { return "application/" + t + "\0foo"; }).forEach(testTypeIgnored);

text.map(function(t) { return "text/" + t; }).forEach(testType);
text.map(function(t) { return ("text/" + t).toUpperCase(); }).forEach(testType);

spaces.forEach(function(s) {
  text.map(function(t) { return "text/" + t + s; }).forEach(testType);
  text.map(function(t) { return s + "text/" + t; }).forEach(testType);
})

text.map(function(t) { return "text/" + t + "\0"; }).forEach(testTypeIgnored);
text.map(function(t) { return "text/" + t + "\0foo"; }).forEach(testTypeIgnored);

// Language attribute

testLanguage("");
testLanguageIgnored(" ");

text.forEach(testLanguage);
text.map(function(t) { return t.toUpperCase(); }).forEach(testLanguage);

text.map(function(t) { return t + " "; }).forEach(testLanguageIgnored);
text.map(function(t) { return " " + t; }).forEach(testLanguageIgnored);
text.map(function(t) { return t + "xyz"; }).forEach(testLanguageIgnored);
text.map(function(t) { return "xyz" + t; }).forEach(testLanguageIgnored);

text.map(function(t) { return t + "\0"; }).forEach(testLanguageIgnored);
text.map(function(t) { return t + "\0foo"; }).forEach(testLanguageIgnored);
</script>