Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/contentPolicy.js

Issue 5840485868371968: Issue 616 - Add $generichide + $genericblock filter options and enforce them. (Closed)
Left Patch Set: Created March 6, 2015, 9:45 p.m.
Right Patch Set: Remove extra parenthesis Created Sept. 28, 2015, 10:15 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | lib/filterClasses.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 /** 18 /**
19 * @fileOverview Content policy implementation, responsible for blocking things. 19 * @fileOverview Content policy implementation, responsible for blocking things.
20 */ 20 */
21 21
22 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 22 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
23 Cu.import("resource://gre/modules/Services.jsm"); 23 Cu.import("resource://gre/modules/Services.jsm");
24 24
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} = 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 * List of explicitly supported content types
36 * @type Array of String 36 * @type string[]
37 */ 37 */
38 let contentTypes = ["OTHER", "SCRIPT", "IMAGE", "STYLESHEET", "OBJECT", "SUBDOCU MENT", "DOCUMENT", "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", "MEDIA"]; 38 let contentTypes = ["OTHER", "SCRIPT", "IMAGE", "STYLESHEET", "OBJECT", "SUBDOCU MENT", "DOCUMENT", "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", "MEDIA"];
39 39
40 /** 40 /**
41 * List of content types that aren't associated with a visual document area 41 * List of content types that aren't associated with a visual document area
42 * @type Array of String 42 * @type string[]
43 */ 43 */
44 let nonVisualTypes = ["SCRIPT", "STYLESHEET", "XMLHTTPREQUEST", "OBJECT_SUBREQUE ST", "FONT"]; 44 let nonVisualTypes = ["SCRIPT", "STYLESHEET", "XMLHTTPREQUEST", "OBJECT_SUBREQUE ST", "FONT"];
45 45
46 /** 46 /**
47 * Randomly generated class name, to be applied to collapsed nodes. 47 * Randomly generated class name, to be applied to collapsed nodes.
48 */ 48 */
49 let collapsedClass = ""; 49 let collapsedClass = "";
50 50
51 /** 51 /**
52 * Public policy checking functions and auxiliary objects 52 * Public policy checking functions and auxiliary objects
53 * @class 53 * @class
54 */ 54 */
55 let Policy = exports.Policy = 55 let Policy = exports.Policy =
56 { 56 {
57 /** 57 /**
58 * Map of content type identifiers by their name. 58 * Map of content type identifiers by their name.
59 * @type Object 59 * @type Object
60 */ 60 */
61 type: {}, 61 type: {},
62 62
63 /** 63 /**
64 * Map of content type names by their identifiers (reverse of type map). 64 * Map of content type names by their identifiers (reverse of type map).
65 * @type Object 65 * @type Object
66 */ 66 */
67 typeDescr: {}, 67 typeDescr: {},
68
69 /**
70 * Map of numerical content types with their corresponding masks
71 * @type Object
72 */
73 typeMask: {},
68 74
69 /** 75 /**
70 * Map of localized content type names by their identifiers. 76 * Map of localized content type names by their identifiers.
71 * @type Object 77 * @type Object
72 */ 78 */
73 localizedDescr: {}, 79 localizedDescr: {},
74 80
75 /** 81 /**
76 * Lists the non-visual content types. 82 * Lists the non-visual content types.
77 * @type Object 83 * @type Object
(...skipping 14 matching lines...) Expand all
92 // type constant by type description and type description by type constant 98 // type constant by type description and type description by type constant
93 let iface = Ci.nsIContentPolicy; 99 let iface = Ci.nsIContentPolicy;
94 for (let typeName of contentTypes) 100 for (let typeName of contentTypes)
95 { 101 {
96 if ("TYPE_" + typeName in iface) 102 if ("TYPE_" + typeName in iface)
97 { 103 {
98 let id = iface["TYPE_" + typeName]; 104 let id = iface["TYPE_" + typeName];
99 this.type[typeName] = id; 105 this.type[typeName] = id;
100 this.typeDescr[id] = typeName; 106 this.typeDescr[id] = typeName;
101 this.localizedDescr[id] = Utils.getString("type_label_" + typeName.toLow erCase()); 107 this.localizedDescr[id] = Utils.getString("type_label_" + typeName.toLow erCase());
108 this.typeMask[id] = RegExpFilter.typeMap[typeName];
102 } 109 }
103 } 110 }
104 111
105 this.type.ELEMHIDE = 0xFFFD; 112 this.type.ELEMHIDE = 0xFFFD;
106 this.typeDescr[0xFFFD] = "ELEMHIDE"; 113 this.typeDescr[0xFFFD] = "ELEMHIDE";
107 this.localizedDescr[0xFFFD] = Utils.getString("type_label_elemhide"); 114 this.localizedDescr[0xFFFD] = Utils.getString("type_label_elemhide");
115 this.typeMask[0xFFFD] = RegExpFilter.typeMap.ELEMHIDE;
108 116
109 this.type.POPUP = 0xFFFE; 117 this.type.POPUP = 0xFFFE;
110 this.typeDescr[0xFFFE] = "POPUP"; 118 this.typeDescr[0xFFFE] = "POPUP";
111 this.localizedDescr[0xFFFE] = Utils.getString("type_label_popup"); 119 this.localizedDescr[0xFFFE] = Utils.getString("type_label_popup");
120 this.typeMask[0xFFFE] = RegExpFilter.typeMap.POPUP;
112 121
113 for (let type of nonVisualTypes) 122 for (let type of nonVisualTypes)
114 this.nonVisual[this.type[type]] = true; 123 this.nonVisual[this.type[type]] = true;
115 124
116 // whitelisted URL schemes 125 // whitelisted URL schemes
117 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) 126 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" "))
118 this.whitelistSchemes[scheme] = true; 127 this.whitelistSchemes[scheme] = true;
119 128
120 // Generate class identifier used to collapse node and register correspondin g 129 // Generate class identifier used to collapse node and register correspondin g
121 // stylesheet. 130 // stylesheet.
(...skipping 24 matching lines...) Expand all
146 { 155 {
147 let topWnd = wnd.top; 156 let topWnd = wnd.top;
148 if (!topWnd || !topWnd.location || !topWnd.location.href) 157 if (!topWnd || !topWnd.location || !topWnd.location.href)
149 return true; 158 return true;
150 159
151 let originWindow = Utils.getOriginWindow(wnd); 160 let originWindow = Utils.getOriginWindow(wnd);
152 let wndLocation = originWindow.location.href; 161 let wndLocation = originWindow.location.href;
153 let docDomain = getHostname(wndLocation); 162 let docDomain = getHostname(wndLocation);
154 let match = null; 163 let match = null;
155 let [sitekey, sitekeyWnd] = getSitekey(wnd); 164 let [sitekey, sitekeyWnd] = getSitekey(wnd);
156 let genericblock = { match: null }; 165 let nogeneric = false;
166
157 if (!match && Prefs.enabled) 167 if (!match && Prefs.enabled)
158 { 168 {
159 let testWnd = wnd; 169 let testWnd = wnd;
160 let testSitekey = sitekey; 170 let testSitekey = sitekey;
161 let testSitekeyWnd = sitekeyWnd; 171 let testSitekeyWnd = sitekeyWnd;
162 let parentWndLocation = getWindowLocation(testWnd); 172 let parentWndLocation = getWindowLocation(testWnd);
163 while (true) 173 while (true)
164 { 174 {
165 let testWndLocation = parentWndLocation; 175 let testWndLocation = parentWndLocation;
166 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); 176 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent));
167 match = Policy.isWhitelisted(testWndLocation, parentWndLocation, testSit ekey); 177 match = Policy.isWhitelisted(testWndLocation, parentWndLocation, testSit ekey);
168 178
169 if (match instanceof WhitelistFilter) 179 if (match instanceof WhitelistFilter)
170 { 180 {
171 FilterStorage.increaseHitCount(match, wnd); 181 FilterStorage.increaseHitCount(match, wnd);
172 RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCU MENT, getHostname(parentWndLocation), false, testWndLocation, match); 182 RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCU MENT, getHostname(parentWndLocation), false, testWndLocation, match);
173 return true; 183 return true;
174 } 184 }
175 else if (!(genericblock.match instanceof WhitelistFilter) && contentType != Policy.type.ELEMHIDE) 185
176 { 186 let genericType = (contentType == Policy.type.ELEMHIDE ?
177 let parentDocDomain = getHostname(parentWndLocation); 187 RegExpFilter.typeMap.GENERICHIDE :
178 genericblock.match = defaultMatcher.matchesAny(testWndLocation, "GENER ICBLOCK", parentDocDomain, false); 188 RegExpFilter.typeMap.GENERICBLOCK);
179 if (genericblock.match instanceof WhitelistFilter) 189 let parentDocDomain = getHostname(parentWndLocation);
180 { 190 let nogenericMatch = defaultMatcher.matchesAny(
181 genericblock.parentDocDomain = parentDocDomain; 191 testWndLocation, genericType, parentDocDomain, false, testSitekey
182 genericblock.testWnd = testWnd; 192 );
183 genericblock.testWndLocation = testWndLocation; 193 if (nogenericMatch instanceof WhitelistFilter)
184 } 194 {
195 nogeneric = true;
196
197 FilterStorage.increaseHitCount(nogenericMatch, wnd);
198 RequestNotifier.addNodeData(testWnd.document, topWnd, contentType,
199 parentDocDomain, false, testWndLocation,
200 nogenericMatch);
185 } 201 }
186 202
187 if (testWnd.parent == testWnd) 203 if (testWnd.parent == testWnd)
188 break; 204 break;
189 205
190 if (testWnd == testSitekeyWnd) 206 if (testWnd == testSitekeyWnd)
191 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent); 207 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent);
192 testWnd = testWnd.parent; 208 testWnd = testWnd.parent;
193 } 209 }
194 } 210 }
195 211
196 // Data loaded by plugins should be attached to the document 212 // Data loaded by plugins should be attached to the document
197 if (contentType == Policy.type.OBJECT_SUBREQUEST && node instanceof Ci.nsIDO MElement) 213 if (contentType == Policy.type.OBJECT_SUBREQUEST && node instanceof Ci.nsIDO MElement)
198 node = node.ownerDocument; 214 node = node.ownerDocument;
199 215
200 // Fix type for objects misrepresented as frames or images 216 // Fix type for objects misrepresented as frames or images
201 if (contentType != Policy.type.OBJECT && (node instanceof Ci.nsIDOMHTMLObjec tElement || node instanceof Ci.nsIDOMHTMLEmbedElement)) 217 if (contentType != Policy.type.OBJECT && (node instanceof Ci.nsIDOMHTMLObjec tElement || node instanceof Ci.nsIDOMHTMLEmbedElement))
202 contentType = Policy.type.OBJECT; 218 contentType = Policy.type.OBJECT;
203 219
204 let locationText = location.spec; 220 let locationText = location.spec;
205 if (!match && contentType == Policy.type.ELEMHIDE) 221 if (!match && contentType == Policy.type.ELEMHIDE)
206 { 222 {
207 let testWnd = wnd; 223 let testWnd = wnd;
208 let parentWndLocation = getWindowLocation(testWnd); 224 let parentWndLocation = getWindowLocation(testWnd);
209 while (true) 225 while (true)
210 { 226 {
211 let testWndLocation = parentWndLocation; 227 let testWndLocation = parentWndLocation;
212 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); 228 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent));
213 let parentDocDomain = getHostname(parentWndLocation); 229 let parentDocDomain = getHostname(parentWndLocation);
214 match = defaultMatcher.matchesAny(testWndLocation, "ELEMHIDE", parentDoc Domain, false); 230 match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMap. ELEMHIDE, parentDocDomain, false, sitekey);
215
216 if (!(match instanceof WhitelistFilter) && (!location.domains || locatio n.domains[""]))
217 match = defaultMatcher.matchesAny(testWndLocation, "GENERICHIDE", pare ntDocDomain, false);
218
219 if (match instanceof WhitelistFilter) 231 if (match instanceof WhitelistFilter)
220 { 232 {
221 FilterStorage.increaseHitCount(match, wnd); 233 FilterStorage.increaseHitCount(match, wnd);
222 RequestNotifier.addNodeData(testWnd.document, topWnd, contentType, par entDocDomain, false, testWndLocation, match); 234 RequestNotifier.addNodeData(testWnd.document, topWnd, contentType, par entDocDomain, false, testWndLocation, match);
223 return true; 235 return true;
224 } 236 }
225 237
226 if (testWnd.parent == testWnd) 238 if (testWnd.parent == testWnd)
227 break; 239 break;
228 else 240 else
229 testWnd = testWnd.parent; 241 testWnd = testWnd.parent;
230 } 242 }
231 243
232 match = location; 244 match = location;
233 locationText = match.text.replace(/^.*?#/, '#'); 245 locationText = match.text.replace(/^.*?#/, '#');
234 location = locationText; 246 location = locationText;
235 247
236 if (!match.isActiveOnDomain(docDomain)) 248 if (!match.isActiveOnDomain(docDomain))
237 return true; 249 return true;
238 250
239 let exception = ElemHide.getException(match, docDomain); 251 let exception = ElemHide.getException(match, docDomain);
240 if (exception) 252 if (exception)
241 { 253 {
242 FilterStorage.increaseHitCount(exception, wnd); 254 FilterStorage.increaseHitCount(exception, wnd);
243 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, locationText, exception); 255 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, locationText, exception);
244 return true; 256 return true;
245 } 257 }
258
259 if (nogeneric && match.isGeneric())
260 return true;
246 } 261 }
247 262
248 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty (location, docDomain)); 263 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty (location, docDomain));
249 264
250 if (!match && Prefs.enabled) 265 if (!match && Prefs.enabled && contentType in Policy.typeMask)
251 { 266 {
252 match = defaultMatcher.matchesAny(locationText, Policy.typeDescr[contentTy pe] || "", docDomain, thirdParty, sitekey); 267 match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentTyp e],
253 if (match instanceof BlockingFilter && (!match.domains || match.domains["" ]) && genericblock.match instanceof WhitelistFilter) 268 docDomain, thirdParty, sitekey, nogeneri c);
254 {
255 FilterStorage.increaseHitCount(genericblock.match, wnd);
256 RequestNotifier.addNodeData(
257 genericblock.testWnd.document,
258 topWnd, contentType,
259 genericblock.parentDocDomain,
260 false, genericblock.testWndLocation,
261 genericblock.match
262 );
263 return true;
264 }
265
266 if (match instanceof BlockingFilter && node.ownerDocument && !(contentType in Policy.nonVisual)) 269 if (match instanceof BlockingFilter && node.ownerDocument && !(contentType in Policy.nonVisual))
267 { 270 {
268 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fas tcollapse); 271 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fas tcollapse);
269 if (collapse || prefCollapse) 272 if (collapse || prefCollapse)
270 schedulePostProcess(node); 273 schedulePostProcess(node);
271 } 274 }
272 275
273 // Track mouse events for objects 276 // Track mouse events for objects
274 if (!match && contentType == Policy.type.OBJECT && node.nodeType == Ci.nsI DOMNode.ELEMENT_NODE) 277 if (!match && contentType == Policy.type.OBJECT && node.nodeType == Ci.nsI DOMNode.ELEMENT_NODE)
275 { 278 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return null; 317 return null;
315 318
316 if (!parentUrl) 319 if (!parentUrl)
317 parentUrl = url; 320 parentUrl = url;
318 321
319 // Ignore fragment identifier 322 // Ignore fragment identifier
320 let index = url.indexOf("#"); 323 let index = url.indexOf("#");
321 if (index >= 0) 324 if (index >= 0)
322 url = url.substring(0, index); 325 url = url.substring(0, index);
323 326
324 let result = defaultMatcher.matchesAny(url, "DOCUMENT", getHostname(parentUr l), false, sitekey); 327 let result = defaultMatcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, g etHostname(parentUrl), false, sitekey);
325 return (result instanceof WhitelistFilter ? result : null); 328 return (result instanceof WhitelistFilter ? result : null);
326 }, 329 },
327 330
328 /** 331 /**
329 * Checks whether the page loaded in a window is whitelisted for indication in the UI. 332 * Checks whether the page loaded in a window is whitelisted for indication in the UI.
330 * @param wnd {nsIDOMWindow} 333 * @param wnd {nsIDOMWindow}
331 * @return {Filter} matching exception rule or null if not whitelisted 334 * @return {Filter} matching exception rule or null if not whitelisted
332 */ 335 */
333 isWindowWhitelisted: function(wnd) 336 isWindowWhitelisted: function(wnd)
334 { 337 {
335 return Policy.isWhitelisted(getWindowLocation(wnd)); 338 return Policy.isWhitelisted(getWindowLocation(wnd));
336 }, 339 },
337 340
338 /** 341 /**
339 * Asynchronously re-checks filters for given nodes. 342 * Asynchronously re-checks filters for given nodes.
340 */ 343 * @param {Node[]} nodes
341 refilterNodes: function(/**Node[]*/ nodes, /**RequestEntry*/ entry) 344 * @param {RequestEntry} entry
345 */
346 refilterNodes: function(nodes, entry)
342 { 347 {
343 // Ignore nodes that have been blocked already 348 // Ignore nodes that have been blocked already
344 if (entry.filter && !(entry.filter instanceof WhitelistFilter)) 349 if (entry.filter && !(entry.filter instanceof WhitelistFilter))
345 return; 350 return;
346 351
347 for (let node of nodes) 352 for (let node of nodes)
348 Utils.runAsync(refilterNode, this, node, entry); 353 Utils.runAsync(() => refilterNode(node, entry));
349 } 354 }
350 }; 355 };
351 Policy.init(); 356 Policy.init();
352 357
353 /** 358 /**
354 * Actual nsIContentPolicy and nsIChannelEventSink implementation 359 * Actual nsIContentPolicy and nsIChannelEventSink implementation
355 * @class 360 * @class
356 */ 361 */
357 let PolicyImplementation = 362 let PolicyImplementation =
358 { 363 {
359 classDescription: "Adblock Plus content policy", 364 classDescription: "Adblock Plus content policy",
360 classID: Components.ID("cfeaabe6-1dd1-11b2-a0c6-cb5c268894c9"), 365 classID: Components.ID("cfeaabe6-1dd1-11b2-a0c6-cb5c268894c9"),
361 contractID: "@adblockplus.org/abp/policy;1", 366 contractID: "@adblockplus.org/abp/policy;1",
362 xpcom_categories: ["content-policy", "net-channel-event-sinks"], 367 xpcom_categories: ["content-policy", "net-channel-event-sinks"],
363 368
364 /** 369 /**
365 * Registers the content policy on startup. 370 * Registers the content policy on startup.
366 */ 371 */
367 init: function() 372 init: function()
368 { 373 {
369 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); 374 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
370 try 375 try
371 { 376 {
372 registrar.registerFactory(this.classID, this.classDescription, this.contra ctID, this); 377 registrar.registerFactory(this.classID, this.classDescription, this.contra ctID, this);
373 } 378 }
374 catch (e if e.result == Cr.NS_ERROR_FACTORY_EXISTS) 379 catch (e)
375 { 380 {
376 // See bug 924340 - it might be too early to init now, the old version 381 // See bug 924340 - it might be too early to init now, the old version
377 // we are replacing didn't finish removing itself yet. 382 // we are replacing didn't finish removing itself yet.
378 Utils.runAsync(this.init.bind(this)); 383 if (e.result == Cr.NS_ERROR_FACTORY_EXISTS)
379 return; 384 {
385 Utils.runAsync(this.init.bind(this));
386 return;
387 }
388
389 Cu.reportError(e);
380 } 390 }
381 391
382 let catMan = Utils.categoryManager; 392 let catMan = Utils.categoryManager;
383 for (let category of this.xpcom_categories) 393 for (let category of this.xpcom_categories)
384 catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true); 394 catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true);
385 395
386 // http-on-opening-request is new in Gecko 18, http-on-modify-request can 396 // http-on-opening-request is new in Gecko 18, http-on-modify-request can
387 // be used in earlier releases. 397 // be used in earlier releases.
388 let httpTopic = "http-on-opening-request"; 398 let httpTopic = "http-on-opening-request";
389 if (Services.vc.compare(Utils.platformVersion, "18.0") < 0) 399 if (Services.vc.compare(Utils.platformVersion, "18.0") < 0)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 { 485 {
476 case "content-document-global-created": 486 case "content-document-global-created":
477 { 487 {
478 if (!(subject instanceof Ci.nsIDOMWindow) || !subject.opener) 488 if (!(subject instanceof Ci.nsIDOMWindow) || !subject.opener)
479 return; 489 return;
480 490
481 let uri = additional || Utils.makeURI(subject.location.href); 491 let uri = additional || Utils.makeURI(subject.location.href);
482 if (!Policy.processNode(subject.opener, subject.opener.document, Policy. type.POPUP, uri, false)) 492 if (!Policy.processNode(subject.opener, subject.opener.document, Policy. type.POPUP, uri, false))
483 { 493 {
484 subject.stop(); 494 subject.stop();
485 Utils.runAsync(subject.close, subject); 495 Utils.runAsync(() => subject.close());
486 } 496 }
487 else if (uri.spec == "about:blank") 497 else if (uri.spec == "about:blank")
488 { 498 {
489 // An about:blank pop-up most likely means that a load will be 499 // An about:blank pop-up most likely means that a load will be
490 // initiated synchronously. Set a flag for our "http-on-opening-reques t" 500 // initiated synchronously. Set a flag for our "http-on-opening-reques t"
491 // handler. 501 // handler.
492 this.expectingPopupLoad = true; 502 this.expectingPopupLoad = true;
493 Utils.runAsync(function() 503 Utils.runAsync(function()
494 { 504 {
495 this.expectingPopupLoad = false; 505 this.expectingPopupLoad = false;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 { 628 {
619 if (outer) 629 if (outer)
620 throw Cr.NS_ERROR_NO_AGGREGATION; 630 throw Cr.NS_ERROR_NO_AGGREGATION;
621 return this.QueryInterface(iid); 631 return this.QueryInterface(iid);
622 } 632 }
623 }; 633 };
624 PolicyImplementation.init(); 634 PolicyImplementation.init();
625 635
626 /** 636 /**
627 * Nodes scheduled for post-processing (might be null). 637 * Nodes scheduled for post-processing (might be null).
628 * @type Array of Node 638 * @type Node[]
629 */ 639 */
630 let scheduledNodes = null; 640 let scheduledNodes = null;
631 641
632 /** 642 /**
633 * Schedules a node for post-processing. 643 * Schedules a node for post-processing.
634 */ 644 */
635 function schedulePostProcess(/**Element*/ node) 645 function schedulePostProcess(/**Element*/ node)
636 { 646 {
637 if (scheduledNodes) 647 if (scheduledNodes)
638 scheduledNodes.push(node); 648 scheduledNodes.push(node);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 if (!wnd || wnd.closed) 818 if (!wnd || wnd.closed)
809 return; 819 return;
810 820
811 if (entry.type == Policy.type.OBJECT) 821 if (entry.type == Policy.type.OBJECT)
812 { 822 {
813 node.removeEventListener("mouseover", objectMouseEventHander, true); 823 node.removeEventListener("mouseover", objectMouseEventHander, true);
814 node.removeEventListener("mouseout", objectMouseEventHander, true); 824 node.removeEventListener("mouseout", objectMouseEventHander, true);
815 } 825 }
816 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; 826 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ;
817 } 827 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld