Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Document/createAttributeNS-namespace-err.html

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../../resources/js-test.js"></script> 4 <script src="../../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script src="script-tests/createAttributeNS-namespace-err.js"></script> 7 <script>
8 description("createAttirbuteNS tests adapted from createElementNS tests attached to webkit bug 16833");
9
10 function assert(c, m)
11 {
12 if (!c)
13 testFailed(m);
14 else
15 testPassed(m);
16 }
17
18 function stringForExceptionCode(c)
19 {
20 var exceptionName;
21 switch(c) {
22 case DOMException.INVALID_CHARACTER_ERR:
23 exceptionName = "INVALID_CHARACTER_ERR";
24 break;
25 case DOMException.NAMESPACE_ERR:
26 exceptionName = "NAMESPACE_ERR";
27 }
28 if (exceptionName)
29 return exceptionName; // + "(" + c + ")";
30 return c;
31 }
32
33 function assertExceptionCode(exception, expect, m)
34 {
35 var actual = exception.code;
36 if (actual !== expect) {
37 m += "; expected " + stringForExceptionCode(expect) + ", threw " + strin gForExceptionCode(actual);
38 testFailed(m);
39 } else {
40 m += "; threw " + exception.toString();
41 testPassed(m);
42 }
43 }
44
45 var allNSTests = [
46 { args: [undefined, undefined] },
47 { args: [null, undefined] },
48 { args: [undefined, null] },
49 { args: [null, null] },
50 { args: [null, ""], code: 5 },
51 { args: ["", null] },
52 { args: ["", ""], code: 5 },
53 { args: [null, "<div>"], code: 5 },
54 { args: [null, "0div"], code: 5 },
55 { args: [null, "di v"], code: 5 },
56 { args: [null, "di<v"], code: 5 },
57 { args: [null, "-div"], code: 5 },
58 { args: [null, ".div"], code: 5 },
59 { args: ["http://example.com/", "<div>"], code: 5 },
60 { args: ["http://example.com/", "0div"], code: 5 },
61 { args: ["http://example.com/", "di<v"], code: 5 },
62 { args: ["http://example.com/", "-div"], code: 5 },
63 { args: ["http://example.com/", ".div"], code: 5 },
64 { args: [null, ":div"], code: 14 },
65 { args: [null, "div:"], code: 14 },
66 { args: ["http://example.com/", ":div"], code: 14 },
67 { args: ["http://example.com/", "div:"], code: 14 },
68 { args: [null, "d:iv"], code: 14 },
69 { args: [null, "a:b:c"], code: 14, message: "valid XML name, invalid QName" } ,
70 { args: ["http://example.com/", "a:b:c"], code: 14, message: "valid XML name, invalid QName" },
71 { args: [null, "a::c"], code: 14, message: "valid XML name, invalid QName" },
72 { args: ["http://example.com/", "a::c"], code: 14, message: "valid XML name, invalid QName" },
73 { args: ["http://example.com/", "a:0"], code: 5, message: "valid XML name, no t a valid QName" },
74 { args: ["http://example.com/", "0:a"], code: 5, message: "0 at start makes i t not a valid XML name" },
75 { args: ["http://example.com/", "a:_"] },
76 { args: ["http://example.com/", "a:\u0BC6"], code: 14,
77 message: "non-ASCII character after colon is CombiningChar, which is " +
78 "NCNameChar but not (Letter | \"_\") so invalid at start of " +
79 "NCName (but still a valid XML name, hence not INVALID_CHARACTER_E RR)" },
80 { args: ["http://example.com/", "\u0BC6:a"], code: 5,
81 message: "non-ASCII character after colon is CombiningChar, which is " +
82 "NCNameChar but not (Letter | \"_\") so invalid at start of " +
83 "NCName (Gecko chooses to throw NAMESPACE_ERR here, but either is valid " +
84 "as this is both an invalid XML name and an invalid QName)" },
85 { args: ["http://example.com/", "a:a\u0BC6"] },
86 { args: ["http://example.com/", "a\u0BC6:a"] },
87 { args: ["http://example.com/", "xml:test"], code: 14, message: "binding xml prefix wrong" },
88 { args: ["http://example.com/", "xmlns:test"], code: 14, message: "binding xm lns prefix wrong" },
89 { args: ["http://www.w3.org/2000/xmlns/", "x:test"], code: 14, message: "bind ing namespace namespace to wrong prefix" },
90 { args: ["http://www.w3.org/2000/xmlns/", "xmlns:test"] },
91 { args: ["http://www.w3.org/XML/1998/namespace", "xml:test"] },
92 { args: ["http://www.w3.org/XML/1998/namespace", "x:test"] },
93 { args: ["http://www.w3.org/2000/xmlns/", "xmlns"] }, // See http://www.w3.or g/2000/xmlns/
94 { args: ["http://example.com/", "xmlns"], code: 14 }, // from the createAttri buteNS section
95 ];
96
97 function sourceify(v)
98 {
99 switch (typeof v) {
100 case "undefined":
101 return v;
102
103 case "string":
104 return '"' + v.replace('"', '\\"') + '"';
105
106 default:
107 return String(v);
108 }
109 }
110
111 function runNSTests()
112 {
113 var createFunction = document.createAttributeNS;
114 var createFunctionName = "createAttributeNS";
115 var doc = document;
116
117 for (var i = 0, sz = allNSTests.length; i < sz; i++) {
118 var test = allNSTests[i];
119
120 var code = -1;
121 var argStr = sourceify(test.args[0]) + ", " + sourceify(test.args[1]);
122 var msg = createFunctionName + "(" + argStr + ")";
123 if ("message" in test)
124 msg += "; " + test.message;
125 try {
126 createFunction.apply(doc, test.args);
127 assert(!("code" in test), msg);
128 } catch (e) {
129 assertExceptionCode(e, test.code || "expected no exception", msg);
130 }
131 }
132 }
133
134 runNSTests();
135 </script>
8 </body> 136 </body>
9 </html> 137 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698