ScriptingTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. class HTMLPurifier_HTMLModule_ScriptingTest extends HTMLPurifier_HTMLModuleHarness
  3. {
  4. function setUp() {
  5. parent::setUp();
  6. $this->config->set('HTML.Trusted', true);
  7. $this->config->set('Output.CommentScriptContents', false);
  8. }
  9. function testDefaultRemoval() {
  10. $this->config->set('HTML.Trusted', false);
  11. $this->assertResult(
  12. '<script type="text/javascript">foo();</script>', ''
  13. );
  14. }
  15. function testPreserve() {
  16. $this->assertResult(
  17. '<script type="text/javascript">foo();</script>'
  18. );
  19. }
  20. function testCDATAEnclosure() {
  21. $this->assertResult(
  22. '<script type="text/javascript">//<![CDATA[
  23. alert("<This is compatible with XHTML>");
  24. //]]></script>'
  25. );
  26. }
  27. function testAllAttributes() {
  28. $this->assertResult(
  29. '<script
  30. defer="defer"
  31. src="test.js"
  32. type="text/javascript"
  33. >PCDATA</script>'
  34. );
  35. }
  36. function testUnsupportedAttributes() {
  37. $this->assertResult(
  38. '<script
  39. type="text/javascript"
  40. charset="utf-8"
  41. >PCDATA</script>',
  42. '<script type="text/javascript">PCDATA</script>'
  43. );
  44. }
  45. }
  46. // vim: et sw=4 sts=4