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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <html>
2 <head>
3 <style>
4 .failed {
5 color: red;
6 font-weight: bold;
7 }
8
9 .passed {
10 color: green;
11 font-weight: bold;
12 }
13 </style>
14 <script>
15 if (window.testRunner)
16 window.testRunner.dumpAsText();
17 var count = 0;
18
19 function shouldThrowException(node)
20 {
21 document.body.appendChild(document.createElement("br"));
22 var header = document.createElement("div");
23 header.textContent = ++count + ". Verifying XMLSerializer.serializeToString( ) should THROW exception with node value = " + node;
24 document.body.appendChild(header);
25
26 var xs = new XMLSerializer();
27 try {
28 var str = xs.serializeToString(node);
29
30 var result = document.createElement("div");
31 result.className = "failed"
32 result.textContent = "FAIL";
33 document.body.appendChild(result);
34 } catch (exception) {
35 var err = "Exception thrown = [" + exception.name + ": " + exception.mes sage + "]";
36 var content = document.createElement("div");
37 content.textContent = err;
38 document.body.appendChild(content);
39
40 var result = document.createElement("div");
41 result.className = "passed"
42 result.textContent = "PASS";
43 document.body.appendChild(result);
44 }
45 }
46
47 function shouldNOTThrowException(node)
48 {
49 document.body.appendChild(document.createElement("br"));
50 var header = document.createElement("div");
51 header.textContent = ++count + ". Verifying XMLSerializer.serializeToString( ) should NOT-THROW exception with node value = " + node;
52 document.body.appendChild(header);
53
54 var xs = new XMLSerializer();
55 try {
56 var str = xs.serializeToString(node);
57
58 var result = document.createElement("div");
59 result.className = "passed"
60 result.textContent = "PASS";
61 document.body.appendChild(result);
62 } catch (exception) {
63 var err = "Exception thrown = [" + exception.name + ": " + exception.mes sage + "]";
64 var content = document.createElement("div");
65 content.textContent = err;
66 document.body.appendChild(content);
67
68 var result = document.createElement("div");
69 result.className = "failed"
70 result.textContent = "FAIL";
71 document.body.appendChild(result);
72 }
73 }
74
75 function runTest()
76 {
77 shouldThrowException(null);
78 shouldThrowException(undefined);
79 shouldThrowException("<html><title>Hello World</title></html>");
80 shouldThrowException(document.children);
81
82 shouldNOTThrowException(document);
83 shouldNOTThrowException(document.documentElement);
84 shouldNOTThrowException(document.firstChild);
85 shouldNOTThrowException(document.createElement("div"));
86 shouldNOTThrowException(document.getElementById("heading"));
87 shouldNOTThrowException(document.createElement("custom"));
88
89 var domParser = new DOMParser();
90
91 var htmlDoc = domParser.parseFromString("<html/>", "text/html");
92 shouldNOTThrowException(htmlDoc);
93 shouldNOTThrowException(htmlDoc.firstChild);
94
95 var xmlDoc = domParser.parseFromString("<root/>", "text/xml");
96 shouldNOTThrowException(xmlDoc);
97 shouldNOTThrowException(xmlDoc.lastChild);
98 }
99 </script>
100 </head>
101 <body onload="runTest();">
102 This tests XMLSerializer.serializeToString() throwing exception when node value is invalid and passing otherwise.
103 <h1 id="heading"/>
104 </body>
105 </html>
OLDNEW
« 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