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

Side by Side Diff: lib/contentPolicy.js

Issue 29329568: Issue 3208 - Moved checks related to context elements from Policy.shouldProcess() to PolicyImplemen… (Closed)
Patch Set: Created Oct. 30, 2015, 11:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 if (testWnd.parent == testWnd) 188 if (testWnd.parent == testWnd)
189 break; 189 break;
190 190
191 if (testWnd == testSitekeyWnd) 191 if (testWnd == testSitekeyWnd)
192 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent); 192 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent);
193 testWnd = testWnd.parent; 193 testWnd = testWnd.parent;
194 } 194 }
195 } 195 }
196 196
197 // Data loaded by plugins should be attached to the document
198 if (contentType == "OBJECT_SUBREQUEST" && node instanceof Ci.nsIDOMElement)
199 node = node.ownerDocument;
200
201 // Fix type for objects misrepresented as frames or images
202 if (contentType != "OBJECT" && (node instanceof Ci.nsIDOMHTMLObjectElement | | node instanceof Ci.nsIDOMHTMLEmbedElement))
203 contentType = "OBJECT";
204
205 if (!match && contentType == "ELEMHIDE") 197 if (!match && contentType == "ELEMHIDE")
206 { 198 {
207 match = location; 199 match = location;
208 location = match.text.replace(/^.*?#/, '#'); 200 location = match.text.replace(/^.*?#/, '#');
209 201
210 if (!match.isActiveOnDomain(docDomain)) 202 if (!match.isActiveOnDomain(docDomain))
211 return true; 203 return true;
212 204
213 let exception = ElemHide.getException(match, docDomain); 205 let exception = ElemHide.getException(match, docDomain);
214 if (exception) 206 if (exception)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 return Ci.nsIContentPolicy.ACCEPT; 376 return Ci.nsIContentPolicy.ACCEPT;
385 377
386 // Ignore standalone objects 378 // Ignore standalone objects
387 if (contentType == Ci.nsIContentPolicy.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))
388 return Ci.nsIContentPolicy.ACCEPT; 380 return Ci.nsIContentPolicy.ACCEPT;
389 381
390 let wnd = Utils.getWindow(node); 382 let wnd = Utils.getWindow(node);
391 if (!wnd) 383 if (!wnd)
392 return Ci.nsIContentPolicy.ACCEPT; 384 return Ci.nsIContentPolicy.ACCEPT;
393 385
386 // Data loaded by plugins should be associated with the document
387 if (contentType == Ci.nsIContentPolicy.TYPE_OBJECT_SUBREQUEST && node instan ceof Ci.nsIDOMElement)
388 node = node.ownerDocument;
389
390 // Fix type for objects misrepresented as frames or images
391 if (contentType != Ci.nsIContentPolicy.TYPE_OBJECT && (node instanceof Ci.ns IDOMHTMLObjectElement || node instanceof Ci.nsIDOMHTMLEmbedElement))
392 contentType = Ci.nsIContentPolicy.TYPE_OBJECT;
393
394 let location = Utils.unwrapURL(contentLocation); 394 let location = Utils.unwrapURL(contentLocation);
395 let result = Policy.processNode(wnd, node, types.get(contentType), location. spec, false); 395 let result = Policy.processNode(wnd, node, types.get(contentType), location. spec, false);
396 return (result ? Ci.nsIContentPolicy.ACCEPT : Ci.nsIContentPolicy.REJECT_REQ UEST); 396 return (result ? Ci.nsIContentPolicy.ACCEPT : Ci.nsIContentPolicy.REJECT_REQ UEST);
397 }, 397 },
398 398
399 shouldProcess: function(contentType, contentLocation, requestOrigin, insecNode , mimeType, extra) 399 shouldProcess: function(contentType, contentLocation, requestOrigin, insecNode , mimeType, extra)
400 { 400 {
401 return Ci.nsIContentPolicy.ACCEPT; 401 return Ci.nsIContentPolicy.ACCEPT;
402 }, 402 },
403 403
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 if (!wnd || wnd.closed) 685 if (!wnd || wnd.closed)
686 return; 686 return;
687 687
688 if (entry.type == "OBJECT") 688 if (entry.type == "OBJECT")
689 { 689 {
690 node.removeEventListener("mouseover", objectMouseEventHander, true); 690 node.removeEventListener("mouseover", objectMouseEventHander, true);
691 node.removeEventListener("mouseout", objectMouseEventHander, true); 691 node.removeEventListener("mouseout", objectMouseEventHander, true);
692 } 692 }
693 Policy.processNode(wnd, node, entry.type, entry.location, true); 693 Policy.processNode(wnd, node, entry.type, entry.location, true);
694 } 694 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld