org.htmlparser.tests.scannersTests
Class ScriptScannerTest

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.htmlparser.tests.ParserTestCase
              extended byorg.htmlparser.tests.scannersTests.ScriptScannerTest
All Implemented Interfaces:
junit.framework.Test

public class ScriptScannerTest
extends ParserTestCase


Field Summary
 
Fields inherited from class org.htmlparser.tests.ParserTestCase
mLexer, node, nodeCount, parser
 
Constructor Summary
ScriptScannerTest(java.lang.String name)
           
 
Method Summary
 void testDecodePage()
          See bug #902121 StringBean throws NullPointerException Contributed by Reza Motori (rezamotori)
 void testDecodeScript()
          See bug #902121 StringBean throws NullPointerException Contributed by Reza Motori (rezamotori)
 void testScan()
           
 void testScanBug()
          Test javascript tag attributes.
 void testScanBugWG()
          Test script code.
 void testScanNoEndTag()
          Tests a bug in ScriptScanner where a NPE would be thrown if the script tag was not closed before the document ended.
 void testScanQuotedEndTag()
          See bug #741769 ScriptScanner doesn't handle quoted tags
 void testScanScriptWithComments()
           
 void testScanScriptWithJavascriptLineEndings()
           
 void testScanScriptWithLinks()
           
 void testScanScriptWithTags()
           
 void testScanScriptWithTagsInComment()
           
 void testScriptCodeExtraction()
           
 void testScriptCodeExtractionWithMultipleQuotes()
           
 void testScriptCodeExtractionWithNewlines()
          There was a bug in the ScriptScanner when there was multiline script and the last line did not have a newline before the end script tag.
 void testScriptsWithForm()
          See bug #839264 toHtml() parse error in Javascripts with "form" keyword Contributed by Ivan Wang (xj92wang)
 void testScriptTagComments()
          Submitted by Dhaval Udani - reproducing bug 664404
 void testScriptTagsGeneratedByScriptCode()
          Duplicates bug reported by James Moliere - whereby, if script tags are generated by script code, the parser interprets them as real tags.
 void testScriptWithinComments()
           
 
Methods inherited from class org.htmlparser.tests.ParserTestCase
assertHiddenIDTagPresent, assertNodeCount, assertNodeCount, assertSameType, assertStringEquals, assertSuperType, assertTagEquals, assertType, assertXmlEquals, createParser, createParser, createParser, createParser, failWithMessage, getParser, main, parse, parseAndAssertNodeCount, parseNodes, removeEscapeCharacters, setParser
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, name, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScriptScannerTest

public ScriptScannerTest(java.lang.String name)
Method Detail

testScan

public void testScan()
              throws ParserException
Throws:
ParserException

testScanBug

public void testScanBug()
                 throws ParserException
Test javascript tag attributes. Bug reported by Gordon Deudney 2002-03-27 Upon parsing : <SCRIPT LANGUAGE="JavaScript" SRC="../js/DetermineBrowser.js"></SCRIPT> the SRC data cannot be retrieved.

Throws:
ParserException

testScanBugWG

public void testScanBugWG()
                   throws ParserException
Test script code. Bug check by Wolfgang Germund 2002-06-02 Upon parsing : <script language="javascript"> if(navigator.appName.indexOf("Netscape") != -1) document.write ('xxx'); else document.write ('yyy'); </script> check getScriptCode().

Throws:
ParserException

testScanScriptWithLinks

public void testScanScriptWithLinks()
                             throws ParserException
Throws:
ParserException

testScanScriptWithComments

public void testScanScriptWithComments()
                                throws ParserException
Throws:
ParserException

testScriptTagComments

public void testScriptTagComments()
                           throws ParserException
Submitted by Dhaval Udani - reproducing bug 664404

Throws:
ParserException

testScriptTagsGeneratedByScriptCode

public void testScriptTagsGeneratedByScriptCode()
                                         throws java.lang.Exception
Duplicates bug reported by James Moliere - whereby, if script tags are generated by script code, the parser interprets them as real tags. The problem was that the string parser was not moving to the ignore state on encountering double quotes (only single quotes were previously accepted).

Throws:
java.lang.Exception

testScriptCodeExtraction

public void testScriptCodeExtraction()
                              throws ParserException
Throws:
ParserException

testScriptCodeExtractionWithMultipleQuotes

public void testScriptCodeExtractionWithMultipleQuotes()
                                                throws ParserException
Throws:
ParserException

testScriptWithinComments

public void testScriptWithinComments()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testScriptCodeExtractionWithNewlines

public void testScriptCodeExtractionWithNewlines()
                                          throws ParserException
There was a bug in the ScriptScanner when there was multiline script and the last line did not have a newline before the end script tag. For example: <script>alert() alert()</script> Would generate the following "scriptCode()" result: alert()alert() But should actually return: alert() alert() This was fixed in ScriptScanner, which this test verifies

Throws:
ParserException

testScanNoEndTag

public void testScanNoEndTag()
                      throws ParserException
Tests a bug in ScriptScanner where a NPE would be thrown if the script tag was not closed before the document ended.

Throws:
ParserException

testScanQuotedEndTag

public void testScanQuotedEndTag()
                          throws ParserException
See bug #741769 ScriptScanner doesn't handle quoted tags

Throws:
ParserException

testScanScriptWithTagsInComment

public void testScanScriptWithTagsInComment()
                                     throws ParserException
Throws:
ParserException

testScanScriptWithJavascriptLineEndings

public void testScanScriptWithJavascriptLineEndings()
                                             throws ParserException
Throws:
ParserException

testScanScriptWithTags

public void testScanScriptWithTags()
                            throws ParserException
Throws:
ParserException

testScriptsWithForm

public void testScriptsWithForm()
                         throws ParserException
See bug #839264 toHtml() parse error in Javascripts with "form" keyword Contributed by Ivan Wang (xj92wang)

Throws:
ParserException

testDecodeScript

public void testDecodeScript()
                      throws ParserException
See bug #902121 StringBean throws NullPointerException Contributed by Reza Motori (rezamotori)

Throws:
ParserException

testDecodePage

public void testDecodePage()
                    throws ParserException
See bug #902121 StringBean throws NullPointerException Contributed by Reza Motori (rezamotori)

Throws:
ParserException