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: Use regexp, ignore case Created May 30, 2017, 12:22 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
diff --git a/inject.preload.js b/inject.preload.js
index c35c071ce48f748401a0e3a3de6f267b51712f37..e24c9c9c65fa10ba087c2037b245f455eadce9fe 100644
--- a/inject.preload.js
+++ b/inject.preload.js
@@ -387,10 +387,16 @@ 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");
+
+ if (typeof sandbox != "string" || /(^|\s)allow-scripts(\s|$)/i.test(sandbox))
+ {
+ 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