String code = "}) alert('watch out')";
StringSource<IncludeDef> source = new StringSource<>(descriptor, code, null, null);
JavascriptIncludeDefHandler handler = new JavascriptIncludeDefHandler(descriptor, source);
IncludeDef def = handler.getDefinition();
try {
def.validateDefinition();
fail("Invalid breaking JS wasn't validated");
} catch (InvalidDefinitionException t) {
String message = t.getMessage();
assertTrue("Unexpected message: " + t,
message.contains("$JsonStreamParseException: Expected ',' or '}', got FUNCTION_ARGS_END"));