Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 14 matching lines...) Expand all Loading... | |
25 let {Utils} = require("utils"); | 25 let {Utils} = require("utils"); |
26 let {Prefs} = require("prefs"); | 26 let {Prefs} = require("prefs"); |
27 let {FilterStorage} = require("filterStorage"); | 27 let {FilterStorage} = require("filterStorage"); |
28 let {BlockingFilter, WhitelistFilter, RegExpFilter} = require("filterClasses"); | 28 let {BlockingFilter, WhitelistFilter, RegExpFilter} = require("filterClasses"); |
29 let {defaultMatcher} = require("matcher"); | 29 let {defaultMatcher} = require("matcher"); |
30 let {objectMouseEventHander} = require("objectTabs"); | 30 let {objectMouseEventHander} = require("objectTabs"); |
31 let {RequestNotifier} = require("requestNotifier"); | 31 let {RequestNotifier} = require("requestNotifier"); |
32 let {ElemHide} = require("elemHide"); | 32 let {ElemHide} = require("elemHide"); |
33 | 33 |
34 /** | 34 /** |
35 * List of explicitly supported content types | 35 * Set of explicitly supported content types |
36 * @type string[] | 36 * @type Set |
37 */ | 37 */ |
38 let contentTypes = ["OTHER", "SCRIPT", "IMAGE", "STYLESHEET", "OBJECT", "SUBDOCU MENT", "DOCUMENT", "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", "MEDIA"]; | 38 let contentTypes = new Set([ |
39 "OTHER", "SCRIPT", "IMAGE", "STYLESHEET", "OBJECT", "SUBDOCUMENT", "DOCUMENT", | |
40 "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", "MEDIA", "ELEMHIDE", "POPUP", | |
41 "GENERICHIDE", "GENERICBLOCK" | |
42 ]); | |
39 | 43 |
40 /** | 44 /** |
41 * List of content types that aren't associated with a visual document area | 45 * Set of content types that aren't associated with a visual document area |
42 * @type string[] | 46 * @type Set |
43 */ | 47 */ |
44 let nonVisualTypes = ["SCRIPT", "STYLESHEET", "XMLHTTPREQUEST", "OBJECT_SUBREQUE ST", "FONT"]; | 48 let nonVisualTypes = new Set([ |
49 "SCRIPT", "STYLESHEET", "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", | |
50 "ELEMHIDE", "POPUP", "GENERICHIDE", "GENERICBLOCK" | |
51 ]); | |
45 | 52 |
46 /** | 53 /** |
47 * Randomly generated class name, to be applied to collapsed nodes. | 54 * Randomly generated class name, to be applied to collapsed nodes. |
48 */ | 55 */ |
49 let collapsedClass = ""; | 56 let collapsedClass = ""; |
50 | 57 |
51 /** | 58 /** |
59 * Maps numerical content type IDs to strings. | |
60 * @type Map | |
Thomas Greiner
2015/11/02 18:54:36
Detail: Since we've already been specifying the ty
Wladimir Palant
2015/11/03 11:26:49
True, will improve JSDoc comments in a separate co
Thomas Greiner
2015/11/03 11:54:54
Great, thanks.
| |
61 */ | |
62 let types = new Map(); | |
63 | |
64 /** | |
52 * Public policy checking functions and auxiliary objects | 65 * Public policy checking functions and auxiliary objects |
53 * @class | 66 * @class |
54 */ | 67 */ |
55 var Policy = exports.Policy = | 68 var Policy = exports.Policy = |
56 { | 69 { |
57 /** | 70 /** |
58 * Map of content type identifiers by their name. | 71 * Map of localized content type names by their identifiers. |
59 * @type Object | 72 * @type Map |
60 */ | 73 */ |
61 type: {}, | 74 localizedDescr: new Map(), |
62 | |
63 /** | |
64 * Map of content type names by their identifiers (reverse of type map). | |
65 * @type Object | |
66 */ | |
67 typeDescr: {}, | |
68 | |
69 /** | |
70 * Map of numerical content types with their corresponding masks | |
71 * @type Object | |
72 */ | |
73 typeMask: {}, | |
74 | |
75 /** | |
76 * Map of localized content type names by their identifiers. | |
77 * @type Object | |
78 */ | |
79 localizedDescr: {}, | |
80 | |
81 /** | |
82 * Lists the non-visual content types. | |
83 * @type Object | |
84 */ | |
85 nonVisual: {}, | |
86 | 75 |
87 /** | 76 /** |
88 * Map containing all schemes that should be ignored by content policy. | 77 * Map containing all schemes that should be ignored by content policy. |
89 * @type Object | 78 * @type Object |
90 */ | 79 */ |
91 whitelistSchemes: {}, | 80 whitelistSchemes: {}, |
92 | 81 |
93 /** | 82 /** |
94 * Called on module startup, initializes various exported properties. | 83 * Called on module startup, initializes various exported properties. |
95 */ | 84 */ |
96 init: function() | 85 init: function() |
97 { | 86 { |
98 // type constant by type description and type description by type constant | 87 // Populate types map |
99 let iface = Ci.nsIContentPolicy; | 88 let iface = Ci.nsIContentPolicy; |
89 for (let name in iface) | |
90 if (name.indexOf("TYPE_") == 0 && name != "TYPE_DATAREQUEST") | |
91 types.set(iface[name], name.substr(5)); | |
92 | |
93 // Populate localized type names | |
100 for (let typeName of contentTypes) | 94 for (let typeName of contentTypes) |
101 { | 95 this.localizedDescr.set(typeName, Utils.getString("type_label_" + typeName .toLowerCase())); |
102 if ("TYPE_" + typeName in iface) | |
103 { | |
104 let id = iface["TYPE_" + typeName]; | |
105 this.type[typeName] = id; | |
106 this.typeDescr[id] = typeName; | |
107 this.localizedDescr[id] = Utils.getString("type_label_" + typeName.toLow erCase()); | |
108 this.typeMask[id] = RegExpFilter.typeMap[typeName]; | |
109 } | |
110 } | |
111 | |
112 this.type.GENERICBLOCK = 0xFFFB; | |
113 this.typeDescr[0xFFFB] = "GENERICBLOCK"; | |
114 this.localizedDescr[0xFFFB] = Utils.getString("type_label_genericblock"); | |
115 this.typeMask[0xFFFB] = RegExpFilter.typeMap.GENERICBLOCK; | |
116 | |
117 this.type.GENERICHIDE = 0xFFFC; | |
118 this.typeDescr[0xFFFC] = "GENERICHIDE"; | |
119 this.localizedDescr[0xFFFC] = Utils.getString("type_label_generichide"); | |
120 this.typeMask[0xFFFC] = RegExpFilter.typeMap.GENERICHIDE; | |
121 | |
122 this.type.ELEMHIDE = 0xFFFD; | |
123 this.typeDescr[0xFFFD] = "ELEMHIDE"; | |
124 this.localizedDescr[0xFFFD] = Utils.getString("type_label_elemhide"); | |
125 this.typeMask[0xFFFD] = RegExpFilter.typeMap.ELEMHIDE; | |
126 | |
127 this.type.POPUP = 0xFFFE; | |
128 this.typeDescr[0xFFFE] = "POPUP"; | |
129 this.localizedDescr[0xFFFE] = Utils.getString("type_label_popup"); | |
130 this.typeMask[0xFFFE] = RegExpFilter.typeMap.POPUP; | |
131 | |
132 for (let type of nonVisualTypes) | |
133 this.nonVisual[this.type[type]] = true; | |
134 | 96 |
135 // whitelisted URL schemes | 97 // whitelisted URL schemes |
136 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) | 98 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) |
137 this.whitelistSchemes[scheme] = true; | 99 this.whitelistSchemes[scheme] = true; |
138 | 100 |
139 // Generate class identifier used to collapse node and register correspondin g | 101 // Generate class identifier used to collapse node and register correspondin g |
140 // stylesheet. | 102 // stylesheet. |
141 let offset = "a".charCodeAt(0); | 103 let offset = "a".charCodeAt(0); |
142 for (let i = 0; i < 20; i++) | 104 for (let i = 0; i < 20; i++) |
143 collapsedClass += String.fromCharCode(offset + Math.random() * 26); | 105 collapsedClass += String.fromCharCode(offset + Math.random() * 26); |
(...skipping 16 matching lines...) Expand all Loading... | |
160 * @param location {nsIURI} | 122 * @param location {nsIURI} |
161 * @param collapse {Boolean} true to force hiding of the node | 123 * @param collapse {Boolean} true to force hiding of the node |
162 * @return {Boolean} false if the node should be blocked | 124 * @return {Boolean} false if the node should be blocked |
163 */ | 125 */ |
164 processNode: function(wnd, node, contentType, location, collapse) | 126 processNode: function(wnd, node, contentType, location, collapse) |
165 { | 127 { |
166 let topWnd = wnd.top; | 128 let topWnd = wnd.top; |
167 if (!topWnd || !topWnd.location || !topWnd.location.href) | 129 if (!topWnd || !topWnd.location || !topWnd.location.href) |
168 return true; | 130 return true; |
169 | 131 |
132 // Interpret unknown types as "other" | |
133 if (!contentTypes.has(contentType)) | |
134 contentType = "OTHER"; | |
135 | |
170 let originWindow = Utils.getOriginWindow(wnd); | 136 let originWindow = Utils.getOriginWindow(wnd); |
171 let wndLocation = originWindow.location.href; | 137 let wndLocation = originWindow.location.href; |
172 let docDomain = getHostname(wndLocation); | 138 let docDomain = getHostname(wndLocation); |
173 let match = null; | 139 let match = null; |
174 let [sitekey, sitekeyWnd] = getSitekey(wnd); | 140 let [sitekey, sitekeyWnd] = getSitekey(wnd); |
175 let nogeneric = false; | 141 let nogeneric = false; |
176 | 142 |
177 function cleanWindowLocation(wnd) | 143 function cleanWindowLocation(wnd) |
178 { | 144 { |
179 let url = getWindowLocation(wnd); | 145 let url = getWindowLocation(wnd); |
(...skipping 10 matching lines...) Expand all Loading... | |
190 let testSitekey = sitekey; | 156 let testSitekey = sitekey; |
191 let testSitekeyWnd = sitekeyWnd; | 157 let testSitekeyWnd = sitekeyWnd; |
192 let parentWndLocation = cleanWindowLocation(testWnd); | 158 let parentWndLocation = cleanWindowLocation(testWnd); |
193 while (true) | 159 while (true) |
194 { | 160 { |
195 let testWndLocation = parentWndLocation; | 161 let testWndLocation = parentWndLocation; |
196 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : clean WindowLocation(testWnd.parent)); | 162 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : clean WindowLocation(testWnd.parent)); |
197 let parentDocDomain = getHostname(parentWndLocation); | 163 let parentDocDomain = getHostname(parentWndLocation); |
198 | 164 |
199 let typeMap = RegExpFilter.typeMap.DOCUMENT; | 165 let typeMap = RegExpFilter.typeMap.DOCUMENT; |
200 if (contentType == Policy.type.ELEMHIDE) | 166 if (contentType == "ELEMHIDE") |
201 typeMap = typeMap | RegExpFilter.typeMap.ELEMHIDE; | 167 typeMap = typeMap | RegExpFilter.typeMap.ELEMHIDE; |
202 let whitelistMatch = defaultMatcher.matchesAny(testWndLocation, typeMap, parentDocDomain, false, sitekey); | 168 let whitelistMatch = defaultMatcher.matchesAny(testWndLocation, typeMap, parentDocDomain, false, sitekey); |
203 if (whitelistMatch instanceof WhitelistFilter) | 169 if (whitelistMatch instanceof WhitelistFilter) |
204 { | 170 { |
205 FilterStorage.increaseHitCount(whitelistMatch, wnd); | 171 FilterStorage.increaseHitCount(whitelistMatch, wnd); |
206 RequestNotifier.addNodeData(testWnd.document, topWnd, | 172 RequestNotifier.addNodeData(testWnd.document, topWnd, |
207 (whitelistMatch.contentType & RegExpFilter.typeMap.DOCUMENT) ? Polic y.type.DOCUMENT : Policy.type.ELEMHIDE, | 173 (whitelistMatch.contentType & RegExpFilter.typeMap.DOCUMENT) ? "DOCU MENT" : "ELEMHIDE", |
208 parentDocDomain, false, testWndLocation, whitelistMatch); | 174 parentDocDomain, false, testWndLocation, whitelistMatch); |
209 return true; | 175 return true; |
210 } | 176 } |
211 | 177 |
212 let genericType = (contentType == Policy.type.ELEMHIDE ? | 178 let genericType = (contentType == "ELEMHIDE" ? "GENERICHIDE" : "GENERICB LOCK"); |
213 Policy.type.GENERICHIDE : | |
214 Policy.type.GENERICBLOCK); | |
215 let nogenericMatch = defaultMatcher.matchesAny(testWndLocation, | 179 let nogenericMatch = defaultMatcher.matchesAny(testWndLocation, |
216 Policy.typeMask[genericType], parentDocDomain, false, testSitekey); | 180 RegExpFilter.typeMap[genericType], parentDocDomain, false, testSitek ey); |
217 if (nogenericMatch instanceof WhitelistFilter) | 181 if (nogenericMatch instanceof WhitelistFilter) |
218 { | 182 { |
219 nogeneric = true; | 183 nogeneric = true; |
220 | 184 |
221 FilterStorage.increaseHitCount(nogenericMatch, wnd); | 185 FilterStorage.increaseHitCount(nogenericMatch, wnd); |
222 RequestNotifier.addNodeData(testWnd.document, topWnd, genericType, | 186 RequestNotifier.addNodeData(testWnd.document, topWnd, genericType, |
223 parentDocDomain, false, testWndLocation, | 187 parentDocDomain, false, testWndLocation, |
224 nogenericMatch); | 188 nogenericMatch); |
225 } | 189 } |
226 | 190 |
227 if (testWnd.parent == testWnd) | 191 if (testWnd.parent == testWnd) |
228 break; | 192 break; |
229 | 193 |
230 if (testWnd == testSitekeyWnd) | 194 if (testWnd == testSitekeyWnd) |
231 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent); | 195 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent); |
232 testWnd = testWnd.parent; | 196 testWnd = testWnd.parent; |
233 } | 197 } |
234 } | 198 } |
235 | 199 |
236 // Data loaded by plugins should be attached to the document | 200 // Data loaded by plugins should be attached to the document |
237 if (contentType == Policy.type.OBJECT_SUBREQUEST && node instanceof Ci.nsIDO MElement) | 201 if (contentType == "OBJECT_SUBREQUEST" && node instanceof Ci.nsIDOMElement) |
238 node = node.ownerDocument; | 202 node = node.ownerDocument; |
239 | 203 |
240 // Fix type for objects misrepresented as frames or images | 204 // Fix type for objects misrepresented as frames or images |
241 if (contentType != Policy.type.OBJECT && (node instanceof Ci.nsIDOMHTMLObjec tElement || node instanceof Ci.nsIDOMHTMLEmbedElement)) | 205 if (contentType != "OBJECT" && (node instanceof Ci.nsIDOMHTMLObjectElement | | node instanceof Ci.nsIDOMHTMLEmbedElement)) |
242 contentType = Policy.type.OBJECT; | 206 contentType = "OBJECT"; |
243 | 207 |
244 let locationText = location.spec; | 208 let locationText = location.spec; |
245 if (!match && contentType == Policy.type.ELEMHIDE) | 209 if (!match && contentType == "ELEMHIDE") |
246 { | 210 { |
247 match = location; | 211 match = location; |
248 locationText = match.text.replace(/^.*?#/, '#'); | 212 locationText = match.text.replace(/^.*?#/, '#'); |
249 location = locationText; | 213 location = locationText; |
250 | 214 |
251 if (!match.isActiveOnDomain(docDomain)) | 215 if (!match.isActiveOnDomain(docDomain)) |
252 return true; | 216 return true; |
253 | 217 |
254 let exception = ElemHide.getException(match, docDomain); | 218 let exception = ElemHide.getException(match, docDomain); |
255 if (exception) | 219 if (exception) |
256 { | 220 { |
257 FilterStorage.increaseHitCount(exception, wnd); | 221 FilterStorage.increaseHitCount(exception, wnd); |
258 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, locationText, exception); | 222 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, locationText, exception); |
259 return true; | 223 return true; |
260 } | 224 } |
261 | 225 |
262 if (nogeneric && match.isGeneric()) | 226 if (nogeneric && match.isGeneric()) |
263 return true; | 227 return true; |
264 } | 228 } |
265 | 229 |
266 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty (location, docDomain)); | 230 let thirdParty = (contentType == "ELEMHIDE" ? false : isThirdParty(location, docDomain)); |
267 | 231 |
268 if (!match && Prefs.enabled && contentType in Policy.typeMask) | 232 if (!match && Prefs.enabled && RegExpFilter.typeMap.hasOwnProperty(contentTy pe)) |
269 { | 233 { |
270 match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentTyp e], | 234 match = defaultMatcher.matchesAny(locationText, RegExpFilter.typeMap[conte ntType], |
271 docDomain, thirdParty, sitekey, nogeneri c); | 235 docDomain, thirdParty, sitekey, nogeneri c); |
272 if (match instanceof BlockingFilter && node.ownerDocument && !(contentType in Policy.nonVisual)) | 236 if (match instanceof BlockingFilter && node.ownerDocument && !nonVisualTyp es.has(contentType)) |
273 { | 237 { |
274 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fas tcollapse); | 238 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fas tcollapse); |
275 if (collapse || prefCollapse) | 239 if (collapse || prefCollapse) |
276 schedulePostProcess(node); | 240 schedulePostProcess(node); |
277 } | 241 } |
278 | 242 |
279 // Track mouse events for objects | 243 // Track mouse events for objects |
280 if (!match && contentType == Policy.type.OBJECT && node.nodeType == Ci.nsI DOMNode.ELEMENT_NODE) | 244 if (!match && contentType == "OBJECT" && node.nodeType == Ci.nsIDOMNode.EL EMENT_NODE) |
281 { | 245 { |
282 node.addEventListener("mouseover", objectMouseEventHander, true); | 246 node.addEventListener("mouseover", objectMouseEventHander, true); |
283 node.addEventListener("mouseout", objectMouseEventHander, true); | 247 node.addEventListener("mouseout", objectMouseEventHander, true); |
284 } | 248 } |
285 } | 249 } |
286 | 250 |
287 // Store node data | 251 // Store node data |
288 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, thirdParty , locationText, match); | 252 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, thirdParty , locationText, match); |
289 if (match) | 253 if (match) |
290 FilterStorage.increaseHitCount(match, wnd); | 254 FilterStorage.increaseHitCount(match, wnd); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy, Ci.nsIObserver, | 365 QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy, Ci.nsIObserver, |
402 Ci.nsIChannelEventSink, Ci.nsIFactory, Ci.nsISupportsWeakReference]), | 366 Ci.nsIChannelEventSink, Ci.nsIFactory, Ci.nsISupportsWeakReference]), |
403 | 367 |
404 // | 368 // |
405 // nsIContentPolicy interface implementation | 369 // nsIContentPolicy interface implementation |
406 // | 370 // |
407 | 371 |
408 shouldLoad: function(contentType, contentLocation, requestOrigin, node, mimeTy peGuess, extra) | 372 shouldLoad: function(contentType, contentLocation, requestOrigin, node, mimeTy peGuess, extra) |
409 { | 373 { |
410 // Ignore requests without context and top-level documents | 374 // Ignore requests without context and top-level documents |
411 if (!node || contentType == Policy.type.DOCUMENT) | 375 if (!node || contentType == Ci.nsIContentPolicy.TYPE_DOCUMENT) |
412 return Ci.nsIContentPolicy.ACCEPT; | 376 return Ci.nsIContentPolicy.ACCEPT; |
413 | 377 |
414 // Ignore standalone objects | 378 // Ignore standalone objects |
415 if (contentType == Policy.type.OBJECT && node.ownerDocument && !/^text\/|[+\ /]xml$/.test(node.ownerDocument.contentType)) | 379 if (contentType == Ci.nsIContentPolicy.TYPE_OBJECT && node.ownerDocument && !/^text\/|[+\/]xml$/.test(node.ownerDocument.contentType)) |
416 return Ci.nsIContentPolicy.ACCEPT; | 380 return Ci.nsIContentPolicy.ACCEPT; |
417 | 381 |
418 let wnd = Utils.getWindow(node); | 382 let wnd = Utils.getWindow(node); |
419 if (!wnd) | 383 if (!wnd) |
420 return Ci.nsIContentPolicy.ACCEPT; | 384 return Ci.nsIContentPolicy.ACCEPT; |
421 | 385 |
422 // Ignore whitelisted schemes | 386 // Ignore whitelisted schemes |
423 let location = Utils.unwrapURL(contentLocation); | 387 let location = Utils.unwrapURL(contentLocation); |
424 if (!Policy.isBlockableScheme(location)) | 388 if (!Policy.isBlockableScheme(location)) |
425 return Ci.nsIContentPolicy.ACCEPT; | 389 return Ci.nsIContentPolicy.ACCEPT; |
426 | 390 |
427 // Interpret unknown types as "other" | 391 let result = Policy.processNode(wnd, node, types.get(contentType), location, false); |
428 if (!(contentType in Policy.typeDescr)) | |
429 contentType = Policy.type.OTHER; | |
430 | |
431 let result = Policy.processNode(wnd, node, contentType, location, false); | |
432 return (result ? Ci.nsIContentPolicy.ACCEPT : Ci.nsIContentPolicy.REJECT_REQ UEST); | 392 return (result ? Ci.nsIContentPolicy.ACCEPT : Ci.nsIContentPolicy.REJECT_REQ UEST); |
433 }, | 393 }, |
434 | 394 |
435 shouldProcess: function(contentType, contentLocation, requestOrigin, insecNode , mimeType, extra) | 395 shouldProcess: function(contentType, contentLocation, requestOrigin, insecNode , mimeType, extra) |
436 { | 396 { |
437 return Ci.nsIContentPolicy.ACCEPT; | 397 return Ci.nsIContentPolicy.ACCEPT; |
438 }, | 398 }, |
439 | 399 |
440 // | 400 // |
441 // nsIObserver interface implementation | 401 // nsIObserver interface implementation |
442 // | 402 // |
443 observe: function(subject, topic, data, additional) | 403 observe: function(subject, topic, data, additional) |
444 { | 404 { |
445 switch (topic) | 405 switch (topic) |
446 { | 406 { |
447 case "content-document-global-created": | 407 case "content-document-global-created": |
448 { | 408 { |
449 if (!(subject instanceof Ci.nsIDOMWindow) || !subject.opener) | 409 if (!(subject instanceof Ci.nsIDOMWindow) || !subject.opener) |
450 return; | 410 return; |
451 | 411 |
452 let uri = additional || Utils.makeURI(subject.location.href); | 412 let uri = additional || Utils.makeURI(subject.location.href); |
453 if (!Policy.processNode(subject.opener, subject.opener.document, Policy. type.POPUP, uri, false)) | 413 if (!Policy.processNode(subject.opener, subject.opener.document, "POPUP" , uri, false)) |
454 { | 414 { |
455 subject.stop(); | 415 subject.stop(); |
456 Utils.runAsync(() => subject.close()); | 416 Utils.runAsync(() => subject.close()); |
457 } | 417 } |
458 else if (uri.spec == "about:blank") | 418 else if (uri.spec == "about:blank") |
459 { | 419 { |
460 // An about:blank pop-up most likely means that a load will be | 420 // An about:blank pop-up most likely means that a load will be |
461 // initiated asynchronously. Wait for that. | 421 // initiated asynchronously. Wait for that. |
462 Utils.runAsync(function() | 422 Utils.runAsync(function() |
463 { | 423 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 { | 460 { |
501 // Special treatment for pop-up windows. Note that we might not have | 461 // Special treatment for pop-up windows. Note that we might not have |
502 // seen the original channel yet because the redirect happened before | 462 // seen the original channel yet because the redirect happened before |
503 // the async code in observe() had a chance to run. | 463 // the async code in observe() had a chance to run. |
504 this.observe(wnd, "content-document-global-created", null, oldChannel. URI); | 464 this.observe(wnd, "content-document-global-created", null, oldChannel. URI); |
505 this.observe(wnd, "content-document-global-created", null, newChannel. URI); | 465 this.observe(wnd, "content-document-global-created", null, newChannel. URI); |
506 } | 466 } |
507 return; | 467 return; |
508 } | 468 } |
509 | 469 |
510 if (!Policy.processNode(wnd, wnd.document, contentType, newChannel.URI, fa lse)) | 470 if (!Policy.processNode(wnd, wnd.document, types.get(contentType), newChan nel.URI, false)) |
511 result = Cr.NS_BINDING_ABORTED; | 471 result = Cr.NS_BINDING_ABORTED; |
512 } | 472 } |
513 catch (e) | 473 catch (e) |
514 { | 474 { |
515 // We shouldn't throw exceptions here - this will prevent the redirect. | 475 // We shouldn't throw exceptions here - this will prevent the redirect. |
516 Cu.reportError(e); | 476 Cu.reportError(e); |
517 } | 477 } |
518 finally | 478 finally |
519 { | 479 { |
520 callback.onRedirectVerifyCallback(result); | 480 callback.onRedirectVerifyCallback(result); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 | 672 |
713 /** | 673 /** |
714 * Re-checks filters on an element. | 674 * Re-checks filters on an element. |
715 */ | 675 */ |
716 function refilterNode(/**Node*/ node, /**RequestEntry*/ entry) | 676 function refilterNode(/**Node*/ node, /**RequestEntry*/ entry) |
717 { | 677 { |
718 let wnd = Utils.getWindow(node); | 678 let wnd = Utils.getWindow(node); |
719 if (!wnd || wnd.closed) | 679 if (!wnd || wnd.closed) |
720 return; | 680 return; |
721 | 681 |
722 if (entry.type == Policy.type.OBJECT) | 682 if (entry.type == "OBJECT") |
723 { | 683 { |
724 node.removeEventListener("mouseover", objectMouseEventHander, true); | 684 node.removeEventListener("mouseover", objectMouseEventHander, true); |
725 node.removeEventListener("mouseout", objectMouseEventHander, true); | 685 node.removeEventListener("mouseout", objectMouseEventHander, true); |
726 } | 686 } |
727 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; | 687 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; |
728 } | 688 } |
OLD | NEW |