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

Unified Diff: LayoutTests/fast/dom/xmlserializer-serialize-to-string-exception.html

Issue 23532055: XMLSerializer.serializeToString() should throw exception for invalid node value. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/xmlserializer-serialize-to-string-exception-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/xmlserializer-serialize-to-string-exception.html
diff --git a/LayoutTests/fast/dom/xmlserializer-serialize-to-string-exception.html b/LayoutTests/fast/dom/xmlserializer-serialize-to-string-exception.html
new file mode 100644
index 0000000000000000000000000000000000000000..88d0168963351dc3a3dce4e1951206d1d74f12a1
--- /dev/null
+++ b/LayoutTests/fast/dom/xmlserializer-serialize-to-string-exception.html
@@ -0,0 +1,105 @@
+<html>
+<head>
+<style>
+.failed {
+ color: red;
+ font-weight: bold;
+}
+
+.passed {
+ color: green;
+ font-weight: bold;
+}
+</style>
+<script>
+if (window.testRunner)
+ window.testRunner.dumpAsText();
+var count = 0;
+
+function shouldThrowException(node)
+{
+ document.body.appendChild(document.createElement("br"));
+ var header = document.createElement("div");
+ header.textContent = ++count + ". Verifying XMLSerializer.serializeToString() should THROW exception with node value = " + node;
+ document.body.appendChild(header);
+
+ var xs = new XMLSerializer();
+ try {
+ var str = xs.serializeToString(node);
+
+ var result = document.createElement("div");
+ result.className = "failed"
+ result.textContent = "FAIL";
+ document.body.appendChild(result);
+ } catch (exception) {
+ var err = "Exception thrown = [" + exception.name + ": " + exception.message + "]";
+ var content = document.createElement("div");
+ content.textContent = err;
+ document.body.appendChild(content);
+
+ var result = document.createElement("div");
+ result.className = "passed"
+ result.textContent = "PASS";
+ document.body.appendChild(result);
+ }
+}
+
+function shouldNOTThrowException(node)
+{
+ document.body.appendChild(document.createElement("br"));
+ var header = document.createElement("div");
+ header.textContent = ++count + ". Verifying XMLSerializer.serializeToString() should NOT-THROW exception with node value = " + node;
+ document.body.appendChild(header);
+
+ var xs = new XMLSerializer();
+ try {
+ var str = xs.serializeToString(node);
+
+ var result = document.createElement("div");
+ result.className = "passed"
+ result.textContent = "PASS";
+ document.body.appendChild(result);
+ } catch (exception) {
+ var err = "Exception thrown = [" + exception.name + ": " + exception.message + "]";
+ var content = document.createElement("div");
+ content.textContent = err;
+ document.body.appendChild(content);
+
+ var result = document.createElement("div");
+ result.className = "failed"
+ result.textContent = "FAIL";
+ document.body.appendChild(result);
+ }
+}
+
+function runTest()
+{
+ shouldThrowException(null);
+ shouldThrowException(undefined);
+ shouldThrowException("<html><title>Hello World</title></html>");
+ shouldThrowException(document.children);
+
+ shouldNOTThrowException(document);
+ shouldNOTThrowException(document.documentElement);
+ shouldNOTThrowException(document.firstChild);
+ shouldNOTThrowException(document.createElement("div"));
+ shouldNOTThrowException(document.getElementById("heading"));
+ shouldNOTThrowException(document.createElement("custom"));
+
+ var domParser = new DOMParser();
+
+ var htmlDoc = domParser.parseFromString("<html/>", "text/html");
+ shouldNOTThrowException(htmlDoc);
+ shouldNOTThrowException(htmlDoc.firstChild);
+
+ var xmlDoc = domParser.parseFromString("<root/>", "text/xml");
+ shouldNOTThrowException(xmlDoc);
+ shouldNOTThrowException(xmlDoc.lastChild);
+}
+</script>
+</head>
+<body onload="runTest();">
+This tests XMLSerializer.serializeToString() throwing exception when node value is invalid and passing otherwise.
+<h1 id="heading"/>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/dom/xmlserializer-serialize-to-string-exception-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698