Chromium Code Reviews| Index: LayoutTests/fast/dom/Document/createCDATASection.html |
| diff --git a/LayoutTests/fast/dom/Document/createCDATASection.html b/LayoutTests/fast/dom/Document/createCDATASection.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..85a8f0ac880c5eeda09ddda5807780f04806c0e4 |
| --- /dev/null |
| +++ b/LayoutTests/fast/dom/Document/createCDATASection.html |
| @@ -0,0 +1,55 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<script src="../../js/resources/js-test-pre.js"></script> |
| +</head> |
| +<body> |
| +<script> |
| +function assert(c, msg) { |
| +if (c) |
| + testPassed(msg); |
| +else |
| + testFailed(msg) |
| +} |
| +var domParser = new DOMParser(); |
| +var xmlDoc = domParser.parseFromString("<example></example>", "text/xml"); |
| +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
|
| +testData = [ |
| + { arg: "Hello" }, |
| + { arg: "Ha]]>o", code: 5 }, |
| + { arg: null }, |
| + { arg: new Date(1234567890) }, |
| + { arg: 42 }, |
| + { arg: "" } |
| +]; |
| + |
| +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
|
| + arg = testData[i].arg; |
| + if (typeof arg == "string") |
| + msg = "createCDATASection('" + arg + "')"; |
| + else if (arg instanceof Date) |
| + msg = "createCDATASection(<Date>)"; |
| + else |
| + msg = "createCDATASection(" + arg + ")"; |
| + try { |
| + res = xmlDoc.createCDATASection(arg); |
| + 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
|
| + testFailed(msg + ": expected exception"); |
| + else |
| + assert(res && res.textContent == String(arg), msg); |
| + } catch(e) { |
| + if ("code" in testData[i]) { |
| + if (e.code == testData[i].code) |
| + testPassed(msg) |
| + else |
| + testFailed(msg + "; expected exception " + testData[i].code + |
| + ", got " + e.code) |
| + } else { |
| + testFailed(msg) |
| + } |
| + } |
| +} |
| +</script> |
| +<script src="../../js/resources/js-test-post.js"></script> |
| +</body> |
| +</html> |