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

Side by Side Diff: inject.preload.js

Issue 29559650: Issue 5650 - Prevent attachShadowRoot to create closed shadow root. (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: reformat code Created Sept. 29, 2017, 3:15 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-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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 configurable: true, enumerable: true, get() 131 configurable: true, enumerable: true, get()
132 { 132 {
133 let thisShadow = shadowRoot(this); 133 let thisShadow = shadowRoot(this);
134 return thisShadow == ourShadowRoot ? null : thisShadow; 134 return thisShadow == ourShadowRoot ? null : thisShadow;
135 } 135 }
136 }); 136 });
137 } 137 }
138 } 138 }
139 139
140 /* 140 /*
141 * Closed shadowRoot prevention.
142 * https://issues.adblockplus.org/ticket/5650
143 */
144 if ("attachShadow" in Element.prototype)
145 {
146 Element.prototype._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 =>
148 {
149 if (options && options.mode == "closed")
150 options.mode = "open";
lainverse 2017/09/29 15:57:35 This is indeed the easiest solution, but I think t
151
152 return this._attachShadow(options);
153 };
154 }
155
156 /*
141 * Shared request checking code, used by both the WebSocket and 157 * Shared request checking code, used by both the WebSocket and
142 * RTCPeerConnection wrappers. 158 * RTCPeerConnection wrappers.
143 */ 159 */
144 let RealCustomEvent = window.CustomEvent; 160 let RealCustomEvent = window.CustomEvent;
145 161
146 // 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
147 // grab the copy of checkRequest left for us by the parent document. Otherwise 163 // grab the copy of checkRequest left for us by the parent document. Otherwise
148 // we need to set it up now, along with the event handling functions. 164 // we need to set it up now, along with the event handling functions.
149 if (injectedIntoContentWindow) 165 if (injectedIntoContentWindow)
150 checkRequest = window[eventName]; 166 checkRequest = window[eventName];
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox)) 412 if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox))
397 { 413 {
398 let script = document.createElement("script"); 414 let script = document.createElement("script");
399 script.type = "application/javascript"; 415 script.type = "application/javascript";
400 script.async = false; 416 script.async = false;
401 script.textContent = "(" + injected + ")('" + randomEventName + "');"; 417 script.textContent = "(" + injected + ")('" + randomEventName + "');";
402 document.documentElement.appendChild(script); 418 document.documentElement.appendChild(script);
403 document.documentElement.removeChild(script); 419 document.documentElement.removeChild(script);
404 } 420 }
405 } 421 }
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