Bug 486676 - [assist][html] Tag completions appear inside script blocks
diff --git a/bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/htmlContentAssistTests.js b/bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/htmlContentAssistTests.js
index ced25f5..51800f6 100644
--- a/bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/htmlContentAssistTests.js
+++ b/bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/htmlContentAssistTests.js
@@ -956,8 +956,34 @@
     			]);
     		});
     	});
+    	/*
+    	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=486676
+    	 */
+    	it('Inside script block - text, no children', function() {
+    		var _o = setup({buffer: '<script>x</script>'});
+    		return assist.computeContentAssist(_o.editorContext, {offset: 9, prefix: 'x'}).then(function(proposals) {
+    			assertProposals(proposals, [	]);
+    		});
+    	});
+    	/*
+    	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=486676
+    	 */
+    	it('Inside script block - no text, children', function() {
+    		var _o = setup({buffer: '<script><a></a></script>'});
+    		return assist.computeContentAssist(_o.editorContext, {offset: 11}).then(function(proposals) {
+    			assertProposals(proposals, [	]);
+    		});
+    	});
+    	/*
+    	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=486676
+    	 */
+    	it('Inside script block - no text, no children', function() {
+    		var _o = setup({buffer: '<script></script>'});
+    		return assist.computeContentAssist(_o.editorContext, {offset: 8}).then(function(proposals) {
+    			assertProposals(proposals, [	]);
+    		});
+    	});
     });
-    
 
 	describe('ARIA Content Assist Tests', function() {
 		// Global aria-* attributes: aria-atomic, aria-busy, aria-controls, aria-describedby, aria-disabled, aria-dropeffect, aria-flowto, aria-grabbed,
diff --git a/bundles/org.eclipse.orion.client.webtools/web/webtools/htmlContentAssist.js b/bundles/org.eclipse.orion.client.webtools/web/webtools/htmlContentAssist.js
index b853460..43cd224 100644
--- a/bundles/org.eclipse.orion.client.webtools/web/webtools/htmlContentAssist.js
+++ b/bundles/org.eclipse.orion.client.webtools/web/webtools/htmlContentAssist.js
@@ -210,33 +210,17 @@
 		 */
 		inScriptOrStyle: function(node, offset, source) {
 			if (node){
-				if(node.type === 'text' && node.parent && node.parent.type === 'tag'){
-					var name = node.parent.name ? node.parent.name.toLowerCase() : '';
+				if (node.type === 'tag'){
+					var name = node.name ? node.name.toLowerCase() : '';
 					if (name === 'script' || name === 'style') {
-						return true;
-					}
-				} else if (node.type === 'tag'){
-					name = node.name ? node.name.toLowerCase() : '';
-					if (name === 'script' || name === 'style') {
-						if (!node.children || !node.children.length > 0){
-							// Empty <script></script>, see if the previous non-whitespace character is '>'
-							if (offset > node.range[0] && offset < node.range[1]){
-								var whitespace = '\t\r\n '; //$NON-NLS-1$
-								var pos = offset;
-								var posChar;
-								var inwhite = true;
-								while (inwhite && pos > node.range[0]){
-									pos--;
-									posChar = source.charAt(pos);
-									inwhite = whitespace.indexOf(posChar) >= 0;
-								}
-								if (posChar === '>'){
-									return true;
-								}
+						if (node.openrange && node.endrange){
+							// If we are in the tag itself we are not actually in the script block
+							if (offset < node.openrange[1] || offset > node.endrange[0]){
+								return false;
 							}
 						}
+						return true;
 					}
-
 				}
 			}
 			return false;
@@ -687,9 +671,7 @@
 				var startTag;
 				// If text content is a '/' offer to close the tag
 				// If we have an uncompleted tag '</' offer to complete the tag
-				if (node.type === 'text' && node.parent && node.parent.type === 'tag'){
-					startTag = node.parent;
-				} else if (node.type === 'tag' && node.openrange && params.offset > node.openrange[1]){
+				if (node.type === 'tag' && node.openrange && params.offset > node.openrange[1]){
 					startTag = node;
 				} else if (node.type === 'tag' && (params.offset > node.range[1] || params.offset < node.range[0])){
 					startTag = node;