myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jak...@apache.org
Subject svn commit: r933812 - /myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
Date Tue, 13 Apr 2010 23:34:29 GMT
Author: jakobk
Date: Tue Apr 13 23:34:28 2010
New Revision: 933812

URL: http://svn.apache.org/viewvc?rev=933812&view=rev
Log:
MYFACES-2650 chaining ajax onchange with existing onchange creates syntax error (test case)

Modified:
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java

Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java?rev=933812&r1=933811&r2=933812&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
(original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
Tue Apr 13 23:34:28 2010
@@ -197,5 +197,27 @@ public class HtmlTextRendererTest extend
         }
         
     }
-
+    
+    /**
+     * Tests if a JavaScript user code is correctly escaped.
+     * e.g. alert('test') has to become alert(\'test\')
+     */
+    public void testClientBehaviorUserCodeJavaScriptEscaping()
+    {
+        inputText.getAttributes().put("onchange", "alert('test')");
+        inputText.addClientBehavior("change", new AjaxBehavior());
+        try 
+        {
+            inputText.encodeAll(facesContext);
+            String output = ((StringWriter) writer.getWriter()).getBuffer().toString();
+            // onchange="jsf.util.chain(document.getElementById('j_id0'),
event,
+            //                          'alert(\'test\')');"
+            assertTrue(output.contains("'alert(\\'test\\')'"));
+        }
+        catch (Exception e)
+        {
+            fail(e.getMessage());
+        }
+    }
+    
 }



Mime
View raw message