@Test public void testPage3WithoutHack() throws IllegalArgumentException, CancelException, WalaException { URL url = getClass().getClassLoader().getResource("pages/page3.html"); JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url); CallGraph CG = builder.makeCallGraph(builder.getOptions()); CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); }
@Test public void testPage3WithHack() throws IllegalArgumentException, CancelException, WalaException { URL url = getClass().getClassLoader().getResource("pages/page3.html"); JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url); addHackedForInLoopSensitivity(builder); CallGraph CG = builder.makeCallGraph(builder.getOptions()); CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); }
@Ignore("This tries to analyze unmodified jquery, which we can't do yet") @Test public void testEx1() throws IllegalArgumentException, CancelException, WalaException { URL url = getClass().getClassLoader().getResource("pages/jquery/ex1.html"); JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url); CallGraph CG = builder.makeCallGraph(builder.getOptions()); CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); } }
@Test public void testWindowOnload() throws 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.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForWindowOnload); }
@Ignore("This test now blows up due to proper handling of the || construct, used in extend(). Should handle this eventually.") @Test public void testJQueryWithHack() throws IllegalArgumentException, CancelException, WalaException { URL url = getClass().getClassLoader().getResource("pages/jquery_hacked.html"); JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url); addHackedForInLoopSensitivity(builder); CallGraph CG = builder.makeCallGraph(builder.getOptions()); CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); }
@Test public void testTutorialExample() throws IllegalArgumentException, IOException, CancelException, WalaException { SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "tutorial-example.js"); CallGraph CG = B.makeCallGraph(B.getOptions()); CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); // verifyGraphAssertions(CG, assertionsForDateProperty); }
@Test public void testTryFinallyCrash() throws IllegalArgumentException, IOException, CancelException, WalaException { JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "try-finally-crash.js"); CallGraph CG = B.makeCallGraph(B.getOptions()); boolean save = CAstCallGraphUtil.AVOID_DUMP; //CAstCallGraphUtil.AVOID_DUMP = false; CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); CAstCallGraphUtil.AVOID_DUMP = save; }
@Test public void testForInRecursion() throws IOException, IllegalArgumentException, CancelException, WalaException { JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "badforin3.js"); addHackedForInLoopSensitivity(B); CallGraph CG = B.makeCallGraph(B.getOptions()); CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); }
@Test public void testForin() throws IOException, IllegalArgumentException, CancelException, WalaException { JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "forin.js"); CallGraph CG = B.makeCallGraph(B.getOptions()); // JSCallGraphUtil.AVOID_DUMP = false; CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForForin); }
@Test public void testDispatch() throws IOException, IllegalArgumentException, CancelException, WalaException { SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "dispatch.js"); CallGraph CG = B.makeCallGraph(B.getOptions()); // JSCallGraphUtil.AVOID_DUMP = false; CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForDispatch); }
@Test public void testBadForInWithoutHack() throws IOException, IllegalArgumentException, CancelException, WalaException { JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "badforin.js"); CallGraph CG = B.makeCallGraph(B.getOptions()); CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForBadForin); }
@Test public void testReturnThis() throws IOException, IllegalArgumentException, CancelException, WalaException { SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "return_this.js"); CallGraph CG = B.makeCallGraph(B.getOptions()); // JSCallGraphUtil.AVOID_DUMP = false; CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForReturnThis); }
@Test public void testbadforin2WithoutHack() throws IOException, IllegalArgumentException, CancelException, WalaException { JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "badforin2.js"); CallGraph CG = B.makeCallGraph(B.getOptions()); CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForbadforin2); }
@Ignore("need to fix this. bug from Sukyoung's group") @Test public void testLoops() throws IllegalArgumentException, IOException, CancelException, WalaException { SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "loops.js"); CallGraph CG = B.makeCallGraph(B.getOptions()); boolean x = CAstCallGraphUtil.AVOID_DUMP; CAstCallGraphUtil.AVOID_DUMP = false; CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); CAstCallGraphUtil.AVOID_DUMP = x; verifyGraphAssertions(CG, assertionsForLoops); }
@Ignore("need to fix this. bug from Sukyoung's group") @Test public void testPrimitiveStrings() throws IllegalArgumentException, IOException, CancelException, WalaException { SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "primitive_strings.js"); CallGraph CG = B.makeCallGraph(B.getOptions()); boolean x = CAstCallGraphUtil.AVOID_DUMP; CAstCallGraphUtil.AVOID_DUMP = false; CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); CAstCallGraphUtil.AVOID_DUMP = x; verifyGraphAssertions(CG, assertionsForPrimitiveStrings); }
@Test public void testStringPrims() throws IOException, IllegalArgumentException, CancelException, WalaException { SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "string-prims.js"); B.getOptions().setTraceStringConstants(true); CallGraph CG = B.makeCallGraph(B.getOptions()); // JSCallGraphUtil.AVOID_DUMP = false; CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForStringPrims); }
@Test public void testbadforin2WithHack() throws IOException, IllegalArgumentException, CancelException, WalaException { JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "badforin2.js"); addHackedForInLoopSensitivity(B); CallGraph CG = B.makeCallGraph(B.getOptions()); CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForbadforin2); verifyGraphAssertions(CG, assertionsForbadforin2HackPrecision); }
@SuppressWarnings("static-access") @Test public void testCPA() throws IOException, IllegalArgumentException, CancelException, WalaException { JSCFABuilder builder = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "cpa.js"); builder.setContextSelector(new CPAContextSelector(builder.getContextSelector())); CallGraph CG = builder.makeCallGraph(builder.getOptions()); JSCallGraphUtil.AVOID_DUMP = false; CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); }
@Test public void testBadForInWithHack() throws IOException, IllegalArgumentException, CancelException, WalaException { JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "badforin.js"); addHackedForInLoopSensitivity(B); CallGraph CG = B.makeCallGraph(B.getOptions()); CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForBadForin); verifyGraphAssertions(CG, assertionsForBadForinHackPrecision); }
@Test(expected = CallGraphBuilderCancelException.class) public void testManyStrings() throws IllegalArgumentException, IOException, CancelException, WalaException { SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "many-strings.js"); B.getOptions().setTraceStringConstants(true); ProgressMaster monitor = ProgressMaster.make(new NullProgressMonitor(), 10000, false); monitor.beginTask("build CG", 1); CallGraph CG = B.makeCallGraph(B.getOptions(), monitor); monitor.done(); CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG); }