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

Delta Between Two Patch Sets: lib/child/elemHide.js

Issue 29329754: Issue 3251 - Delegate processing of element hiding hits to shouldAllowAsync() so that hits show up (Closed)
Left Patch Set: Reversed logic and improved JSDoc comments Created Nov. 6, 2015, 11:26 a.m.
Right Patch Set: Rebased Created Nov. 12, 2015, 3:04 p.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 | « lib/child/contentPolicy.js ('k') | lib/contentPolicy.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
(...skipping 16 matching lines...) Expand all
27 if (property && property.get) 27 if (property && property.get)
28 delete proto.Components; 28 delete proto.Components;
29 } 29 }
30 catch (e) 30 catch (e)
31 { 31 {
32 Cu.reportError(e); 32 Cu.reportError(e);
33 } 33 }
34 34
35 let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); 35 let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
36 36
37 let {shouldAllow} = require("child/contentPolicy"); 37 let {shouldAllowAsync} = require("child/contentPolicy");
38 let {Utils} = require("utils"); 38 let {Utils} = require("utils");
39 39
40 // The allowXBL binding below won't have any effect on the element. For elements 40 // The allowXBL binding below won't have any effect on the element. For elements
41 // that should be hidden however we don't return any binding at all, this makes 41 // that should be hidden however we don't return any binding at all, this makes
42 // Gecko stop constructing the node - it cannot be shown. 42 // Gecko stop constructing the node - it cannot be shown.
43 const allowXBL = "<bindings xmlns='http://www.mozilla.org/xbl'><binding id='dumm y' bindToUntrustedContent='true'/></bindings>"; 43 const allowXBL = "<bindings xmlns='http://www.mozilla.org/xbl'><binding id='dumm y' bindToUntrustedContent='true'/></bindings>";
44 const hideXBL = "<bindings xmlns='http://www.mozilla.org/xbl'/>"; 44 const hideXBL = "<bindings xmlns='http://www.mozilla.org/xbl'/>";
45 45
46 /** 46 /**
47 * about: URL module used to count hits. 47 * about: URL module used to count hits.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 notificationCallbacks: null, 124 notificationCallbacks: null,
125 loadFlags: 0, 125 loadFlags: 0,
126 loadGroup: null, 126 loadGroup: null,
127 name: null, 127 name: null,
128 status: Cr.NS_OK, 128 status: Cr.NS_OK,
129 129
130 asyncOpen: function(listener, context) 130 asyncOpen: function(listener, context)
131 { 131 {
132 let processResponse = (allow) => 132 let processResponse = (allow) =>
133 { 133 {
134 let data = (allow ? allowXBL : hideXBL); 134 let data = (allow ? allowXBL : hideXBL);
tschuster 2015/11/18 13:47:52 Oh yeah. That is pretty subtle. Especially with th
135 let stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci .nsIStringInputStream); 135 let stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci .nsIStringInputStream);
136 stream.setData(data, data.length); 136 stream.setData(data, data.length);
137 137
138 try { 138 try {
139 listener.onStartRequest(this, context); 139 listener.onStartRequest(this, context);
140 } catch(e) {} 140 } catch(e) {}
141 try { 141 try {
142 listener.onDataAvailable(this, context, stream, 0, stream.available()); 142 listener.onDataAvailable(this, context, stream, 0, stream.available());
143 } catch(e) {} 143 } catch(e) {}
144 try { 144 try {
145 listener.onStopRequest(this, context, Cr.NS_OK); 145 listener.onStopRequest(this, context, Cr.NS_OK);
146 } catch(e) {} 146 } catch(e) {}
147 }; 147 };
148 148
149 let window = Utils.getRequestWindow(this); 149 let window = Utils.getRequestWindow(this);
150 shouldAllow(window, window.document, "ELEMHIDE", this.key, processResponse); 150 shouldAllowAsync(window, window.document, "ELEMHIDE", this.key, processRespo nse);
151 }, 151 },
152 152
153 asyncOpen2: function(listener) 153 asyncOpen2: function(listener)
154 { 154 {
155 if (!this.loadInfo.triggeringPrincipal.equals(Utils.systemPrincipal)) 155 if (!this.loadInfo.triggeringPrincipal.equals(Utils.systemPrincipal))
156 throw Cr.NS_ERROR_FAILURE; 156 throw Cr.NS_ERROR_FAILURE;
157 this.asyncOpen(listener, null); 157 this.asyncOpen(listener, null);
158 }, 158 },
159 159
160 open: function() 160 open: function()
(...skipping 12 matching lines...) Expand all
173 { 173 {
174 throw Cr.NS_ERROR_NOT_IMPLEMENTED; 174 throw Cr.NS_ERROR_NOT_IMPLEMENTED;
175 }, 175 },
176 resume: function() 176 resume: function()
177 { 177 {
178 throw Cr.NS_ERROR_NOT_IMPLEMENTED; 178 throw Cr.NS_ERROR_NOT_IMPLEMENTED;
179 }, 179 },
180 180
181 QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel, Ci.nsIRequest]) 181 QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel, Ci.nsIRequest])
182 }; 182 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld