Bugzilla 315660.
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/AllContentAssistTests.java b/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/AllContentAssistTests.java
index 681f319..6985ea1 100644
--- a/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/AllContentAssistTests.java
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/AllContentAssistTests.java
@@ -90,6 +90,7 @@
 		all.addTest(GlobalShadowedByFuncArgTests.suite());
 		all.addTest(AddToNavigatorTests.suite());
 		all.addTest(Dom5LibraryTests.suite());
+		all.addTest(NestedWithinParenthesesTests.suite());
 		
 		// tests that do editing to the files
 		all.addTest(GlobalFunctionTests_Edited.suite());
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/ContentAssistTestUtilities.java b/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/ContentAssistTestUtilities.java
index c95535f..9e5803b 100644
--- a/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/ContentAssistTestUtilities.java
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/ContentAssistTestUtilities.java
@@ -12,6 +12,7 @@
 

 import java.io.IOException;

 import java.io.StringReader;

+import java.lang.reflect.Field;

 import java.lang.reflect.Method;

 import java.util.HashSet;

 import java.util.Set;

@@ -24,6 +25,7 @@
 import org.eclipse.jface.text.contentassist.ICompletionProposal;

 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;

 import org.eclipse.jface.text.source.ISourceViewer;

+import org.eclipse.jface.text.source.SourceViewer;

 import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;

 import org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor;

 import org.eclipse.wst.jsdt.internal.ui.text.html.HTML2TextReader;

@@ -382,4 +384,57 @@
 

 		set.clear();

 	}

+	

+	/**

+	 * Get a proposal and test by inserting computed proposal into the Editor.

+	 */

+	public static void runProposalandInertTest(TestProjectSetup testProject, String filePath, int lineNum, int lineRelativeCharOffset, String expectedResult) throws Exception{

+		

+			IFile file = testProject.getFile(filePath);

+			JavaEditor editor  = testProject.getEditor(file);

+			IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());

+			int offset = doc.getLineOffset(lineNum) + lineRelativeCharOffset;

+

+			ICompletionProposal[][] pages = getProposals(editor, offset, 1);

+		

+			verifyInsertProposalToEditor(editor, offset, pages, expectedResult);

+	}

+	

+	/**

+	 * Verify insert proposal to Editor between parenthesis.

+	 * 

+	 * @param editor JavaEditor of Content Assist invoked

+	 * @param offset Location of Content Assist invoked.

+	 * @param pages computed CompletionProposals

+	 * @param expectedResult Expected result after proposal inserted to Editor

+	 * @throws Exception

+	 */

+	public static void verifyInsertProposalToEditor(JavaEditor editor, int offset, ICompletionProposal[][] pages, String expectedResult) throws Exception {

+		ISourceViewer viewer = editor.getViewer();

+		Field fContentAssistant = SourceViewer.class.getDeclaredField("fContentAssistant");

+		fContentAssistant.setAccessible(true);

+		ContentAssistant contentassistant = (ContentAssistant)fContentAssistant.get(viewer);

+		

+		Field fProposalPopup = ContentAssistant.class.getDeclaredField("fProposalPopup");

+		fProposalPopup.setAccessible(true);

+		Object objPopup = fProposalPopup.get(contentassistant);

+		

+		Class proposalPopupClass = Class.forName("org.eclipse.jface.text.contentassist.CompletionProposalPopup");

+		Method privateInsertProposalMethod = proposalPopupClass.getDeclaredMethod("insertProposal", new Class[]{ICompletionProposal.class,char.class,int.class,int.class});

+		privateInsertProposalMethod.setAccessible(true);

+		

+		// Set selected range to properly compute ReplacementLength in AbstractJavaCompletionProposal.

+		viewer.setSelectedRange(offset, 0);

+		

+		// Invoke insertProposal of CompletionProposalPopup

+		privateInsertProposalMethod.invoke(objPopup, new Object[]{pages[0][0], new Character((char) 0), new Integer(524288), new Integer(offset)});

+		

+		// Get result of inserted proposal in the Editor

+		String strAfterInsert = viewer.getDocument().get();

+

+		if (!expectedResult.equals(strAfterInsert)) {

+			Assert.fail("\n<ExpectedResult>\n" + expectedResult + "\n<The result after inserting to Editor>\n" + strAfterInsert);

+		}

+	}

+	

 }
\ No newline at end of file
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/NestedWithinParenthesesTests.java b/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/NestedWithinParenthesesTests.java
new file mode 100644
index 0000000..241be27
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/NestedWithinParenthesesTests.java
@@ -0,0 +1,136 @@
+/*******************************************************************************

+ * Copyright (c) 2013 IBM Corporation and others.

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ * 

+ * Contributors:

+ *     IBM Corporation - initial API and implementation

+ *     

+ *******************************************************************************/

+package org.eclipse.wst.jsdt.ui.tests.contentassist;

+

+import junit.extensions.TestSetup;

+import junit.framework.Test;

+import junit.framework.TestCase;

+import junit.framework.TestSuite;

+

+import org.eclipse.wst.jsdt.ui.tests.utils.TestProjectSetup;

+

+public class NestedWithinParenthesesTests extends TestCase {

+	/**

+	 * <p>

+	 * This tests name

+	 * </p>

+	 */

+	private static final String TEST_NAME = "Test Insert Proposals Within Parentheses";

+

+	/**

+	 * <p>

+	 * Test project setup for this test.

+	 * </p>

+	 */

+	private static TestProjectSetup fTestProjectSetup;

+	

+	/**

+	 * <p>

+	 * Default constructor

+	 * <p>

+	 * <p>

+	 * Use {@link #suite()}

+	 * </p>

+	 * 

+	 * @see #suite()

+	 */

+	public NestedWithinParenthesesTests() {

+		super(TEST_NAME);

+	}

+

+	/**

+	 * <p>

+	 * Constructor that takes a test name.

+	 * </p>

+	 * <p>

+	 * Use {@link #suite()}

+	 * </p>

+	 * 

+	 * @param name

+	 *            The name this test run should have.

+	 * 

+	 * @see #suite()

+	 */

+	public NestedWithinParenthesesTests(String name) {

+		super(name);

+	}

+

+	/**

+	 * <p>

+	 * Use this method to add these tests to a larger test suite so set up and tear down can be

+	 * performed

+	 * </p>

+	 * 

+	 * @return a {@link TestSetup} that will run all of the tests in this class

+	 *         with set up and tear down.

+	 */

+

+	public static Test suite() {

+		TestSuite ts = new TestSuite(NestedWithinParenthesesTests.class, TEST_NAME);

+		

+		fTestProjectSetup = new TestProjectSetup(ts, "ContentAssist", "root", false) {

+			/**

+			 * @see org.eclipse.wst.jsdt.ui.tests.contentassist.ContentAssistTestUtilities.ContentAssistTestsSetup#additionalSetUp()

+			 */

+			public void additionalSetUp() throws Exception {

+			}

+		};

+		

+		return fTestProjectSetup;

+	}

+	

+	public void testInsertToEditor_315660_1() throws Exception {

+		String expectedResult = 

+				"var data1;\n" +

+				"addEventListener(type, listener, useCapture)" ;

+		ContentAssistTestUtilities.runProposalandInertTest(fTestProjectSetup, "validateTest_315660_1.js", 1, 0, expectedResult);

+	}

+	

+	public void testInsertToEditor_315660_2() throws Exception {

+		String expectedResult = 

+				"var data1;\n" +

+				"var data2;\n" +

+				"(data1)";

+		ContentAssistTestUtilities.runProposalandInertTest(fTestProjectSetup, "validateTest_315660_2.js", 2, 5, expectedResult);

+	}

+	

+	public void testInsertToEditor_315660_3() throws Exception {

+		String expectedResult = 

+				"var data1;\n"+

+				"var data2;\n"+

+				"(\n"+

+				"	// data\n"+

+				"	(\n"+

+				"        data1	\n"+

+				"	)\n"+

+				");";

+		ContentAssistTestUtilities.runProposalandInertTest(fTestProjectSetup, "validateTest_315660_3.js", 5, 10, expectedResult);

+	}

+

+	public void testInsertToEditor_315660_4() throws Exception {

+		String expectedResult = 

+				"var data1;\n" +

+				"var data2;\n" +

+				"((10+data1));";

+		ContentAssistTestUtilities.runProposalandInertTest(fTestProjectSetup, "validateTest_315660_4.js", 2, 7, expectedResult);

+	}

+	

+	public void testInsertToEditor_315660_5() throws Exception {

+		String expectedResult = 

+				"var point = new Object();\n"+

+				"point.x = 2.3;\n"+

+				"point.y = -1.2;\n"+

+				"var square = {upperLeft: {x:point.x, y:point.y}, upperRight: {x:(parseFloat(s))} };";

+		ContentAssistTestUtilities.runProposalandInertTest(fTestProjectSetup, "validateTest_315660_5.js", 3, 66, expectedResult);

+	}

+

+}

diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_1.js b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_1.js
new file mode 100644
index 0000000..b432634
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_1.js
@@ -0,0 +1 @@
+var data1;

diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_2.js b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_2.js
new file mode 100644
index 0000000..30790d4
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_2.js
@@ -0,0 +1,3 @@
+var data1;

+var data2;

+(data)
\ No newline at end of file
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_3.js b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_3.js
new file mode 100644
index 0000000..33e0c31
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_3.js
@@ -0,0 +1,8 @@
+var data1;

+var data2;

+(

+	// data

+	(

+        da	

+	)

+);
\ No newline at end of file
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_4.js b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_4.js
new file mode 100644
index 0000000..a1fc367
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_4.js
@@ -0,0 +1,3 @@
+var data1;

+var data2;

+((10+da));
\ No newline at end of file
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_5.js b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_5.js
new file mode 100644
index 0000000..71135f5
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/validateTest_315660_5.js
@@ -0,0 +1,4 @@
+var point = new Object();

+point.x = 2.3;

+point.y = -1.2;

+var square = {upperLeft: {x:point.x, y:point.y}, upperRight: {x:(p)} };
\ No newline at end of file