You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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