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

Unified Diff: inject.preload.js

Issue 29451568: Issue 4494 - Avoid causing some sandbox related warnings (Closed)
Patch Set: Created May 30, 2017, 9:22 a.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
diff --git a/inject.preload.js b/inject.preload.js
index c35c071ce48f748401a0e3a3de6f267b51712f37..3b1e1f61bb9da682e7202f8a9549c82ad2fcb248 100644
--- a/inject.preload.js
+++ b/inject.preload.js
@@ -387,10 +387,15 @@ function injected(eventName, injectedIntoContentWindow)
if (document instanceof HTMLDocument)
{
- let script = document.createElement("script");
- script.type = "application/javascript";
- script.async = false;
- script.textContent = "(" + injected + ")('" + randomEventName + "');";
- document.documentElement.appendChild(script);
- document.documentElement.removeChild(script);
+ let sandbox = window.frameElement &&
+ window.frameElement.getAttribute("sandbox");
Sebastian Noack 2017/05/30 09:41:16 Nit: The indentation looks a bit off here.
kzar 2017/05/30 10:20:31 Done.
+ if (typeof sandbox != "string" || sandbox.includes("allow-scripts"))
Sebastian Noack 2017/05/30 09:41:16 What if allow-scripts is misspelled like "allow-sc
kzar 2017/05/30 10:20:31 Well a false-positive doesn't matter here, it just
Sebastian Noack 2017/05/30 10:36:46 I wonder whether we even need this check. If scrip
Sebastian Noack 2017/05/30 10:43:34 Never mind. We are in the extension's content scri
kzar 2017/05/30 12:27:15 Doing some further reading I realised that window.
+ {
+ let script = document.createElement("script");
+ script.type = "application/javascript";
+ script.async = false;
+ script.textContent = "(" + injected + ")('" + randomEventName + "');";
+ document.documentElement.appendChild(script);
+ document.documentElement.removeChild(script);
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld