This commit is contained in:
Julian Dolby 2013-09-18 14:00:04 -04:00
commit dd4d794517
6 changed files with 101 additions and 4 deletions

View File

@ -0,0 +1,17 @@
<HTML>
<TITLE>Welcome!</TITLE>
Hi
<SCRIPT>
function onload_handler() {}
window.onload = onload_handler;
</SCRIPT>
<BR>
Welcome to our system
</HTML>

File diff suppressed because one or more lines are too long

View File

@ -296,6 +296,24 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
verifyGraphAssertions(CG, assertionsForWindowx);
}
<<<<<<< HEAD
=======
private static final Object[][] assertionsForWindowOnload = new Object[][] {
new Object[] { ROOT, new String[] { "windowonload.html" } },
new Object[] { "windowonload.html", new String[] { "windowonload.html/__WINDOW_MAIN__" } },
new Object[] { "windowonload.html/__WINDOW_MAIN__", new String[] { "windowonload.html/__WINDOW_MAIN__/onload_handler" } },
};
@Test public void testWindowOnload() throws IOException, IllegalArgumentException, CancelException, WalaException {
URL url = getClass().getClassLoader().getResource("pages/windowonload.html");
JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url);
CallGraph CG = builder.makeCallGraph(builder.getOptions());
CAstCallGraphUtil.dumpCG(builder.getPointerAnalysis(), CG);
verifyGraphAssertions(CG, assertionsForWindowOnload);
}
>>>>>>> 8984637b86dd09a60d973627e83d1daf648826a8
/*
@Test public void testJQuery() throws IOException, IllegalArgumentException, CancelException, WalaException {
URL url = getClass().getClassLoader().getResource("pages/jquery.html");

View File

@ -28,7 +28,10 @@ import com.ibm.wala.cast.js.html.jericho.JerichoHtmlParser;
import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position;
import com.ibm.wala.util.collections.Pair;
/**
* extracts JavaScript source code from HTML, with no model of the actual
* DOM data structure
*/
public class DomLessSourceExtractor extends JSSourceExtractor {
private static final Pattern LEGAL_JS_IDENTIFIER_REGEXP = Pattern.compile("[a-zA-Z$_][a-zA-Z\\d$_]*");
protected interface IGeneratorCallback extends IHtmlCallback {
@ -57,8 +60,14 @@ public class DomLessSourceExtractor extends JSSourceExtractor {
this.scriptRegion = new SourceRegion();
this.domRegion = new SourceRegion();
this.entrypointRegion = new SourceRegion();
addDefaultHandlerInvocations();
}
private void addDefaultHandlerInvocations() {
// always invoke window.onload
entrypointRegion.println("window.onload();");
}
protected Position makePos(int lineNumber, ITag governingTag) {
return makePos(entrypointUrl, lineNumber, governingTag);
}

View File

@ -62,7 +62,7 @@ import com.ibm.wala.util.warnings.Warnings;
/**
* Logic to interpret "factory" methods in context.
*/
class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
/**
* A Map from CallerSiteContext -> Set <TypeReference>represents the types a factory method might create in a particular context

View File

@ -26,7 +26,7 @@ import com.ibm.wala.util.intset.IntSetUtil;
/**
* A {@link ContextSelector} to intercept calls to Object.getClass()
*/
class GetClassContextSelector implements ContextSelector {
public class GetClassContextSelector implements ContextSelector {
public final static MethodReference GET_CLASS = MethodReference.findOrCreate(TypeReference.JavaLangObject, "getClass",
"()Ljava/lang/Class;");