--- /dev/null
+--TEST--
+escape types
+--TEMPLATE--
+
+1. autoescape 'html' |escape('js')
+
+{% autoescape 'html' %}
+<a onclick="alert("{{ msg|escape('js') }}")"></a>
+{% endautoescape %}
+
+2. autoescape 'html' |escape('js')
+
+{% autoescape 'html' %}
+<a onclick="alert("{{ msg|escape('js') }}")"></a>
+{% endautoescape %}
+
+3. autoescape 'js' |escape('js')
+
+{% autoescape 'js' %}
+<a onclick="alert("{{ msg|escape('js') }}")"></a>
+{% endautoescape %}
+
+4. no escape
+
+{% autoescape false %}
+<a onclick="alert("{{ msg }}")"></a>
+{% endautoescape %}
+
+5. |escape('js')|escape('html')
+
+{% autoescape false %}
+<a onclick="alert("{{ msg|escape('js')|escape('html') }}")"></a>
+{% endautoescape %}
+
+6. autoescape 'html' |escape('js')|escape('html')
+
+{% autoescape 'html' %}
+<a onclick="alert("{{ msg|escape('js')|escape('html') }}")"></a>
+{% endautoescape %}
+
+--DATA--
+return array('msg' => "<>\n'\"")
+--EXPECT--
+
+1. autoescape 'html' |escape('js')
+
+<a onclick="alert("\x3C\x3E\x0A\x27\x22")"></a>
+
+2. autoescape 'html' |escape('js')
+
+<a onclick="alert("\x3C\x3E\x0A\x27\x22")"></a>
+
+3. autoescape 'js' |escape('js')
+
+<a onclick="alert("\x3C\x3E\x0A\x27\x22")"></a>
+
+4. no escape
+
+<a onclick="alert("<>
+'"")"></a>
+
+5. |escape('js')|escape('html')
+
+<a onclick="alert("\x3C\x3E\x0A\x27\x22")"></a>
+
+6. autoescape 'html' |escape('js')|escape('html')
+
+<a onclick="alert("\x3C\x3E\x0A\x27\x22")"></a>
+