2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for javascript escaping.
6 * @package phpMyAdmin-test
12 require_once 'PHPUnit/Framework.php';
17 require_once './libraries/js_escape.lib.php';
20 * Test java script escaping.
22 * @package phpMyAdmin-test
24 class PMA_escapeJsString_test
extends PHPUnit_Framework_TestCase
26 public function testEscape_1()
28 $this->assertEquals('\\\';', PMA_escapeJsString('\';'));
31 public function testEscape_2()
33 $this->assertEquals('\r\n\\\'<scrIpt></\' + \'script>', PMA_escapeJsString("\r\n'<scrIpt></sCRIPT>"));
36 public function testEscape_3()
38 $this->assertEquals('\\\';[XSS]', PMA_escapeJsString('\';[XSS]'));
41 public function testEscape_4()
43 $this->assertEquals('</\' + \'script></head><body>[HTML]', PMA_escapeJsString('</SCRIPT></head><body>[HTML]'));
46 public function testEscape_5()
48 $this->assertEquals('"\\\'\\\\\\\'"', PMA_escapeJsString('"\'\\\'"'));
51 public function testEscape_6()
53 $this->assertEquals("\\\\\'\'\'\'\'\'\'\'\'\'\'\'\\\\", PMA_escapeJsString("\\''''''''''''\\"));