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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Document/createElementNS-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/createElementNS-namespace-err.js"></script> 7 <script>
8 description("createElementNS tests from mozilla, 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 ];
94
95 var allNoNSTests = [
96 { args: [undefined] },
97 { args: [null] },
98 { args: [""], code: 5 },
99 { args: ["<div>"], code: 5 },
100 { args: ["0div"], code: 5 },
101 { args: ["di v"], code: 5 },
102 { args: ["di<v"], code: 5 },
103 { args: ["-div"], code: 5 },
104 { args: [".div"], code: 5 },
105 { args: [":"], message: "valid XML name, invalid QName" },
106 { args: [":div"], message: "valid XML name, invalid QName" },
107 { args: ["div:"], message: "valid XML name, invalid QName" },
108 { args: ["d:iv"] },
109 { args: ["a:b:c"], message: "valid XML name, invalid QName" },
110 { args: ["a::c"], message: "valid XML name, invalid QName" },
111 { args: ["a::c:"], message: "valid XML name, invalid QName" },
112 { args: ["a:0"], message: "valid XML name, not a valid QName" },
113 { args: ["0:a"], code: 5, message: "0 at start makes it not a valid XML name" },
114 { args: ["a:_"] },
115 { args: ["a:\u0BC6"],
116 message: "non-ASCII character after colon is CombiningChar, which is " +
117 "valid in pre-namespace XML" },
118 { args: ["\u0BC6:a"], code: 5, message: "not a valid start character" },
119 { args: ["a:a\u0BC6"] },
120 { args: ["a\u0BC6:a"] },
121 { args: ["xml:test"] },
122 { args: ["xmlns:test"] },
123 { args: ["x:test"] },
124 { args: ["xmlns:test"] },
125 { args: ["SOAP-ENV:Body"] }, // From Yahoo Mail Beta
126 ];
127
128 function sourceify(v)
129 {
130 switch (typeof v) {
131 case "undefined":
132 return v;
133 case "string":
134 return '"' + v.replace('"', '\\"') + '"';
135 default:
136 return String(v);
137 }
138 }
139
140 function sourceifyArgs(args)
141 {
142 var copy = new Array(args.length);
143 for (var i = 0, sz = args.length; i < sz; i++)
144 copy[i] = sourceify(args[i]);
145
146 return copy.join(", ");
147 }
148
149 function runNSTests(tests, doc, createFunctionName)
150 {
151 for (var i = 0, sz = tests.length; i < sz; i++) {
152 var test = tests[i];
153
154 var code = -1;
155 var argStr = sourceifyArgs(test.args);
156 var msg = createFunctionName + "(" + argStr + ")";
157 if ("message" in test)
158 msg += "; " + test.message;
159 try {
160 doc[createFunctionName].apply(doc, test.args);
161 assert(!("code" in test), msg);
162 } catch (e) {
163 assertExceptionCode(e, test.code || "expected no exception", msg);
164 }
165 }
166 }
167
168 debug("HTML tests:")
169 runNSTests(allNSTests, document, "createElementNS");
170 runNSTests(allNoNSTests, document, "createElement");
171
172 debug("XHTML createElement tests:")
173 var xhtmlDoc = document.implementation.createDocument("http://www.w3.org/1999/xh tml", "html", null);
174 runNSTests(allNoNSTests, xhtmlDoc, "createElement");
175
176 debug("XML createElement tests:")
177 var xmlDoc = document.implementation.createDocument("http://www.example.com/foo" , "example", null);
178 runNSTests(allNoNSTests, xmlDoc, "createElement");
179 </script>
8 </body> 180 </body>
9 </html> 181 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698