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

Side by Side Diff: sky/tests/lowlevel/createElement.html

Issue 685623002: Move the tests from .html to .sky (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sky/tests/lowlevel/camel-case.sky ('k') | sky/tests/lowlevel/createElement.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <test>
2 <link rel="import" href="../resources/chai.html" />
3 <link rel="import" href="../resources/mocha.html" />
4 <script>
5 describe('createElementNS tests from mozilla, attached to webkit bug 16833', fun ction() {
6 it('should behave like mozilla', function() {
7 function stringForExceptionCode(c)
8 {
9 var exceptionName;
10 switch(c) {
11 case DOMException.INVALID_CHARACTER_ERR:
12 exceptionName = "INVALID_CHARACTER_ERR";
13 break;
14 case DOMException.NAMESPACE_ERR:
15 exceptionName = "NAMESPACE_ERR";
16 }
17 if (exceptionName)
18 return exceptionName; // + "(" + c + ")";
19 return c;
20 }
21
22 function assertExceptionCode(exception, expect, m)
23 {
24 var actual = exception.code;
25 if (actual !== expect) {
26 m += "; expected " + stringForExceptionCode(expect) + ", threw " + s tringForExceptionCode(actual);
27 assert.ok(false, m);
28 } else {
29 m += "; threw " + exception.toString();
30 assert.ok(true, m);
31 }
32 }
33
34 var allNoNSTests = [
35 { args: [undefined] },
36 { args: [null] },
37 { args: [""], code: 5 },
38 { args: ["<div>"], code: 5 },
39 { args: ["0div"], code: 5 },
40 { args: ["di v"], code: 5 },
41 { args: ["di<v"], code: 5 },
42 { args: ["-div"], code: 5 },
43 { args: [".div"], code: 5 },
44 { args: [":"], message: "valid XML name, invalid QName" },
45 { args: [":div"], message: "valid XML name, invalid QName" },
46 { args: ["div:"], message: "valid XML name, invalid QName" },
47 { args: ["d:iv"] },
48 { args: ["a:b:c"], message: "valid XML name, invalid QName" },
49 { args: ["a::c"], message: "valid XML name, invalid QName" },
50 { args: ["a::c:"], message: "valid XML name, invalid QName" },
51 { args: ["a:0"], message: "valid XML name, not a valid QName" },
52 { args: ["0:a"], code: 5, message: "0 at start makes it not a valid XML n ame" },
53 { args: ["a:_"] },
54 { args: ["a:\u0BC6"],
55 message: "non-ASCII character after colon is CombiningChar, which is " +
56 "valid in pre-namespace XML" },
57 { args: ["\u0BC6:a"], code: 5, message: "not a valid start character" },
58 { args: ["a:a\u0BC6"] },
59 { args: ["a\u0BC6:a"] },
60 { args: ["xml:test"] },
61 { args: ["xmlns:test"] },
62 { args: ["x:test"] },
63 { args: ["xmlns:test"] },
64 { args: ["SOAP-ENV:Body"] }, // From Yahoo Mail Beta
65 ];
66
67 function sourceify(v)
68 {
69 switch (typeof v) {
70 case "undefined":
71 return v;
72 case "string":
73 return '"' + v.replace('"', '\\"') + '"';
74 default:
75 return String(v);
76 }
77 }
78
79 function sourceifyArgs(args)
80 {
81 var copy = new Array(args.length);
82 for (var i = 0, sz = args.length; i < sz; i++)
83 copy[i] = sourceify(args[i]);
84
85 return copy.join(", ");
86 }
87
88 function runNSTests(tests, doc, createFunctionName)
89 {
90 for (var i = 0, sz = tests.length; i < sz; i++) {
91 var test = tests[i];
92
93 var code = -1;
94 var argStr = sourceifyArgs(test.args);
95 var msg = createFunctionName + "(" + argStr + ")";
96 if ("message" in test)
97 msg += "; " + test.message;
98 try {
99 doc[createFunctionName].apply(doc, test.args);
100 assert(!("code" in test), msg);
101 } catch (e) {
102 assertExceptionCode(e, test.code || "expected no exception", msg );
103 }
104 }
105 }
106
107 var doc = document.implementation.createDocument();
108 runNSTests(allNoNSTests, doc, "createElement");
109 });
110 });
111 </script>
112 </test>
OLDNEW
« no previous file with comments | « sky/tests/lowlevel/camel-case.sky ('k') | sky/tests/lowlevel/createElement.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698