Examples of ScriptTag


Examples of org.htmlparser.tags.ScriptTag

    public void testScanScriptWithTags() throws ParserException {
        String javascript = "\nAnything inside the script tag should be unchanged, even <li> and other html tags\n";
        createParser("<script>"+ javascript + "</script>");
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a script tag",node[0] instanceof ScriptTag);
        ScriptTag scriptTag = (ScriptTag)node[0];
        String scriptCode = scriptTag.getScriptCode();
        assertStringEquals("Expected Code",javascript,scriptCode);
    }
View Full Code Here

Examples of org.htmlparser.tags.ScriptTag

            "document.write(\"<img src=\\\"http://www.parsads.com/adserve/scriptinject.asp?F=4&Z=3,4,5,10,12&N=1&U=644&O=&nocache=\"  + nIndexs + \"\\\" width=\\\"1\\\" hight=\\\"1\\\"><img src=\\\"http://www.parsads.com/adserve/scriptinject.asp?F=4&Z=3,4,5,10,12&N=1&U=643&O=&nocache=\"  + nIndexs + \"\\\" width=\\\"1\\\" hight=\\\"1\\\"><img src=\\\"http://www.parsads.com/adserve/scriptinject.asp?F=4&Z=3,4,5,10,12&N=1&U=324&O=&nocache=\"  + nIndexs + \"\\\" width=\\\"1\\\" hight=\\\"1\\\">\");\r\n";
       
        parser = new Parser (url);
        NodeList scripts = parser.extractAllNodesThatMatch (new TagNameFilter ("SCRIPT"));
        assertEquals ("wrong number of scripts found", 2, scripts.size ());
        ScriptTag script = (ScriptTag)scripts.elementAt (1);
        assertStringEquals ("script not decoded correctly", plaintext, script.getScriptCode ());
    }
View Full Code Here

Examples of org.htmlparser.tags.ScriptTag

    // Register the script 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];
    assertStringEquals("Expected Script Code", "document.write(d+\".com\")", scriptTag.getScriptCode());
    assertStringEquals("script tag html", testHtml, scriptTag.toHtml());
  }
View Full Code Here

Examples of org.htmlparser.tags.ScriptTag

    // 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];
    Hashtable table = scriptTag.getAttributes();
    String srcExpected = (String) table.get("SRC");
    assertEquals("Expected SRC value", "../js/DetermineBrowser.js", srcExpected);
  }
View Full Code Here

Examples of org.htmlparser.tags.ScriptTag

    sb2.append(" document.write ('yyy');\r\n");
    String testHTML2 = new String(sb2.toString());

    assertTrue("Node should be a script tag", node[1] instanceof ScriptTag);
    // Check the data in the applet tag
    ScriptTag scriptTag = (ScriptTag) node[1];
    String s = scriptTag.getScriptCode();
    assertStringEquals("Expected Script Code", testHTML2, s);
  }
View Full Code Here

Examples of org.htmlparser.tags.ScriptTag

    // parser.addScanner(new HTMLScriptScanner("-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];
    // assertStringEquals("Expected Script
    // Code",testHTML2,scriptTag.getScriptCode());
  }
View Full Code Here

Examples of org.htmlparser.tags.ScriptTag

    // Register the image scanner
    parser.registerScanners();
    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];
    String scriptCode = scriptTag.getScriptCode();
    String expectedCode = "<!--\r\n" + "  function validateForm()\r\n" + "  {\r\n" + "     var i = 10;\r\n"
        + "     if(i < 5)\r\n" + "     i = i - 1 ; \r\n" + "     return true;\r\n" + "  }\r\n" + "// -->";
    assertStringEquals("Expected Code", expectedCode, scriptCode);
  }
View Full Code Here

Examples of org.htmlparser.tags.ScriptTag

    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

Examples of org.htmlparser.tags.ScriptTag

        + "document.write(\"}\"); " + "// parser thinks this is the end tag. "
        + "document.write(\"</script>\");" + "</script>" + "<body>" + "</body>" + "</html>");
    parser.registerScanners();
    Node scriptNodes[] = parser.extractAllNodesThatAre(ScriptTag.class);
    assertType("scriptnode", ScriptTag.class, scriptNodes[0]);
    ScriptTag scriptTag = (ScriptTag) scriptNodes[0];
    assertStringEquals("script code", "document.write(\"<script " + "language=\\\"JavaScript\\\">\");"
        + "document.write(\"function onmousedown" + "(event)\");" + "document.write(\"{ // do something\"); "
        + "document.write(\"}\"); " + "// parser thinks this is the end tag. "
        + "document.write(\"</script>\");", scriptTag.getScriptCode());

  }
View Full Code Here

Examples of org.htmlparser.tags.ScriptTag

    createParser("<SCRIPT language=JavaScript>" + "document.write(\"<a href=\"1.htm\"><img src=\"1.jpg\" "
        + "width=\"80\" height=\"20\" border=\"0\"></a>\");" + "</SCRIPT>");
    parser.registerScanners();
    parseAndAssertNodeCount(1);
    assertType("script", ScriptTag.class, node[0]);
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertStringEquals("script code", "document.write(\"<a href=\"1.htm\"><img src=\"1.jpg\" "
        + "width=\"80\" height=\"20\" border=\"0\"></a>\");", scriptTag.getScriptCode());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.