public static String runScript (String testDir, String test, String engine) throws FileNotFoundException, IOException {
Context cx = Context.enter();
Scriptable scope = cx.initStandardObjects();
cx.evaluateReader(scope, new FileReader(new File(testDir + File.separator + "html5" + File.separator + "emulator.js")), "library", 1, null);
cx.evaluateString(scope, engine, "<engine>", 1, null);
Object result = cx.evaluateReader(scope, new FileReader(new File(testDir + File.separator + "html5" + File.separator + test)), "test", 1, null);
String res = Context.toString(result);
Context.exit();