2
votes

If I download the minified YUI3 loader and include it in my background.html I get the following error:

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' chrome-extension-resource:".

Can YUI3 be used in an extension?

2

2 Answers

1
votes

It looks like it's blocking you from using eval(). Make sure you have the following line in your manifest.

"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"

0
votes

This is how I was able to do it. Clone yui3 and yui3-gallery from git and in my extension tree, add the modules I need. Then load config.js from popup.html and background.html. The file looks like this:

YUI_config = {
    filter: "raw",
    base: "yui3/build/",
    root: "yui3/build/",
    comboBase: "/combo?",
    combine: false,
    groups: {
        gallery: {
            base: "yui3-gallery/build/",
            root: "yui3-gallery/build/",
            comboBase: "/combo?",
            combine: false,
            patterns: {
                "gallery-": {},
                "gallerycss-": { type: "css" }
            }
        }
    }
};

Now it all works!