eden_lane
eden_lane

Reputation: 108

EvalError when trying to load realtime data model

I'm trying to get realtime data model with gapi.drive.realtime.load method in my Chrome Packaged App :

gapi.drive.realtime.load(fileId, onLoad)

but I'm caught an EvalError:

Uncaught 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: "script-src 'self' apis.google.com drive.google.com".

Of courcse, I can just add 'unsafe-eval' to manifest, but I guess it is bad way to solve this problem. Can you suggest better solution ?

Upvotes: 1

Views: 155

Answers (1)

sowbug
sowbug

Reputation: 4672

A packaged app can't have a less restrictive CSP than the default, so your proposed change to the manifest wouldn't have worked. Instead, create a sandboxed iframe that allows eval(), then message back and forth between the iframe and your app. This is a good example with links to further documentation.

Upvotes: 2

Related Questions