Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an al...
Closed this issue · 7 comments
Atom Version: 1.0.0
System: Ubuntu 15.04
Thrown From: mocha-runner package, v1.0.2
Stack Trace
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'".
At /home/octod/workspace/ride-css/node_modules/express/node_modules/depd/index.js:421
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'".
at Function.wrapfunction (/home/octod/workspace/ride-css/node_modules/express/node_modules/depd/index.js:421:5)
at Object.<anonymous> (/home/octod/workspace/ride-css/node_modules/express/node_modules/send/index.js:156:47)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/usr/share/atom/resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/home/octod/workspace/ride-css/node_modules/express/lib/utils.js:19:12)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/usr/share/atom/resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/home/octod/workspace/ride-css/node_modules/express/lib/view.js:19:13)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/usr/share/atom/resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/home/octod/workspace/ride-css/node_modules/express/lib/application.js:22:12)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/usr/share/atom/resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/home/octod/workspace/ride-css/node_modules/express/lib/express.js:17:13)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/usr/share/atom/resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/home/octod/workspace/ride-css/node_modules/express/index.js:11:18)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/usr/share/atom/resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at Object.<anonymous> (/home/octod/workspace/ride-css/test/server.js:1:77)
at Module._compile (module.js:452:26)
at Object.loadFile [as .js] (/usr/share/atom/resources/app.asar/src/babel.js:162:21)
at Module.load (module.js:347:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:357:17)
at require (module.js:376:17)
at /home/octod/.atom/packages/mocha-runner/node_modules/mocha/lib/mocha.js:192:27
at Array.forEach (native)
at Mocha.loadFiles (/home/octod/.atom/packages/mocha-runner/node_modules/mocha/lib/mocha.js:189:14)
at Mocha.run (/home/octod/.atom/packages/mocha-runner/node_modules/mocha/lib/mocha.js:422:31)
at Runner.run (/home/octod/.atom/packages/mocha-runner/lib/runner.js:63:9)
at /home/octod/.atom/packages/mocha-runner/lib/main.js:40:21
at /home/octod/.atom/packages/mocha-runner/lib/window.js:38:5
at CallbacksRegistry.module.exports.CallbacksRegistry.apply (/usr/share/atom/resources/atom.asar/common/api/lib/callbacks-registry.js:35:42)
at EventEmitter.<anonymous> (/usr/share/atom/resources/atom.asar/renderer/api/lib/remote.js:146:30)
at emitTwo (events.js:87:13)
at EventEmitter.emit (events.js:169:7)
Commands
-4:20.5.0 application:open-folder (atom-pane.pane.active)
-3:22.9.0 command-palette:toggle (atom-pane.pane.active)
-3:22.2.0 core:confirm (atom-text-editor.editor.mini.is-focused)
-3:22.2.0 gulp-control:toggle (atom-pane.pane.active)
-3:19.9.0 core:close (atom-pane.pane.active)
-3:16.3.0 command-palette:toggle (atom-pane.pane.active)
-3:14 core:select-all (atom-text-editor.editor.mini.is-focused)
2x -3:11.8.0 core:move-down (atom-text-editor.editor.mini.is-focused)
-3:11.4.0 core:confirm (atom-text-editor.editor.mini.is-focused)
-3:11.4.0 settings-view:install-packages-and-themes (atom-pane.pane.active)
-3:09.7.0 core:select-all (atom-text-editor.editor.mini.is-focused)
2x -3:08.3.0 core:confirm (atom-text-editor.editor.mini.is-focused)
-0:05.4.0 command-palette:toggle (div.settings-view.pane-item)
-0:04.0 core:backspace (atom-text-editor.editor.mini.is-focused)
-0:01.6.0 core:confirm (atom-text-editor.editor.mini.is-focused)
-0:01.6.0 mocha-runner:run-specs (div.settings-view.pane-item)
Config
{
"core": {},
"mocha-runner": {}
}
Installed Packages
# User
Stylus, v1.0.0
atom-typescript, v5.0.10
atom-yeoman, v0.3.11
build, v0.40.0
color-picker, v2.0.7
emmet, v2.3.12
file-icons, v1.5.8
grunt-runner, v0.10.0
gulp-control, v0.4.2
highlight-line, v0.11.0
language-cshtml, v0.1.1
language-jade, v0.4.0
linter, v1.1.0
minimap, v4.10.2
mocha-runner, v1.0.2
omnisharp-atom, v0.17.3
project-manager, v1.15.10
# Dev
No dev packages
Neat.... thanks for the report, will look into this probably this weekend at some point.
This looks like a problem with your test script -- do you get the same thing running mocha
without using mocha-runner ?
I'm sorry but the test works normally when launched by the command line.
Ok, so there's a few problems going on.
- Fixing the error is easy enough - atom has a CSP configuration that blocks eval/etc. This can be worked around by using loophole which basically runs the code through the
vm
module. - With that fixed, the fs calls were failing with an inability to find anything. process.cwd() is still the atom directory when it runs, so I swap it out before the tests start and swap it back once finished.
- For some reason, the
require
declaration in mocha.opts isn't coming through, so each of the tests is failing because it can't find should. I'm not entirely sure why this is -- it requires a bit more investigation on my part to figure out (digging through mocha code) - this is the big one: the express app isn't shutting down once the test suite has finished. This one I'm not entirely sure how to fix. If you run mocha from the command line, the process dies at the end taking express along with it. The way I have this setup, the mocha code is running inside the atom process which doesn't die. This is a doozy and I'm at a bit of a loss to figure out how to fix it.
I've fixed the first two and pushed up as 1.1.0 -- (in all honesty, screwed up the apm command, intended that to be 1.0.3) -- anyway, I'll need to think how to fix the others.
I was able to fix the doosy -- actually not as hard as I originally thought. I was able to create a fork to a worker js file that did the actual running. Of course it has zero atom context so say goodbye to potentially running package specs with this runner -- but it does clean itself up nicely now.
Latest version is 1.1.1 -- last thing I need to do is figure out why things required through mocha.opts aren't coming through.
I've fixed up the rest of the problems and am now able to run the ride-css tests successfully.
Closing this now -- thanks for reporting!
Great! Thanks for the help and the nice work!