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: Created Sept. 29, 2017, 2:49 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;
147 Element.prototype.attachShadow = options => {
148 if (options && options.mode == "closed") {
149 options.mode = "open";
150 }
151 return this._attachShadow(options);
152 };
153 }
154
155 /*
141 * Shared request checking code, used by both the WebSocket and 156 * Shared request checking code, used by both the WebSocket and
142 * RTCPeerConnection wrappers. 157 * RTCPeerConnection wrappers.
143 */ 158 */
144 let RealCustomEvent = window.CustomEvent; 159 let RealCustomEvent = window.CustomEvent;
145 160
146 // If we've been injected into a frame via contentWindow then we can simply 161 // 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 162 // 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. 163 // we need to set it up now, along with the event handling functions.
149 if (injectedIntoContentWindow) 164 if (injectedIntoContentWindow)
150 checkRequest = window[eventName]; 165 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)) 411 if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox))
397 { 412 {
398 let script = document.createElement("script"); 413 let script = document.createElement("script");
399 script.type = "application/javascript"; 414 script.type = "application/javascript";
400 script.async = false; 415 script.async = false;
401 script.textContent = "(" + injected + ")('" + randomEventName + "');"; 416 script.textContent = "(" + injected + ")('" + randomEventName + "');";
402 document.documentElement.appendChild(script); 417 document.documentElement.appendChild(script);
403 document.documentElement.removeChild(script); 418 document.documentElement.removeChild(script);
404 } 419 }
405 } 420 }
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