b=450088 backing out (new reftest failed)
[wine-gecko.git] / testing / mochitest / tests / test_bug352728.html
blob06354fab4cc36bbb8f937e7957de5749f32c1c97
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=352728
5 -->
6 <head>
7 <title>Test for Bug 352728</title>
8 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=352728">Mozilla Bug 352728</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
17 </div>
18 <pre id="test">
19 <script class="testbody" type="text/javascript">
20 /** Test for Bug 352728 **/
22 function checkTypes(aNode, aNodeType, aTypeArray)
24 for (var i = 0; i < aTypeArray.length; ++i) {
25 ok(aNode instanceof aTypeArray[i], aNodeType + " type test " + i,
26 aNodeType + " should be a " + aTypeArray[i]);
30 function checkInterfaces(aNode, aNodeType, aInterfaceArray)
32 for (var i = 0; i < aInterfaceArray.length; ++i) {
33 ok(aNode instanceof Components.interfaces[aInterfaceArray[i]],
34 aNodeType + " interface test " + i,
35 aNodeType + " should be a " + aInterfaceArray[i]);
39 function testCharacterData(aNode, aText)
41 is(aNode.length, aText.length, "Text length should match");
42 is(aNode.data, aText, "Text content should match");
43 is(aNode.nodeValue, aText, "Check nodeValue");
44 is(aNode.localName, null, "Check localName")
45 is(aNode.namespaceURI, null, "Check namespaceURI");
48 function testComment(aText, aShouldSucceed)
50 try {
51 var comment = document.createComment(aText);
52 var types = [ Comment, CharacterData, Node ];
53 checkTypes(comment, "comment", types);
55 var interfaces = [ "nsIDOMComment", "nsIDOMCharacterData", "nsIDOMNode",
56 "nsIDOM3Node", "nsIDOMEventTarget" ];
57 checkInterfaces(comment, "comment", interfaces);
59 testCharacterData(comment, aText);
60 is(comment.nodeName, "#comment", "Check nodeName");
61 is(comment.nodeType, Node.COMMENT_NODE, "Check nodeType");
63 if (!aShouldSucceed) {
64 ok(0, "Invalid comment creation",
65 "Shouldn't create comment with embedded \"--\"");
67 } catch (e) {
68 if (aShouldSucceed) {
69 ok(0, "Correct functioning of comment stuff", "something broke: " + e);
70 } else {
71 is(e.code, DOMException.INVALID_CHARACTER_ERR, "Check exception code");
76 function testCDATASection(aText, aShouldSucceed)
78 try {
79 var cdataSection = document.createCDATASection(aText);
80 ok(0, "Invalid CDATA section creation",
81 "Shouldn't create CDATA sections in HTML");
82 } catch (e) {
83 is(e.code, DOMException.NOT_SUPPORTED_ERR, "Check exception code");
87 function testPI(aTarget, aData, aShouldSucceed, aReason)
89 try {
90 var pi = document.createProcessingInstruction(aTarget, aData);
91 ok(0, "Invalid processing instruction creation",
92 "Shouldn't create processing instructions in HTML");
93 } catch (e) {
94 is(e.code, DOMException.NOT_SUPPORTED_ERR, "Check exception code");
98 testComment("Some text", true);
99 testComment("Some text with a '-' in it", true);
100 testComment("Some text with a '-' and a '-' and another '-'", true);
101 testComment("Some text -- this shouldn't create a node!", false);
102 testComment("<!-- This is an HTML comment -->", false);
104 testCDATASection("Some text", true);
105 testCDATASection("Some text with a '?' in it", true);
106 testCDATASection("Some text with a '>' in it", true);
107 testCDATASection("Some text with a '?' and a '>' in it", true);
108 testCDATASection("Some text with a '? >' in it", true);
109 testCDATASection("Some text -- ?> this should be ok", true);
110 testCDATASection("Some text ]]&gt; this should not create a node!", false);
112 testPI("foo", "bar", true);
113 testPI("foo:bar", "baz", true);
114 testPI("foo", "bar?", true);
115 testPI("foo", "bar>", true);
116 testPI("foo", "bar? >", true);
117 testPI("<aaa", "bar", false, "Target should not contain '<'");
118 testPI("aaa>", "bar", false, "Target should not contain '>'");
119 testPI("aa?", "bar", false, "Target should not contain '?'");
120 testPI("foo", "bar?>", false, "Data should not contain '?>'");
121 </script>
122 </pre>
123 </body>
124 </html>