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

Unified Diff: inject.preload.js

Issue 29807586: Issue 6744 - Fixed wrapper injection on Chrome 67 (Closed)
Patch Set: Created June 14, 2018, 8:53 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
@@ -363,15 +363,26 @@
if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox))
{
let script = document.createElement("script");
+ let code = "(" + injected + ")('" + randomEventName + "');";
+
script.type = "application/javascript";
script.async = false;
- // Firefox 58 only bypasses site CSPs when assigning to 'src'.
- let url = URL.createObjectURL(new Blob([
- "(" + injected + ")('" + randomEventName + "');"
- ]));
- script.src = url;
- document.documentElement.appendChild(script);
+
+ // Firefox 58 only bypasses site CSPs when assigning to 'src',
+ // while Chrome 67 only bypasses site CSPs when using 'textContent'.
+ if (browser.runtime.getURL("").startsWith("chrome-extension://"))
Sebastian Noack 2018/06/14 21:03:09 FWIW, I'm not too happy with this check, but I don
kzar 2018/06/15 07:52:07 Acknowledged.
+ {
+ script.textContent = code;
+ document.documentElement.appendChild(script);
+ }
+ else
+ {
+ let url = URL.createObjectURL(new Blob([code]));
+ script.src = url;
+ document.documentElement.appendChild(script);
+ URL.revokeObjectURL(url);
+ }
+
document.documentElement.removeChild(script);
- URL.revokeObjectURL(url);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld