use of org.mozilla.javascript.EcmaError in project cucumber-jvm by cucumber.
the class HTMLFormatterTest method writes_valid_report_js.
@Test
public void writes_valid_report_js() throws IOException {
URL reportJs = new URL(outputDir, "report.js");
Context cx = Context.enter();
Global scope = new Global(cx);
try {
cx.evaluateReader(scope, new InputStreamReader(reportJs.openStream(), "UTF-8"), reportJs.getFile(), 1, null);
fail("Should have failed");
} catch (EcmaError expected) {
assertTrue(expected.getMessage().startsWith("ReferenceError: \"document\" is not defined."));
}
}
use of org.mozilla.javascript.EcmaError in project BPjs by bThink-BGU.
the class JsEventSet method contains.
@Override
public boolean contains(BEvent event) {
try {
Object result = predicate.call(Context.getCurrentContext(), predicate, predicate.getParentScope(), new Object[] { Context.javaToJS(event, predicate.getParentScope()) });
Boolean res = (Boolean) Context.jsToJava(result, Boolean.class);
if (res == null) {
throw new RuntimeException("JS Predicate returned null, not a boolean value. " + predicate.toString());
}
return res;
} catch (EvaluatorException ee) {
throw new BPjsRuntimeException("JS Predicate did not return a boolean value.", ee);
} catch (EcmaError ee) {
throw new BPjsRuntimeException("Error evaluating JS Predicate:" + ee.getMessage(), ee);
}
}
Aggregations