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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/xmlserializer-serialize-to-string-exception.html

Issue 2667303004: Move tests for DOMParser and XMLSerializer to dom/domparsing/. (Closed)
Patch Set: Created 3 years, 10 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
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 " + (arguments.length ? "argument " + node : "no a rgument");
24 document.body.appendChild(header);
25
26 var xs = new XMLSerializer();
27 try {
28 var str = xs.serializeToString.apply(xs, arguments);
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 argument " + 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();
78 shouldThrowException(null);
79 shouldThrowException(undefined);
80 shouldThrowException("<html><title>Hello World</title></html>");
81 shouldThrowException(document.children);
82
83 shouldNOTThrowException(document);
84 shouldNOTThrowException(document.documentElement);
85 shouldNOTThrowException(document.firstChild);
86 shouldNOTThrowException(document.createElement("div"));
87 shouldNOTThrowException(document.getElementById("heading"));
88 shouldNOTThrowException(document.createElement("custom"));
89
90 var domParser = new DOMParser();
91
92 var htmlDoc = domParser.parseFromString("<html/>", "text/html");
93 shouldNOTThrowException(htmlDoc);
94 shouldNOTThrowException(htmlDoc.firstChild);
95
96 var xmlDoc = domParser.parseFromString("<root/>", "text/xml");
97 shouldNOTThrowException(xmlDoc);
98 shouldNOTThrowException(xmlDoc.lastChild);
99 }
100 </script>
101 </head>
102 <body onload="runTest();">
103 This tests XMLSerializer.serializeToString() throwing exception when node value is invalid and passing otherwise.
104 <h1 id="heading"/>
105 </body>
106 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698