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

Delta Between Two Patch Sets: inject.preload.js

Issue 29559650: Issue 5650 - Prevent attachShadowRoot to create closed shadow root. (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: reformat code Created Sept. 29, 2017, 3:15 p.m.
Right Patch Set: Capture the original attachShadow instead. Created Sept. 29, 2017, 4:54 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 | « no previous file | no next file » | 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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 }); 136 });
137 } 137 }
138 } 138 }
139 139
140 /* 140 /*
141 * Closed shadowRoot prevention. 141 * Closed shadowRoot prevention.
142 * https://issues.adblockplus.org/ticket/5650 142 * https://issues.adblockplus.org/ticket/5650
143 */ 143 */
144 if ("attachShadow" in Element.prototype) 144 if ("attachShadow" in Element.prototype)
145 { 145 {
146 Element.prototype._attachShadow = Element.prototype.attachShadow; 146 let _attachShadow = Element.prototype.attachShadow;
lainverse 2017/09/29 15:57:35 You left unwrapped _attachShadow right in the same
hub 2017/09/29 16:54:29 good point. done.
147 Element.prototype.attachShadow = options => 147 Element.prototype.attachShadow = options =>
148 { 148 {
149 if (options && options.mode == "closed") 149 if (options && options.mode == "closed")
150 options.mode = "open"; 150 options.mode = "open";
lainverse 2017/09/29 15:57:35 This is indeed the easiest solution, but I think t
151 151
152 return this._attachShadow(options); 152 return _attachShadow.call(this, options);
lainverse 2017/10/02 06:41:21 Arrow functions doesn't have their own 'this' and
153 }; 153 };
154 } 154 }
155 155
156 /* 156 /*
157 * Shared request checking code, used by both the WebSocket and 157 * Shared request checking code, used by both the WebSocket and
158 * RTCPeerConnection wrappers. 158 * RTCPeerConnection wrappers.
159 */ 159 */
160 let RealCustomEvent = window.CustomEvent; 160 let RealCustomEvent = window.CustomEvent;
161 161
162 // If we've been injected into a frame via contentWindow then we can simply 162 // If we've been injected into a frame via contentWindow then we can simply
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox)) 412 if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox))
413 { 413 {
414 let script = document.createElement("script"); 414 let script = document.createElement("script");
415 script.type = "application/javascript"; 415 script.type = "application/javascript";
416 script.async = false; 416 script.async = false;
417 script.textContent = "(" + injected + ")('" + randomEventName + "');"; 417 script.textContent = "(" + injected + ")('" + randomEventName + "');";
418 document.documentElement.appendChild(script); 418 document.documentElement.appendChild(script);
419 document.documentElement.removeChild(script); 419 document.documentElement.removeChild(script);
420 } 420 }
421 } 421 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld