@@ -237,6 +237,44 @@ public final void testHtml51SemanticsScriptingExample5Part2() throws Exception {
237237 errors .clear ();
238238 }
239239
240+ public final void testMoreUnbalancedHtmlCommentsInScripts () throws Exception {
241+ String js = "if (x-->y) { ... }\n " ;
242+
243+ renderer .openDocument ();
244+ renderer .openTag ("script" , ImmutableList .<String >of ());
245+ renderer .text (js );
246+ renderer .closeTag ("script" );
247+ renderer .closeDocument ();
248+
249+ // We could actually allow this since --> is not banned per 4.12.1.3
250+ assertEquals (
251+ "<script></script>" ,
252+ rendered .toString ());
253+ assertEquals (
254+ "Invalid CDATA text content : -->y) { .." ,
255+ Joiner .on ('\n' ).join (errors ));
256+ errors .clear ();
257+ }
258+
259+ public final void testShortHtmlCommentInScript () throws Exception {
260+ String js = "// <!----> <!--->" ;
261+
262+ renderer .openDocument ();
263+ renderer .openTag ("script" , ImmutableList .<String >of ());
264+ renderer .text (js );
265+ renderer .closeTag ("script" );
266+ renderer .closeDocument ();
267+
268+ // We could actually allow this since --> is not banned per 4.12.1.3
269+ assertEquals (
270+ "<script></script>" ,
271+ rendered .toString ());
272+ assertEquals (
273+ "Invalid CDATA text content : <!--->" ,
274+ Joiner .on ('\n' ).join (errors ));
275+ errors .clear ();
276+ }
277+
240278 public final void testHtml51SemanticsScriptingExample5Part3 () throws Exception {
241279 String js = "<!-- if ( player<script ) { ... } -->" ;
242280
@@ -281,6 +319,24 @@ public final void testHtml51SemanticsScriptingExample5Part4() throws Exception {
281319 rendered .toString ());
282320 }
283321
322+ public final void testHtmlCommentInRcdata () throws Exception {
323+ String str = "// <!----> <!---> <!--" ;
324+
325+ renderer .openDocument ();
326+ renderer .openTag ("title" , ImmutableList .<String >of ());
327+ renderer .text (str );
328+ renderer .closeTag ("title" );
329+ renderer .openTag ("textarea" , ImmutableList .<String >of ());
330+ renderer .text (str );
331+ renderer .closeTag ("textarea" );
332+ renderer .closeDocument ();
333+
334+ assertEquals (
335+ "<title>// <!----> <!---> <!--</title>"
336+ + "<textarea>// <!----> <!---> <!--</textarea>" ,
337+ rendered .toString ());
338+ }
339+
284340 public final void testTagInCdata () throws Exception {
285341 renderer .openDocument ();
286342 renderer .openTag ("script" , ImmutableList .<String >of ());
0 commit comments