SafeScriptingTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. class HTMLPurifier_HTMLModule_SafeScriptingTest extends HTMLPurifier_HTMLModuleHarness
  3. {
  4. public function setUp()
  5. {
  6. parent::setUp();
  7. $this->config->set('HTML.SafeScripting', array('http://localhost/foo.js'));
  8. }
  9. public function testMinimal()
  10. {
  11. $this->assertResult(
  12. '<script></script>',
  13. ''
  14. );
  15. }
  16. public function testGood()
  17. {
  18. $this->assertResult(
  19. '<script type="text/javascript" src="http://localhost/foo.js"></script>'
  20. );
  21. }
  22. public function testGoodWithAutoclosedTag()
  23. {
  24. $this->assertResult(
  25. '<script type="text/javascript" src="http://localhost/foo.js"/>',
  26. '<script type="text/javascript" src="http://localhost/foo.js"></script>'
  27. );
  28. }
  29. public function testBad()
  30. {
  31. $this->assertResult(
  32. '<script type="text/javascript" src="http://localhost/foobar.js" />',
  33. ''
  34. );
  35. $this->assertResult(
  36. '<script type="text/javascript" src="http://localhost/FOO.JS" />',
  37. ''
  38. );
  39. }
  40. }
  41. // vim: et sw=4 sts=4