1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
/** Test for Bug 396843 **/
function testInDocument(doc, documentID) {
var allNodes = [];
var XMLNodes = [];
// HTML
function HTML_TAG(name) {
allNodes.push(doc.createElement(name));
}
/* List copy/pasted from nsHTMLTagList.h */
HTML_TAG("a", "Anchor")
HTML_TAG("abbr", "Span")
HTML_TAG("acronym", "Span")
HTML_TAG("address", "Span")
HTML_TAG("applet", "SharedObject")
HTML_TAG("area", "Area")
HTML_TAG("b", "Span")
HTML_TAG("base", "Shared")
HTML_TAG("basefont", "Span")
HTML_TAG("bdo", "Span")
HTML_TAG("bgsound", "Span")
HTML_TAG("big", "Span")
HTML_TAG("blockquote", "Shared")
HTML_TAG("body", "Body")
HTML_TAG("br", "BR")
HTML_TAG("button", "Button")
HTML_TAG("canvas", "Canvas")
HTML_TAG("caption", "TableCaption")
HTML_TAG("center", "Span")
HTML_TAG("cite", "Span")
HTML_TAG("code", "Span")
HTML_TAG("col", "TableCol")
HTML_TAG("colgroup", "TableCol")
HTML_TAG("dd", "Span")
HTML_TAG("del", "Mod")
HTML_TAG("dfn", "Span")
HTML_TAG("dir", "Shared")
HTML_TAG("div", "Div")
HTML_TAG("dl", "SharedList")
HTML_TAG("dt", "Span")
HTML_TAG("em", "Span")
HTML_TAG("embed", "SharedObject")
HTML_TAG("fieldset", "FieldSet")
HTML_TAG("font", "Font")
HTML_TAG("form", "Form")
HTML_TAG("frame", "Frame")
HTML_TAG("frameset", "FrameSet")
HTML_TAG("h1", "Heading")
HTML_TAG("h2", "Heading")
HTML_TAG("h3", "Heading")
HTML_TAG("h4", "Heading")
HTML_TAG("h5", "Heading")
HTML_TAG("h6", "Heading")
HTML_TAG("head", "Head")
HTML_TAG("hr", "HR")
HTML_TAG("html", "Html")
HTML_TAG("i", "Span")
HTML_TAG("iframe", "IFrame")
HTML_TAG("image", "")
HTML_TAG("img", "Image")
HTML_TAG("input", "Input")
HTML_TAG("ins", "Mod")
HTML_TAG("isindex", "Unknown")
HTML_TAG("kbd", "Span")
HTML_TAG("keygen", "Span")
HTML_TAG("label", "Label")
HTML_TAG("legend", "Legend")
HTML_TAG("li", "LI")
HTML_TAG("link", "Link")
HTML_TAG("listing", "Span")
HTML_TAG("map", "Map")
HTML_TAG("marquee", "Div")
HTML_TAG("menu", "Shared")
HTML_TAG("meta", "Meta")
HTML_TAG("multicol", "Unknown")
HTML_TAG("nobr", "Span")
HTML_TAG("noembed", "Div")
HTML_TAG("noframes", "Div")
HTML_TAG("noscript", "Div")
HTML_TAG("object", "Object")
HTML_TAG("ol", "SharedList")
HTML_TAG("optgroup", "OptGroup")
HTML_TAG("option", "Option")
HTML_TAG("p", "Paragraph")
HTML_TAG("param", "Shared")
HTML_TAG("plaintext", "Span")
HTML_TAG("pre", "Pre")
HTML_TAG("q", "Shared")
HTML_TAG("s", "Span")
HTML_TAG("samp", "Span")
HTML_TAG("script", "Script")
HTML_TAG("select", "Select")
HTML_TAG("small", "Span")
HTML_TAG("spacer", "Unknown")
HTML_TAG("span", "Span")
HTML_TAG("strike", "Span")
HTML_TAG("strong", "Span")
HTML_TAG("style", "Style")
HTML_TAG("sub", "Span")
HTML_TAG("sup", "Span")
HTML_TAG("table", "Table")
HTML_TAG("tbody", "TableSection")
HTML_TAG("td", "TableCell")
HTML_TAG("textarea", "TextArea")
HTML_TAG("tfoot", "TableSection")
HTML_TAG("th", "TableCell")
HTML_TAG("thead", "TableSection")
HTML_TAG("template", "Template")
HTML_TAG("title", "Title")
HTML_TAG("tr", "TableRow")
HTML_TAG("tt", "Span")
HTML_TAG("u", "Span")
HTML_TAG("ul", "SharedList")
HTML_TAG("var", "Span")
HTML_TAG("wbr", "Shared")
HTML_TAG("xmp", "Span")
function SVG_TAG(name) {
allNodes.push(doc.createElementNS("http://www.w3.org/2000/svg", name));
}
// List sorta stolen from SVG element factory.
SVG_TAG("a")
SVG_TAG("polyline")
SVG_TAG("polygon")
SVG_TAG("circle")
SVG_TAG("ellipse")
SVG_TAG("line")
SVG_TAG("rect")
SVG_TAG("svg")
SVG_TAG("g")
SVG_TAG("foreignObject")
SVG_TAG("path")
SVG_TAG("text")
SVG_TAG("tspan")
SVG_TAG("image")
SVG_TAG("style")
SVG_TAG("linearGradient")
SVG_TAG("metadata")
SVG_TAG("radialGradient")
SVG_TAG("stop")
SVG_TAG("defs")
SVG_TAG("desc")
SVG_TAG("script")
SVG_TAG("use")
SVG_TAG("symbol")
SVG_TAG("marker")
SVG_TAG("title")
SVG_TAG("clipPath")
SVG_TAG("textPath")
SVG_TAG("filter")
SVG_TAG("feBlend")
SVG_TAG("feColorMatrix")
SVG_TAG("feComponentTransfer")
SVG_TAG("feComposite")
SVG_TAG("feFuncR")
SVG_TAG("feFuncG")
SVG_TAG("feFuncB")
SVG_TAG("feFuncA")
SVG_TAG("feGaussianBlur")
SVG_TAG("feMerge")
SVG_TAG("feMergeNode")
SVG_TAG("feMorphology")
SVG_TAG("feOffset")
SVG_TAG("feFlood")
SVG_TAG("feTile")
SVG_TAG("feTurbulence")
SVG_TAG("feConvolveMatrix")
SVG_TAG("feDistantLight")
SVG_TAG("fePointLight")
SVG_TAG("feSpotLight")
SVG_TAG("feDiffuseLighting")
SVG_TAG("feSpecularLighting")
SVG_TAG("feDisplacementMap")
SVG_TAG("feImage")
SVG_TAG("pattern")
SVG_TAG("mask")
SVG_TAG("svgSwitch")
// Toss in some other namespaced stuff too, for good measure
// XUL stuff might not be creatable in content documents
try {
allNodes.push(doc.createElementNS(
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"window"));
} catch (e) {}
allNodes.push(doc.createElementNS("http://www.w3.org/1998/Math/MathML",
"math"));
allNodes.push(doc.createElementNS("http://www.w3.org/2001/xml-events",
"testname"));
allNodes.push(doc.createElementNS("bogus.namespace", "testname"));
var XMLDoc = doc.implementation.createDocument("", "", null);
// And non-elements
allNodes.push(doc.createTextNode("some text"));
allNodes.push(doc.createComment("some text"));
allNodes.push(doc.createDocumentFragment());
XMLNodes.push(XMLDoc.createCDATASection("some text"));
XMLNodes.push(XMLDoc.createProcessingInstruction("PI", "data"));
function runTestUnwrapped() {
if (!("wrappedJSObject" in doc)) {
return;
}
ok(doc.wrappedJSObject.nodePrincipal === undefined,
"Must not have document principal for " + documentID);
ok(doc.wrappedJSObject.baseURIObject === undefined,
"Must not have document base URI for " + documentID);
ok(doc.wrappedJSObject.documentURIObject === undefined,
"Must not have document URI for " + documentID);
for (var i = 0; i < allNodes.length; ++i) {
ok(allNodes[i].wrappedJSObject.nodePrincipal === undefined,
"Unexpected principal appears for " + allNodes[i].nodeName +
" in " + documentID);
ok(allNodes[i].wrappedJSObject.baseURIObject === undefined,
"Unexpected base URI appears for " + allNodes[i].nodeName +
" in " + documentID);
}
}
function runTestProps() {
isnot(doc.nodePrincipal, null,
"Must have document principal in " + documentID);
is(doc.nodePrincipal instanceof Components.interfaces.nsIPrincipal,
true, "document principal must be a principal in " + documentID);
isnot(doc.baseURIObject, null,
"Must have document base URI in" + documentID);
is(doc.baseURIObject instanceof Components.interfaces.nsIURI,
true, "document base URI must be a URI in " + documentID);
isnot(doc.documentURIObject, null,
"Must have document URI " + documentID);
is(doc.documentURIObject instanceof Components.interfaces.nsIURI,
true, "document URI must be a URI in " + documentID);
is(doc.documentURIObject.spec, doc.documentURI,
"document URI must be the right URI in " + documentID);
for (var i = 0; i < allNodes.length; ++i) {
is(allNodes[i].nodePrincipal, doc.nodePrincipal,
"Unexpected principal for " + allNodes[i].nodeName +
" in " + documentID);
is(allNodes[i].baseURIObject, doc.baseURIObject,
"Unexpected base URI for " + allNodes[i].nodeName +
" in " + documentID);
}
for (i = 0; i < XMLNodes.length; ++i) {
is(XMLNodes[i].nodePrincipal, doc.nodePrincipal,
"Unexpected principal for " + XMLNodes[i].nodeName +
" in " + documentID);
is(XMLNodes[i].baseURIObject.spec, "about:blank",
"Unexpected base URI for " + XMLNodes[i].nodeName +
" in " + documentID);
}
}
runTestUnwrapped();
runTestProps();
runTestUnwrapped();
}
add_task(function* test1() {
testInDocument(document, "browser window");
});
function* newTabTest(location) {
yield BrowserTestUtils.withNewTab({ gBrowser, url: location },
function* (browser) {
yield ContentTask.spawn(browser, { location, testInDocument_: testInDocument.toSource() },
function* ({ location, testInDocument_ }) {
let testInDocument = eval(`(() => (${testInDocument_}))()`);
testInDocument(content.document, location);
});
});
}
add_task(function* test2() {
yield newTabTest("about:blank");
});
add_task(function* test3() {
yield newTabTest("about:config");
});
|