mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Merge branch 'master' into improve-backtraces
This commit is contained in:
commit
bb8810fdd1
5 changed files with 46202 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
sudo: false
|
||||
language: ruby
|
||||
rvm:
|
||||
- 1.9.3
|
||||
|
|
|
@ -64,7 +64,7 @@ older stock runtimes like JSC on OSX and JScript on Windows may not. You should
|
|||
only count on ES3 features being available. Prefer feature checking these APIs
|
||||
rather than hard coding support for specific runtimes.
|
||||
|
||||
**Can I ExecJS be used to sandbox scripts?**
|
||||
**Can ExecJS be used to sandbox scripts?**
|
||||
|
||||
No, ExecJS shouldn't be used for any security related sandboxing. Since runtimes
|
||||
are automatically detected, each runtime has different sandboxing properties.
|
||||
|
|
43557
test/fixtures/babel.js
vendored
Normal file
43557
test/fixtures/babel.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2613
test/fixtures/uglify.js
vendored
Normal file
2613
test/fixtures/uglify.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -330,9 +330,39 @@ class TestExecJS < Test
|
|||
end
|
||||
end
|
||||
|
||||
def test_babel
|
||||
assert source = File.read(File.expand_path("../fixtures/babel.js", __FILE__))
|
||||
source = <<-JS
|
||||
var self = this;
|
||||
#{source}
|
||||
babel.eval = function(code) {
|
||||
return eval(babel.transform(code)["code"]);
|
||||
}
|
||||
JS
|
||||
context = ExecJS.compile(source)
|
||||
assert_equal 64, context.call("babel.eval", "((x) => x * x)(8)")
|
||||
end
|
||||
|
||||
def test_coffeescript
|
||||
assert source = File.read(File.expand_path("../fixtures/coffee-script.js", __FILE__))
|
||||
context = ExecJS.compile(source)
|
||||
assert_equal 64, context.call("CoffeeScript.eval", "((x) -> x * x)(8)")
|
||||
end
|
||||
|
||||
def test_uglify
|
||||
assert source = File.read(File.expand_path("../fixtures/uglify.js", __FILE__))
|
||||
source = <<-JS
|
||||
#{source}
|
||||
|
||||
function uglify(source) {
|
||||
var ast = UglifyJS.parse(source);
|
||||
var stream = UglifyJS.OutputStream();
|
||||
ast.print(stream);
|
||||
return stream.toString();
|
||||
}
|
||||
JS
|
||||
context = ExecJS.compile(source)
|
||||
assert_equal "function foo(bar){return bar}",
|
||||
context.call("uglify", "function foo(bar) {\n return bar;\n}")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue