[362065] StringIndexOutOfBoundsException translating documents with empty event handler attributes
diff --git a/tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/translation/TestHtmlTranslation.java b/tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/translation/TestHtmlTranslation.java index 18a5c12..35be762 100644 --- a/tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/translation/TestHtmlTranslation.java +++ b/tests/org.eclipse.wst.jsdt.web.core.tests/src/org/eclipse/wst/jsdt/web/core/tests/translation/TestHtmlTranslation.java
@@ -550,4 +550,25 @@ // release model structuredModel.releaseFromRead(); } + + public void testEmptyEventHandlerValueCausesStringIndexOutOfBounds() throws Exception { + String fileName = getName() + ".html"; + IStructuredModel structuredModel = getSharedModel(fileName, "<html><body><span onclick=\"\"></body></html>"); + assertNotNull("missing test model", structuredModel); + JsTranslationAdapterFactory.setupAdapterFactory(structuredModel); + try { + // do translation + JsTranslationAdapter translationAdapter = (JsTranslationAdapter) ((IDOMModel) structuredModel).getDocument().getAdapterFor(IJsTranslation.class); + IJsTranslation translation = translationAdapter.getJsTranslation(false); + String translated = translation.getJsText(); + } + catch (StringIndexOutOfBoundsException e) { + fail(e.getMessage()); + } + finally { + if (structuredModel != null) { + structuredModel.releaseFromRead(); + } + } + } }