Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../js/resources/js-test-pre.js"></script> | |
| 5 </head> | |
| 6 <body> | |
| 7 <script> | |
| 8 function assert(c, msg) { | |
| 9 if (c) | |
| 10 testPassed(msg); | |
| 11 else | |
| 12 testFailed(msg) | |
| 13 } | |
| 14 var domParser = new DOMParser(); | |
| 15 var xmlDoc = domParser.parseFromString("<example></example>", "text/xml"); | |
| 16 assert("createCDATASection" in xmlDoc, "createCDATASection exists") | |
|
arv (Not doing code reviews)
2013/08/20 14:09:54
shouldBe('"createCDATASection" in xmlDoc', 'true')
Daniel Bratell
2013/08/20 15:37:58
Thanks! I have still a lot to learn about all the
| |
| 17 testData = [ | |
| 18 { arg: "Hello" }, | |
| 19 { arg: "Ha]]>o", code: 5 }, | |
| 20 { arg: null }, | |
| 21 { arg: new Date(1234567890) }, | |
| 22 { arg: 42 }, | |
| 23 { arg: "" } | |
| 24 ]; | |
| 25 | |
| 26 for (var i = 0; i < testData.length; i++) { | |
|
arv (Not doing code reviews)
2013/08/20 14:09:54
This test is overly complex.
shouldBeEqualToStrin
| |
| 27 arg = testData[i].arg; | |
| 28 if (typeof arg == "string") | |
| 29 msg = "createCDATASection('" + arg + "')"; | |
| 30 else if (arg instanceof Date) | |
| 31 msg = "createCDATASection(<Date>)"; | |
| 32 else | |
| 33 msg = "createCDATASection(" + arg + ")"; | |
| 34 try { | |
| 35 res = xmlDoc.createCDATASection(arg); | |
| 36 if ("code" in testData[i]) | |
|
arv (Not doing code reviews)
2013/08/20 14:09:54
Don't test the code. Test the whole string. See ab
| |
| 37 testFailed(msg + ": expected exception"); | |
| 38 else | |
| 39 assert(res && res.textContent == String(arg), msg); | |
| 40 } catch(e) { | |
| 41 if ("code" in testData[i]) { | |
| 42 if (e.code == testData[i].code) | |
| 43 testPassed(msg) | |
| 44 else | |
| 45 testFailed(msg + "; expected exception " + testData[i].code + | |
| 46 ", got " + e.code) | |
| 47 } else { | |
| 48 testFailed(msg) | |
| 49 } | |
| 50 } | |
| 51 } | |
| 52 </script> | |
| 53 <script src="../../js/resources/js-test-post.js"></script> | |
| 54 </body> | |
| 55 </html> | |
| OLD | NEW |