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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: inject.preload.js
===================================================================
--- a/inject.preload.js
+++ b/inject.preload.js
@@ -133,16 +133,32 @@
let thisShadow = shadowRoot(this);
return thisShadow == ourShadowRoot ? null : thisShadow;
}
});
}
}
/*
+ * Closed shadowRoot prevention.
+ * https://issues.adblockplus.org/ticket/5650
+ */
+ if ("attachShadow" in Element.prototype)
+ {
+ 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.
+ Element.prototype.attachShadow = options =>
+ {
+ if (options && options.mode == "closed")
+ options.mode = "open";
lainverse 2017/09/29 15:57:35 This is indeed the easiest solution, but I think t
+
+ return this._attachShadow(options);
+ };
+ }
+
+ /*
* Shared request checking code, used by both the WebSocket and
* RTCPeerConnection wrappers.
*/
let RealCustomEvent = window.CustomEvent;
// If we've been injected into a frame via contentWindow then we can simply
// grab the copy of checkRequest left for us by the parent document. Otherwise
// we need to set it up now, along with the event handling functions.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld