Package org.htmlparser.scanners

Examples of org.htmlparser.scanners.ScriptScanner


    String testHTML1 = new String(sb1.toString());

    createParser(testHTML1, "http://www.google.com/test/index.html");
    Parser.setLineSeparator("\r\n");
    // Register the image scanner
    parser.addScanner(new ScriptScanner("-s"));

    parseAndAssertNodeCount(2);

    StringBuffer sb2 = new StringBuffer();
    sb2.append("if(navigator.appName.indexOf(\"Netscape\") != -1)\r\n");
View Full Code Here


   */
  public void testScriptTagComments() throws ParserException {
    String testHtml = "<SCRIPT LANGUAGE=\"JavaScript\">\r\n" + "<!--\r\n" + "// -->\r\n" + "</SCRIPT>";
    createParser(testHtml);

    parser.addScanner(new ScriptScanner("-s"));
    parseAndAssertNodeCount(1);
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertStringEquals("scriptag html", testHtml, scriptTag.toHtml());
  }
View Full Code Here

   * Tests a bug in ScriptScanner where a NPE would be thrown if the script
   * tag was not closed before the document ended.
   */
  public void testScanNoEndTag() throws ParserException {
    createParser("<script>");
    parser.addScanner(new ScriptScanner("-s"));
    parseAndAssertNodeCount(1);
  }
View Full Code Here

  /**
   * See bug #741769 ScriptScanner doesn't handle quoted </script> tags
   */
  public void testScanQuotedEndTag() throws ParserException {
    createParser("<SCRIPT language=\"JavaScript\">document.write('</SCRIPT>');</SCRIPT>");
    parser.addScanner(new ScriptScanner("-s"));
    parseAndAssertNodeCount(1);
    String s = node[0].toHtml();
    assertEquals("Parse error", "<SCRIPT LANGUAGE=\"JavaScript\">document.write('</SCRIPT>');</SCRIPT>", s);
  }
View Full Code Here

    super(name);
  }

  protected void setUp() throws Exception {
    super.setUp();
    scriptScanner = new ScriptScanner();
  }
View Full Code Here

  }

  public void testToHTML() throws ParserException {
    createParser("<SCRIPT>document.write(d+\".com\")</SCRIPT>");
    // Register the image scanner
    parser.addScanner(new ScriptScanner("-s"));

    parseAndAssertNodeCount(1);
    assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
    // Check the data in the applet tag
    ScriptTag scriptTag = (ScriptTag) node[0];
View Full Code Here

    String testHTML1 = new String(sb1.toString());

    createParser(testHTML1);
    Parser.setLineSeparator("\r\n");
    // Register the image scanner
    parser.addScanner(new ScriptScanner("-s"));

    StringBuffer sb2 = new StringBuffer();
    sb2.append("<SCRIPT LANGUAGE=\"javascript\">\r\n");
    sb2.append("if(navigator.appName.indexOf(\"Netscape\") != -1)\r\n");
    sb2.append(" document.write ('xxx');\r\n");
View Full Code Here

    sb1.append(" document.write ('yyy');\r\n");
    sb1.append("</script>\r\n");
    createParser(sb1.toString());

    // Register the image scanner
    parser.addScanner(new ScriptScanner("-s"));
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertEquals("Script Src", "/adb.js", scriptTag.getAttribute("src"));
    assertEquals("Script Language", "javascript", scriptTag.getAttribute("language"));
View Full Code Here

    sb1.append("var lower = '<%=lowerValue%>';\n");
    sb1.append("</script>\n");
    createParser(sb1.toString());

    // Register the image scanner
    parser.addScanner(new ScriptScanner("-s"));
    // parser.registerScanners();
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertStringEquals("Script toHTML()",
View Full Code Here

    StringBuffer sb1 = new StringBuffer();
    sb1.append("<script src='<%=sourceFileName%>'></script>");
    createParser(sb1.toString());

    // Register the image scanner
    parser.addScanner(new ScriptScanner("-s"));
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertStringEquals("Script toHTML()", "<SCRIPT SRC=\"<%=sourceFileName%>\"></SCRIPT>", scriptTag.toHtml());
  }
View Full Code Here

TOP

Related Classes of org.htmlparser.scanners.ScriptScanner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.