Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <?xml version="1.0"?>
2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
3 <window title="Mozilla Bug 481777 subwindow"
4 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
5 onload="runTests()">
7 <iframe type="content" id="html1" src="data:text/html,<html><head><title id='t'>Test</title></head></html>"/>
8 <iframe type="content" id="html2" src="data:text/html,<html><head><title id='t'>Test</title><title>Foo</title></head></html>"/>
9 <iframe type="content" id="html3" src="data:text/html,<html></html>"/>
10 <iframe type="content" id="xhtml1" src="data:text/xml,<html xmlns='http://www.w3.org/1999/xhtml'><body><title id='t'>Test</title></body></html>"/>
11 <iframe type="content" id="xhtml2" src="data:text/xml,<title xmlns='http://www.w3.org/1999/xhtml'>Test</title>"/>
12 <iframe type="content" id="xhtml3" src="data:text/xml,<title xmlns='http://www.w3.org/1999/xhtml'>Te<div>bogus</div>st</title>"/>
13 <iframe type="content" id="xhtml4" src="data:text/xml,<html xmlns='http://www.w3.org/1999/xhtml'/>"/>
14 <iframe type="content" id="xhtml5" src="data:text/xml,<html xmlns='http://www.w3.org/1999/xhtml'><head/></html>"/>
15 <iframe type="content" id="xhtml6" src="data:text/xml,<html xmlns='http://www.w3.org/1999/xhtml'><head><style/></head></html>"/>
16 <iframe id="xul1" src="data:application/vnd.mozilla.xul+xml,<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' title='Test'/>"/>
17 <iframe id="xul2" src="data:application/vnd.mozilla.xul+xml,<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' title='Test'/>"/>
18 <iframe type="content" id="svg1" src="data:text/xml,<svg xmlns='http://www.w3.org/2000/svg'><title id='t'>Test</title></svg>"/>
19 <iframe type="content" id="svg2" src="data:text/xml,<svg xmlns='http://www.w3.org/2000/svg'><title id='t'>Test</title></svg>"/>
21 <script type="application/javascript">
22 <![CDATA[
23 var imports = [ "SimpleTest", "is", "isnot", "ok" ];
24 for each (var name in imports) {
25 window[name] = window.opener.wrappedJSObject[name];
26 }
28 function testStatics() {
29 function testStatic(id, expect, description) {
30 is(document.getElementById(id).contentDocument.title, expect, description);
31 }
33 testStatic("html1", "Test", "HTML <title>");
34 testStatic("html2", "Test", "choose the first HTML <title>");
35 testStatic("html3", "", "No title");
36 testStatic("xhtml1", "Test", "XHTML <title> in body");
37 testStatic("xhtml2", "Test", "XHTML <title> as root element");
38 testStatic("xhtml3", "Test", "XHTML <title> containing an element");
39 testStatic("xul1", "Test", "XUL <window> title attribute");
40 testStatic("svg1", "Test", "SVG <title>");
42 // This one does nothing and won't fire an event
43 document.getElementById("xhtml4").contentDocument.title = "Hello";
44 is(document.getElementById("xhtml4").contentDocument.title, "", "Setting 'title' does nothing with no <head>");
45 }
47 function testDynamics() {
48 var inProgress = {};
49 var inProgressDoc = {};
50 var inProgressWin = {};
51 function testDynamic(id, expect, description, op, checkDOM) {
52 inProgress[description] = true;
53 inProgressDoc[description] = true;
54 inProgressWin[description] = true;
55 var frame = document.getElementById(id);
56 var done = false;
58 function listener(ev) {
59 inProgress[description] = false;
60 is(frame.contentDocument.title, expect, "'title': " + description);
61 is(frame.contentDocument, ev.target, "Unexpected target: " + description);
62 if (typeof(checkDOM) != "undefined") {
63 checkDOM(frame.contentDocument, "DOM: " + description);
64 }
65 }
67 function listener2(ev) {
68 inProgressDoc[description] = false;
69 }
70 function listener3(ev) {
71 inProgressWin[description] = false;
72 }
73 frame.addEventListener("DOMTitleChanged", listener, false);
74 frame.contentDocument.addEventListener("DOMTitleChanged", listener2, false);
75 frame.contentWindow.addEventListener("DOMTitleChanged", listener3, false);
77 op(frame.contentDocument);
78 }
80 var dynamicTests = [
81 [ "html1", "Hello", "Setting HTML <title> text contents",
82 function(doc){
83 var t = doc.getElementById("t"); t.textContent = "Hello";
84 } ],
85 [ "html2", "Foo", "Removing HTML <title>",
86 function(doc){
87 var t = doc.getElementById("t"); t.parentNode.removeChild(t);
88 } ],
89 [ "html3", "Hello", "Appending HTML <title> element to root element",
90 function(doc){
91 var t = doc.createElement("title"); t.textContent = "Hello"; doc.documentElement.appendChild(t);
92 } ],
93 [ "xhtml3", "Hello", "Setting 'title' clears existing <title> contents",
94 function(doc){
95 doc.title = "Hello";
96 },
97 function(doc, desc) {
98 is(doc.documentElement.firstChild.data, "Hello", desc);
99 is(doc.documentElement.firstChild.nextSibling, null, desc);
100 } ],
101 [ "xhtml5", "Hello", "Setting 'title' works with a <head>",
102 function(doc){
103 doc.title = "Hello";
104 },
105 function(doc, desc) {
106 var head = doc.documentElement.firstChild;
107 var title = head.firstChild;
108 is(title.tagName.toLowerCase(), "title", desc);
109 is(title.firstChild.data, "Hello", desc);
110 is(title.firstChild.nextSibling, null, desc);
111 is(title.nextSibling, null, desc);
112 } ],
113 [ "xhtml6", "Hello", "Setting 'title' appends to <head>",
114 function(doc){
115 doc.title = "Hello";
116 },
117 function(doc, desc) {
118 var head = doc.documentElement.firstChild;
119 is(head.firstChild.tagName.toLowerCase(), "style", desc);
120 var title = head.firstChild.nextSibling;
121 is(title.tagName.toLowerCase(), "title", desc);
122 is(title.firstChild.data, "Hello", desc);
123 is(title.firstChild.nextSibling, null, desc);
124 is(title.nextSibling, null, desc);
125 } ],
126 [ "xul1", "Hello", "Setting XUL <window> title attribute",
127 function(doc){
128 doc.documentElement.setAttribute("title", "Hello");
129 } ],
130 [ "xul2", "Hello", "Setting 'title' in XUL",
131 function(doc){
132 doc.title = "Hello";
133 },
134 function(doc, desc) {
135 is(doc.documentElement.getAttribute("title"), "Hello", desc);
136 is(doc.documentElement.firstChild, null, desc);
137 } ],
138 [ "svg1", "Hello", "Setting SVG <title> text contents",
139 function(doc){
140 var t = doc.getElementById("t"); t.textContent = "Hello";
141 } ],
142 [ "svg2", "", "Removing SVG <title>",
143 function(doc){
144 var t = doc.getElementById("t"); t.parentNode.removeChild(t);
145 } ] ];
147 var titleWindow = window;
149 function runIndividualTest(i) {
150 if (i == dynamicTests.length) {
151 // Closing the window will nuke the global properties, since this
152 // function is not really running on this window... or something
153 // like that. Thanks, executeSoon!
154 var tester = SimpleTest;
155 window.close();
156 tester.finish();
157 } else {
158 var parameters = dynamicTests[i];
159 var testElementId = parameters[0];
160 var testExpectedValue = parameters[1];
161 var testDescription = parameters[2];
162 var testOp = parameters[3];
163 var testCheckDOM = parameters[4];
165 function checkTest() {
166 ok(!inProgress[testDescription],
167 testDescription + ": DOMTitleChange not fired");
168 ok(inProgressDoc[testDescription],
169 testDescription + ": DOMTitleChange fired on content document");
170 ok(inProgressWin[testDescription],
171 testDescription + ": DOMTitleChange fired on content window");
172 // Run the next test in the context of the parent XUL window.
173 titleWindow.setTimeout(runIndividualTest, 0, i+1);
174 }
175 function spinEventLoopOp(doc) {
176 // Perform the test's operations.
177 testOp(doc);
178 // Spin the associated window's event loop to ensure we
179 // drain any asynchronous changes and fire associated
180 // events.
181 doc.defaultView.setTimeout(checkTest, 0);
182 }
184 testDynamic(testElementId, testExpectedValue, testDescription,
185 spinEventLoopOp, testCheckDOM);
186 }
187 }
189 window.setTimeout(runIndividualTest, 0, 0);
190 }
192 function runTests() {
193 testStatics();
194 testDynamics();
195 }
196 ]]>
197 </script>
198 </window>