I almost have everything working when packaging up the WebGL build into a chrome app but when I attempt to play a youtube video by triggering an external javascript call I get the following error.
exception thrown: EvalError: Refused to evaluate a string as JavaScript because ‘unsafe-eval’ is not an allowed source of script in the following Content Security Policy directive: “default-src ‘self’ blob: filesystem: chrome-extension-resource:”.
,EvalError: Refused to evaluate a string as JavaScript because ‘unsafe-eval’ is not an allowed source of script in the following Content Security Policy directive: “default-src ‘self’ blob: filesystem: chrome-extension-resource:”.
at eval (native)
at _JS_Eval_EvalJS (blob:chrome-extension%3A//mekdombnlfdacdfgknfccaphfbnogjil/75908f11-79dc-4daa-9b23-cc9d92853612:1:159628)
at Array.tdc (blob:chrome-extension%3A//mekdombnlfdacdfgknfccaphfbnogjil/75908f11-79dc-4daa-9b23-cc9d92853612:15:517679)
at AEl (blob:chrome-extension%3A//mekdombnlfdacdfgknfccaphfbnogjil/75908f11-79dc-4daa-9b23-cc9d92853612:12:1130355)
at yEl (blob:chrome-extension%3A//mekdombnlfdacdfgknfccaphfbnogjil/75908f11-79dc-4daa-9b23-cc9d92853612:12:1129885)
at Xjg (blob:chrome-extension%3A//mekdombnlfdacdfgknfccaphfbnogjil/75908f11-79dc-4daa-9b23-cc9d92853612:14:970351)
at dTh (blob:chrome-extension%3A//mekdombnlfdacdfgknfccaphfbnogjil/75908f11-79dc-4daa-9b23-cc9d92853612:5:642857)
at Array.eTh (blob:chrome-extension%3A//mekdombnlfdacdfgknfccaphfbnogjil/75908f11-79dc-4daa-9b23-cc9d92853612:5:644669)
at Array.rBp (blob:chrome-extension%3A//mekdombnlfdacdfgknfccaphfbnogjil/75908f11-79dc-4daa-9b23-cc9d92853612:8:419230)
at _M (blob:chrome-extension%3A//mekdombnlfdacdfgknfccaphfbnogjil/75908f11-79dc-4daa-9b23-cc9d92853612:26:350241)
Based on this documentation (Content Security Policy | Apps | Chrome for Developers ) it seems this is blocked for security reasons.
You can’t use string-to-JavaScript methods like eval() and new Function().
Does anyone have any suggestions on how I can trigger javascript functions from within Unity. I’m assuming Application.ExternalCall needs to use eval?
The reason we play our video in youtube and not in unity is because we were having issues on specific devices when attempting to create the video texture in WebGL and so far it been a big improvement in terms of app stability.
crushforth:
I almost have everything working when packaging up the WebGL build into a chrome app but when I attempt to play a youtube video by triggering an external javascript call I get the following error.
Based on this documentation (https://developer.chrome.com/apps/contentSecurityPolicy ) it seems this is blocked for security reasons.
You can’t use string-to-JavaScript methods like eval() and new Function().
Does anyone have any suggestions on how I can trigger javascript functions from within Unity. I’m assuming Application.ExternalCall needs to use eval?
The reason we play our video in youtube and not in unity is because we were having issues on specific devices when attempting to create the video texture in WebGL and so far it been a big improvement in terms of app stability.
Hello crushforth.
Consider using jslib plugin instead, this way you should not encounter any security restrictions: http://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
1 Like
Thanks. I’ll get on implementing this.