Bug 457825 - Support access control headers when downloading fonts. r=jonas,dbaron...
[wine-gecko.git] / testing / mochitest / tests / test_bug352728.xhtml
blobf6676c8af36e286c45f2716eb1ac84e486e48474
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <!--
3 https://bugzilla.mozilla.org/show_bug.cgi?id=352728
4 -->
5 <head>
6 <title>Test for Bug 352728</title>
7 <script type="text/javascript" src="/MochiKit/packed.js"></script>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=352728">Mozilla Bug 352728</a>
13 <p id="display"></p>
14 <div id="content" style="display: none">
16 </div>
17 <pre id="test">
18 <!-- First make sure that a script consisting of multiple CDATA sections is
19 even supported -->
20 <script class="testbody" type="text/javascript">
21 var cdataTest1 = false;
22 var cdataTest2 = false;
23 var cdataTest3 = false;
24 </script>
26 <script class="testbody" type="text/javascript">
27 <![CDATA[
28 cdataTest1 = true;
29 ]]>
30 cdataTest2 = true;
31 <![CDATA[
32 cdataTest3 = true;
33 ]]>
34 </script>
36 <script class="testbody" type="text/javascript">
37 is(cdataTest1, true, "Check first CDATA section");
38 is(cdataTest2, true, "Check in between CDATA sections");
39 is(cdataTest3, true, "Check second CDATA section");
40 </script>
42 <script class="testbody" type="text/javascript">
43 <![CDATA[
45 /** Test for Bug 352728 **/
46 function checkTypes(aNode, aNodeType, aTypeArray)
48 for (var i = 0; i < aTypeArray.length; ++i) {
49 ok(aNode instanceof aTypeArray[i], aNodeType + " type test " + i,
50 aNodeType + " should be a " + aTypeArray[i]);
54 function checkInterfaces(aNode, aNodeType, aInterfaceArray)
56 for (var i = 0; i < aInterfaceArray.length; ++i) {
57 ok(aNode instanceof Components.interfaces[aInterfaceArray[i]],
58 aNodeType + " interface test " + i,
59 aNodeType + " should be a " + aInterfaceArray[i]);
63 function testCharacterData(aNode, aText)
65 is(aNode.length, aText.length, "Text length should match");
66 is(aNode.data, aText, "Text content should match");
67 is(aNode.nodeValue, aText, "Check nodeValue");
68 is(aNode.localName, null, "Check localName")
69 is(aNode.namespaceURI, null, "Check namespaceURI");
72 function testComment(aText, aShouldSucceed)
74 try {
75 var comment = document.createComment(aText);
76 var types = [ Comment, CharacterData, Node ];
77 checkTypes(comment, "comment", types);
79 var interfaces = [ "nsIDOMComment", "nsIDOMCharacterData", "nsIDOMNode",
80 "nsIDOM3Node", "nsIDOMEventTarget" ];
81 checkInterfaces(comment, "comment", interfaces);
83 testCharacterData(comment, aText);
84 is(comment.nodeName, "#comment", "Check nodeName");
85 is(comment.nodeType, Node.COMMENT_NODE, "Check nodeType");
87 if (!aShouldSucceed) {
88 ok(0, "Invalid comment creation",
89 "Shouldn't create comment with embedded \"--\"");
91 } catch (e) {
92 if (aShouldSucceed) {
93 ok(0, "Correct functioning of comment stuff", "something broke: " + e);
94 } else {
95 is(e.code, DOMException.INVALID_CHARACTER_ERR, "Check exception code");
100 function testCDATASection(aText, aShouldSucceed)
102 try {
103 var cdataSection = document.createCDATASection(aText);
104 var types = [ CDATASection, CharacterData, Node ];
105 checkTypes(cdataSection, "CDATA section", types);
107 var interfaces = [ "nsIDOMCDATASection", "nsIDOMCharacterData",
108 "nsIDOMNode", "nsIDOM3Node", "nsIDOMEventTarget" ];
109 checkInterfaces(cdataSection, "CDATA section", interfaces);
111 testCharacterData(cdataSection, aText);
112 is(cdataSection.nodeName, "#cdata-section", "Check nodeName");
113 is(cdataSection.nodeType, Node.CDATA_SECTION_NODE, "Check nodeType");
115 if (!aShouldSucceed) {
116 ok(0, "Invalid CDATA section creation",
118 "Shouldn't create CDATA section with embedded \"]]&gt;\"");
119 <![CDATA[
121 } catch (e) {
122 if (aShouldSucceed) {
123 ok(0, "Correct functioning of CDATA section stuff",
124 "something broke: " + e);
125 } else {
126 is(e.code, DOMException.INVALID_CHARACTER_ERR, "Check exception code");
131 function testPI(aTarget, aData, aShouldSucceed, aReason)
133 try {
134 var pi = document.createProcessingInstruction(aTarget, aData);
135 var types = [ ProcessingInstruction, Node ];
136 checkTypes(pi, "processing instruction", types);
138 var interfaces = [ "nsIDOMProcessingInstruction", "nsIDOMNode",
139 "nsIDOM3Node", "nsIDOMEventTarget" ];
140 checkInterfaces(pi, "processing instruction", interfaces);
142 is(pi.target, aTarget, "Check target");
143 is(pi.data, aData, "Check data");
144 is(pi.nodeName, aTarget, "Check nodeName");
145 is(pi.nodeValue, aData, "Check nodeValue");
146 is(pi.localName, null, "Check localName")
147 is(pi.namespaceURI, null, "Check namespaceURI");
149 is(pi.nodeType, Node.PROCESSING_INSTRUCTION_NODE, "Check nodeType");
151 if (!aShouldSucceed) {
152 ok(0, "Invalid processing instruction creation", aReason);
154 } catch (e) {
155 if (aShouldSucceed) {
156 ok(0, "Correct functioning of processing instruction stuff",
157 "something broke: " + e);
158 } else {
159 is(e.code, DOMException.INVALID_CHARACTER_ERR, "Check exception code");
164 testComment("Some text", true);
165 testComment("Some text with a '-' in it", true);
166 testComment("Some text with a '-' and a '-' and another '-'", true);
167 testComment("Some text -- this shouldn't create a node!", false);
168 testComment("<!-- This is an HTML comment -->", false);
170 testCDATASection("Some text", true);
171 testCDATASection("Some text with a '?' in it", true);
172 testCDATASection("Some text with a '>' in it", true);
173 testCDATASection("Some text with a '?' and a '>' in it", true);
174 testCDATASection("Some text with a '? >' in it", true);
175 testCDATASection("Some text -- ?> this should be ok", true);
177 testCDATASection("Some text ]]&gt; this should not create a node!", false);
179 <![CDATA[
181 testPI("foo", "bar", true);
182 testPI("foo:bar", "baz", true);
183 testPI("foo", "bar?", true);
184 testPI("foo", "bar>", true);
185 testPI("foo", "bar? >", true);
186 testPI("<aaa", "bar", false, "Target should not contain '<'");
187 testPI("aaa>", "bar", false, "Target should not contain '>'");
188 testPI("aa?", "bar", false, "Target should not contain '?'");
189 testPI("foo", "bar?>", false, "Data should not contain '?>'");
191 </script>
192 </pre>
193 </body>
194 </html>