more JS stuff

This commit is contained in:
dolby 2012-08-22 12:15:46 -04:00
parent 0a3acfde4a
commit 0518b5242b
107 changed files with 10787 additions and 103 deletions

View File

@ -3,5 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="source"/>
<classpathentry kind="src" path="data"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -14,6 +14,7 @@ Require-Bundle: com.ibm.wala.cast.java.test;bundle-version="1.0.0",
com.ibm.wala.cast;bundle-version="1.0.0",
com.ibm.wala.ide;bundle-version="1.1.3",
com.ibm.wala.core;bundle-version="1.1.3",
com.ibm.wala.util;bundle-version="1.1.3",
org.eclipse.core.resources;bundle-version="3.4.1",
org.eclipse.jdt.core;bundle-version="3.4.2",
org.junit4;bundle-version="4.8.1",

View File

@ -0,0 +1,11 @@
java\/awt\/.*
javax\/swing\/.*
sun\/awt\/.*
sun\/swing\/.*
com\/sun\/.*
sun\/.*
org\/netbeans\/.*
org\/openide\/.*
com\/ibm\/crypto\/.*
com\/ibm\/security\/.*
org\/apache\/xerces\/.*

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,305 @@
/**
* Refinement Analysis Tools is Copyright (c) 2007 The Regents of the
* University of California (Regents). Provided that this notice and
* the following two paragraphs are included in any distribution of
* Refinement Analysis Tools or its derivative work, Regents agrees
* not to assert any of Regents' copyright rights in Refinement
* Analysis Tools against recipient for recipient's reproduction,
* preparation of derivative works, public display, public
* performance, distribution or sublicensing of Refinement Analysis
* Tools and derivative works, in source code and object code form.
* This agreement not to assert does not confer, by implication,
* estoppel, or otherwise any license or rights in any intellectual
* property of Regents, including, but not limited to, any patents
* of Regents or Regents' employees.
*
* IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
* INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE
* AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE AND FURTHER DISCLAIMS ANY STATUTORY
* WARRANTY OF NON-INFRINGEMENT. THE SOFTWARE AND ACCOMPANYING
* DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
* IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
* UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
package com.ibm.wala.demandpa.driver;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import org.eclipse.core.runtime.NullProgressMonitor;
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
import com.ibm.wala.core.tests.util.TestConstants;
import com.ibm.wala.demandpa.alg.ContextSensitiveStateMachine;
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo;
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo.PointsToResult;
import com.ibm.wala.demandpa.alg.refinepolicy.FieldRefinePolicy;
import com.ibm.wala.demandpa.alg.refinepolicy.ManualFieldPolicy;
import com.ibm.wala.demandpa.alg.refinepolicy.ManualRefinementPolicy;
import com.ibm.wala.demandpa.alg.refinepolicy.RefinementPolicyFactory;
import com.ibm.wala.demandpa.alg.refinepolicy.TunedRefinementPolicy;
import com.ibm.wala.demandpa.alg.statemachine.StateMachineFactory;
import com.ibm.wala.demandpa.flowgraph.IFlowLabel;
import com.ibm.wala.demandpa.util.MemoryAccessMap;
import com.ibm.wala.demandpa.util.SimpleMemoryAccessMap;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException;
import com.ibm.wala.ipa.callgraph.CallGraphStats;
import com.ibm.wala.ipa.callgraph.Entrypoint;
import com.ibm.wala.ipa.callgraph.impl.Util;
import com.ibm.wala.ipa.callgraph.propagation.HeapModel;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
import com.ibm.wala.ipa.cha.ClassHierarchy;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.properties.WalaProperties;
import com.ibm.wala.ssa.IR;
import com.ibm.wala.ssa.SSACheckCastInstruction;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.Predicate;
import com.ibm.wala.ide.util.ProgressMaster;
import com.ibm.wala.ide.util.ProgressMonitorDelegate;
import com.ibm.wala.util.WalaException;
import com.ibm.wala.util.collections.Pair;
import com.ibm.wala.util.debug.Assertions;
/**
* Uses a demand-driven points-to analysis to check the safety of downcasts.
*
* @author Manu Sridharan
*
*/
public class DemandCastChecker {
// maximum number of casts to check
private static final int MAX_CASTS = Integer.MAX_VALUE;
/**
* @param args
* @throws CancelException
* @throws IllegalArgumentException
* @throws IOException
*/
public static void main(String[] args) throws IllegalArgumentException, CancelException, IOException {
try {
Properties p = new Properties();
p.putAll(WalaProperties.loadProperties());
} catch (WalaException e) {
e.printStackTrace();
Assertions.UNREACHABLE();
}
runTestCase(TestConstants.JLEX_MAIN, TestConstants.JLEX, "JLex");
// runTestCase(TestConstants.HELLO_MAIN, TestConstants.HELLO, "Hello");
}
public static void runTestCase(String mainClass, String scopeFile, String benchName) throws IllegalArgumentException,
CancelException, IOException {
System.err.println("=====BENCHMARK " + benchName + "=====");
System.err.println("analyzing " + benchName);
DemandRefinementPointsTo dmp = null;
try {
dmp = makeDemandPointerAnalysis(scopeFile, mainClass, benchName);
findFailingCasts(dmp.getBaseCallGraph(), dmp);
} catch (ClassHierarchyException e) {
e.printStackTrace();
}
System.err.println("=*=*=*=*=*=*=*=*=*=*=*=*=*=*");
System.err.println("");
System.err.println("");
}
private static DemandRefinementPointsTo makeDemandPointerAnalysis(String scopeFile, String mainClass, String benchName)
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(scopeFile, getExclusions(benchName));
// build a type hierarchy
ClassHierarchy cha = ClassHierarchy.make(scope);
// set up call graph construction options; mainly what should be considered
// entrypoints?
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass);
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
System.err.print("constructing call graph...");
final Pair<CallGraph, PointerAnalysis> cgAndPA = buildCallGraph(scope, cha, options);
CallGraph cg = cgAndPA.fst;
System.err.println("done");
System.err.println(CallGraphStats.getStats(cg));
MemoryAccessMap fam = new SimpleMemoryAccessMap(cg, cgAndPA.snd.getHeapModel(), false);
DemandRefinementPointsTo fullDemandPointsTo = DemandRefinementPointsTo.makeWithDefaultFlowGraph(cg, heapModel, fam, cha, options, makeStateMachineFactory());
fullDemandPointsTo.setRefinementPolicyFactory(chooseRefinePolicyFactory(cha));
return fullDemandPointsTo;
}
private static String getExclusions(String benchName) {
return CallGraphTestUtil.REGRESSION_EXCLUSIONS;
}
// if true, construct up-front call graph cheaply (0-CFA)
private static final boolean CHEAP_CG = true;
private static HeapModel heapModel;
/**
* builds a call graph, and sets the corresponding heap model for analysis
*
* @param scope
* @param cha
* @param options
* @return
* @throws CancelException
* @throws IllegalArgumentException
*/
private static Pair<CallGraph, PointerAnalysis> buildCallGraph(AnalysisScope scope, ClassHierarchy cha, AnalysisOptions options)
throws IllegalArgumentException, CancelException {
CallGraph retCG = null;
PointerAnalysis retPA = null;
final AnalysisCache cache = new AnalysisCache();
CallGraphBuilder builder;
if (CHEAP_CG) {
builder = Util.makeZeroCFABuilder(options, cache, cha, scope);
// we want vanilla 0-1 CFA, which has one abstract loc per allocation
heapModel = Util.makeVanillaZeroOneCFABuilder(options, cache, cha, scope);
} else {
builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
heapModel = (HeapModel) builder;
}
ProgressMaster master = ProgressMaster.make(new NullProgressMonitor());
master.setMillisPerWorkItem(360000);
master.beginTask("runSolver", 1);
try {
retCG = builder.makeCallGraph(options, ProgressMonitorDelegate.createProgressMonitorDelegate(master));
retPA = builder.getPointerAnalysis();
} catch (CallGraphBuilderCancelException e) {
System.err.println("TIMED OUT!!");
retCG = e.getPartialCallGraph();
retPA = e.getPartialPointerAnalysis();
}
return Pair.make(retCG, retPA);
}
private static RefinementPolicyFactory chooseRefinePolicyFactory(ClassHierarchy cha) {
if (true) {
return new TunedRefinementPolicy.Factory(cha);
} else {
return new ManualRefinementPolicy.Factory(cha);
}
}
private static StateMachineFactory<IFlowLabel> makeStateMachineFactory() {
return new ContextSensitiveStateMachine.Factory();
}
private static List<Pair<CGNode, SSACheckCastInstruction>> findFailingCasts(CallGraph cg, DemandRefinementPointsTo dmp) {
final IClassHierarchy cha = dmp.getClassHierarchy();
List<Pair<CGNode, SSACheckCastInstruction>> failing = new ArrayList<Pair<CGNode, SSACheckCastInstruction>>();
int numSafe = 0, numMightFail = 0;
outer: for (Iterator<? extends CGNode> nodeIter = cg.iterator(); nodeIter.hasNext();) {
CGNode node = nodeIter.next();
TypeReference declaringClass = node.getMethod().getReference().getDeclaringClass();
// skip library classes
if (declaringClass.getClassLoader().equals(ClassLoaderReference.Primordial)) {
continue;
}
IR ir = node.getIR();
if (ir == null)
continue;
SSAInstruction[] instrs = ir.getInstructions();
for (int i = 0; i < instrs.length; i++) {
if (numSafe + numMightFail > MAX_CASTS)
break outer;
SSAInstruction instruction = instrs[i];
if (instruction instanceof SSACheckCastInstruction) {
SSACheckCastInstruction castInstr = (SSACheckCastInstruction) instruction;
final TypeReference[] declaredResultTypes = castInstr.getDeclaredResultTypes();
boolean primOnly = true;
for (TypeReference t : declaredResultTypes) {
if (! t.isPrimitiveType()) {
primOnly = false;
}
}
if (primOnly) {
continue;
}
System.err.println("CHECKING " + castInstr + " in " + node.getMethod());
PointerKey castedPk = heapModel.getPointerKeyForLocal(node, castInstr.getUse(0));
Predicate<InstanceKey> castPred = new Predicate<InstanceKey>() {
@Override
public boolean test(InstanceKey ik) {
TypeReference ikTypeRef = ik.getConcreteType().getReference();
for (TypeReference t : declaredResultTypes) {
if (cha.isAssignableFrom(cha.lookupClass(t), cha.lookupClass(ikTypeRef))) {
return true;
}
}
return false;
}
};
long startTime = System.currentTimeMillis();
Pair<PointsToResult, Collection<InstanceKey>> queryResult = dmp.getPointsTo(castedPk, castPred);
long runningTime = System.currentTimeMillis() - startTime;
System.err.println("running time: " + runningTime + "ms");
final FieldRefinePolicy fieldRefinePolicy = dmp.getRefinementPolicy().getFieldRefinePolicy();
switch (queryResult.fst) {
case SUCCESS:
System.err.println("SAFE: " + castInstr + " in " + node.getMethod());
if (fieldRefinePolicy instanceof ManualFieldPolicy) {
ManualFieldPolicy hackedFieldPolicy = (ManualFieldPolicy) fieldRefinePolicy;
System.err.println(hackedFieldPolicy.getHistory());
}
System.err.println("TRAVERSED " + dmp.getNumNodesTraversed() + " nodes");
numSafe++;
break;
case NOMOREREFINE:
if (queryResult.snd != null) {
System.err.println("MIGHT FAIL: no more refinement possible for " + castInstr + " in " + node.getMethod());
} else {
System.err.println("MIGHT FAIL: exceeded budget for " + castInstr + " in " + node.getMethod());
}
failing.add(Pair.make(node, castInstr));
numMightFail++;
break;
case BUDGETEXCEEDED:
System.err.println("MIGHT FAIL: exceeded budget for " + castInstr + " in " + node.getMethod());
failing.add(Pair.make(node, castInstr));
numMightFail++;
break;
default:
Assertions.UNREACHABLE();
}
}
}
// break outer;
}
System.err.println("TOTAL SAFE: " + numSafe);
System.err.println("TOTAL MIGHT FAIL: " + numMightFail);
return failing;
}
}

Binary file not shown.

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.wala.cast.js.test.data</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="examples-src"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.FireFoxBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>

View File

@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.JRE_CONTAINER

View File

@ -0,0 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Eclipse-LazyStart: true
Bundle-Name: %pluginName
Bundle-SymbolicName: com.ibm.wala.cast.js.test.data
Bundle-Version: 1.1.3.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy

View File

@ -0,0 +1,63 @@
(function _top_level () {
var jQuery = window.jQuery = window.$ = function (selector, context) {
return new jQuery.fn.init(selector, context);
};
var undefined;
jQuery.extend = jQuery.fn.extend = function _extend () {
var target = arguments[0] || {},
i = 1,
length = arguments.length,
deep = false,
options;
if (target.constructor == Boolean) {
deep = target;
target = arguments[1] || {};
i = 2;
}
if (typeof target != "object" && typeof target != "function") target = {};
if (length == i) {
target = this;
--i;
}
for (; i < length; i++) if ((options = arguments[i]) != null)
for (var name in options) {
(function _forin_body (name) {
var src = target[name],
copy = options[name];
if (target === copy) return;
if (deep && copy && typeof copy == "object" && !copy.nodeType) {
target[name] = jQuery.extend(deep, src || (copy.length != null ? [] : {}), copy);
}
else if (copy !== undefined) target[name] = copy;
else target[name] = copy;
})(name);
}
return target;
};
jQuery.extend({
speed: function _speed (speed, easing, fn) {
var opt = speed && speed.constructor == Object ? speed : {
complete: fn || !fn && easing || jQuery.isFunction(speed) && speed,
duration: speed,
easing: fn && easing || easing && easing.constructor != Function && easing
};
opt.duration = (opt.duration && opt.duration.constructor == Number ? opt.duration : jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
opt.old = opt.complete;
opt.complete = function _complete () {
if (opt.queue !== false) jQuery(this).dequeue();
if (jQuery.isFunction(opt.old)) opt.old.call(this);
};
return opt;
},
});
})();

View File

@ -0,0 +1,27 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD><TITLE>Login</TITLE></HEAD>
<SCRIPT>
function signon() {
var form = document.forms[0];
var elts = form.operation;
for (var elt in elts) {
if (elts[elt].checked==true) {
window.open(elts[elt].value + ".php?user=" + form.user.value + "&pw=" + form.pw.value);
}
}
}
</SCRIPT>
<BODY>
<FORM ID="theform" METHOD = "post" NAME = "login"
ACTION="javascript: signon();">
User Name: <INPUT TYPE = "text" NAME = "user"/><BR>
Password: <INPUT TYPE = "password" NAME = "pw"/><BR>
<INPUT TYPE="radio" NAME="operation" VALUE="query"/>Query
<INPUT TYPE="radio" NAME="operation" VALUE="update"/>Update <BR>
<INPUT TYPE="submit" NAME="Submit"/>
</FORM>
</BODY>
</HTML>

View File

@ -0,0 +1,14 @@
function collection() {
// initially empty collection
this.forall = function forall_base (f) { };
// allow adding items
this.add = function collection_add (new_item) {
var oldforall = this.forall;
this.forall = function forall_elt (f) {
oldforall(f);
f(new_item);
};
};
}

View File

@ -0,0 +1,196 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script>
var g_image_number = 0;
</script>
<script>
function test_function_base_crawling()
{
var href;
href = "results.html?";
href += "function_base_crawling_";
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
document.location.href = href;
}
</script>
<script>
function test_event_element()
{
var href;
href = "results.html?";
href += "event_element_";
if (window.event == undefined) {
href += (12*document.location.href.length) ? "unsupported" : "strange_behaviour";
} else if (!isNaN(window.event.srcElement)) {
href += (12*document.location.href.length) ? "srcElement_unsupported" : "strange_behaviour";
} else if (!isNaN(window.event.srcElement)) {
href += (12*document.location.href.length) ? "srcElement_attr_unsupported" : "strange_behaviour";
} else {
href += (12*document.location.href.length) ? "worked" : "strange_behaviour";
}
document.location.href = href;
}
</script>
<script>
function test_isNaN()
{
var href;
href = "results.html?";
href += "isNaN_";
if (!isNaN(window.asghdaa)) {
href += (12*document.location.href.length) ? "unsupported" : "strange_behaviour";
} else {
href += (12*document.location.href.length) ? "worked" : "strange_behaviour";
}
document.location.href = href;
}
</script>
<script>
function test_first_phase()
{
var href;
href = "results.html?";
href += "first_phase_";
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
document.location.href = href;
}
</script>
<script>
function test_second_phase()
{
var button = document.createElement("button");
button.innerText = "go to second phase html";
document.body.appendChild(button);
button.onclick = function () {
var href;
href = "results.html?";
href += "second_phase_";
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
document.location.href = href;
};
var thirdButton = document.createElement("button");
thirdButton.innerText = 'Test "Third Phase Competability"';
thirdButton.onclick = test_third_phase;
document.body.appendChild(thirdButton);
}
</script>
<script>
function test_third_phase()
{
var button = document.createElement("button");
button.innerText = "go to third phase html";
document.body.appendChild(button);
button.onclick = function () {
var href;
href = "results.html?";
href += "third_phase_";
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
document.location.href = href;
}
}
</script>
<script>
function test_n_phase()
{
var button = document.createElement("button");
button.tag = isNaN(event.srcElement.tag) ? 1 : Number(event.srcElement.tag) + 1;
button.innerText = "go to "+button.tag+" phase html";
button.onclick = function () {
var href;
href = "results.html?";
href += "n_phase_"+button.tag+"_";
href += (12*document.location.href.length) ? "worked" : "/strange_behaviour";
document.location.href = href;
};
var linkButton = document.createElement("button");
linkButton.tag = button.tag;
linkButton.innerText = "create "+linkButton.tag+" phase button";
linkButton.onclick = test_n_phase;
document.body.appendChild(linkButton);
document.body.appendChild(button);
}
</script>
<script>
var differentOrder = "/differnet_order_";
</script>
<script>
function test_both_order2()
{
differentOrder += "2";
test_both_order_button.innerText = 'Test "Different Order Competability 2"';
}
</script>
<script>
function test_both_order()
{
var href;
href = "results.html?";
href += "both_order_";
href += (test_both_order_button.innerText.substr(test_both_order_button.innerText.length-2,1));
href += ".html";
document.location.href = href;
}
</script>
<script>
function send_unique_dom_request()
{
var href;
href = "results.html?";
href += "dom_unique";
href += ".html";
document.location.href = href;
}
</script>
<script>
function send_same_dom_request()
{
var href;
href = "results.html?";
href += "dom_same";
href += ".html";
document.location.href = href;
}
</script>
<script>
function test_unique_dom_button2()
{
test_unique_dom_button.onclick = send_same_dom_request;
}
</script>
<body>
<BR><BR><BR><HR><BR><BR><BR>
<BR><button onclick = "test_event_element()">Test "Event Element"</button>
<BR><button onclick = "test_isNaN()">Test "isNaN Competability"</button>
<BR><button onclick = "test_first_phase()">Test "First Phase Competability"</button>
<BR><button onclick = "test_second_phase()">Test "Second Phase Competability"</button>
<BR><button onclick = "test_n_phase()">Test "N Phase Competability"</button>
<BR><button id=test_both_order_button onclick = "test_both_order()">Test "Different Order Competability 1"</button>
<button onclick = "test_both_order2()">Change Different Order Location</button>
<BR><button onclick = "test_unique_dom_button2()">Change Next element onclick Method</button>
<button id=test_unique_dom_button onclick = "send_unique_dom_request()">Test "Unique Dom Competability"</button>
<BR>
</body>
</html>

View File

@ -0,0 +1,4 @@
function changeUrls()
{
document.links[0].href = "page15.php?a=ok";
}

View File

@ -0,0 +1,4 @@
function changeUrls()
{
document.links[0].href = "page16.php?a=ok";
}

View File

@ -0,0 +1,4 @@
function changeUrls()
{
document.links[0].href = "page17.php?a=ok";
}

View File

@ -0,0 +1,25 @@
<html>
<body>
<script>
var myForm = document.createElement("form");
myForm.setAttribute("action","page11.php");
myForm.setAttribute("method","GET");
var myHiddenA = document.createElement("input");
myHiddenA.setAttribute("type","hidden");
myHiddenA.setAttribute("name","a");
myHiddenA.setAttribute("value","ok");
var myHiddenB = document.createElement("input");
myHiddenB.setAttribute("type","hidden");
myHiddenB.setAttribute("name","b");
myHiddenB.setAttribute("value","ok");
var mySubmit = document.createElement("input");
mySubmit.setAttribute("type","submit");
mySubmit.setAttribute("name","submit");
mySubmit.setAttribute("value","submit");
myForm.appendChild(myHiddenA);
myForm.appendChild(myHiddenB);
myForm.appendChild(mySubmit);
document.body.appendChild(myForm);
</script>
</body>
</html>

View File

@ -0,0 +1,25 @@
<HTML>
<BODY>
<SCRIPT>
var myForm = document.createElement("form");
myForm.setAttribute("action","page11.php");
myForm.setAttribute("method","GET");
var myHiddenA = document.createElement("input");
myHiddenA.setAttribute("type","hidden");
myHiddenA.setAttribute("name","a");
myHiddenA.setAttribute("value","ok");
var myHiddenB = document.createElement("input");
myHiddenB.setAttribute("type","hidden");
myHiddenB.setAttribute("name","b");
myHiddenB.setAttribute("value","ok");
var mySubmit = document.createElement("input");
mySubmit.setAttribute("type","submit");
mySubmit.setAttribute("name","submit");
mySubmit.setAttribute("value","submit");
myForm.appendChild(myHiddenA);
myForm.appendChild(myHiddenB);
myForm.appendChild(mySubmit);
document.body.appendChild(myForm);
</SCRIPT>
</BODY>
</HTML>

View File

@ -0,0 +1,31 @@
<html>
<head>
<script>
function handler()
{
if(this.readyState == 4)
{
var contents = this.responseText;
document.getElementById("myDiv").innerHTML = contents;
}
return;
}
function callXHR()
{
var textBoxValue = document.getElementById("freeTextField").value;
var client = new XMLHttpRequest();
client.onreadystatechange = handler;
client.open("GET", "page12.php?freeTextField="+textBoxValue, true);
client.send(null);
return;
}
</script>
</head>
<body>
<div id="myDiv" style="location: absolute; top: 100px; left: 100px; height: 400px; width: 400px; background-color: #ff0000;"></div>
<input type="text" id="freeTextField" name="freeTextField" value="DEFAULT_SHOULD_BE_CHANGED"></input>
<button onclick="return callXHR();">SUBMIT</button>
</body>
</html>

View File

@ -0,0 +1,32 @@
<html>
<head>
<script>
function handler()
{
if(this.readyState == 4)
{
var contents = this.responseText;
document.getElementById("myDiv").innerHTML = contents;
}
return;
}
function callXHR()
{
var textBoxValue = document.getElementById("freeTextField").value;
var client = new XMLHttpRequest();
client.onreadystatechange = handler;
client.open("POST", "page13.php", true);
client.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
client.send("freeTextField="+textBoxValue);
return;
}
</script>
</head>
<body>
<div id="myDiv" style="location: absolute; top: 100px; left: 100px; height: 400px; width: 400px; background-color: #ff0000;"></div>
<input type="text" id="freeTextField" name="freeTextField" value="DEFAULT_SHOULD_BE_CHANGED"></input>
<button onclick="return callXHR();">SUBMIT</button>
</body>
</html>

View File

@ -0,0 +1,8 @@
<html>
<head>
<script src="15.js"></script>
</head>
<body onload="return changeUrls();">
<a href="#">Link to be changed onload</a>
</body>
</html>

View File

@ -0,0 +1,8 @@
<html>
<head>
<script src="16.js"></script>
</head>
<body>
<a href="#" onclick="return changeUrls();">Link to be changed onload</a>
</body>
</html>

View File

@ -0,0 +1,37 @@
<html>
<head>
<script>
function loadScript(url, callback)
{
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = url;
var done = false;
script.onload = script.onreadystatechange = function _page17_handler()
{
if( !done && ( !this.readyState || this.readyState == "loaded" || this.readyState == "complete"))
{
done = true;
callback();
script.onload = script.onreadystatechange = null;
head.removeChild( script );
}
};
head.appendChild(script);
}
function callFunction()
{
changeUrls();
}
</script>
</head>
<body>
<a href="#">Test Link</a>
<script>
loadScript("17.js", callFunction);
</script>
</body>
</html>

View File

@ -0,0 +1,23 @@
<html><head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>iframe</title></head>
<body>
<script>
function f() {}
</script>
<iframe src="frameBody.html" onload="f()"></iframe>
<script>
function h(x) { function f(x) { return x; }; return f(x); }; h(3);
</script>
</body></html>

View File

@ -0,0 +1,263 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script>
(function top () {
var c = n.jQuery = n.$ = function dollar (a, d) {
return new c.fn.init(a, d)
}
c.fn = c.prototype = {
init: function init (a, d) {
a = a || document;
if (a.nodeType) {
this[0] = a;
this.length = 1;
this.context = a;
return this
}
if (typeof a === "string") {
var f = r.exec(a);
if (f && (f[1] || !d)) if (f[1]) a = c.clean([f[1]], d);
else {
if ((d = document.getElementById(f[3])) && d.id != f[3]) return c().find(a);
f = c(d || []);
f.context = document;
f.selector = a;
return f
} else return c(d).find(a)
} else if (c.isFunction(a)) return c(document).ready(a);
if (a.selector && a.context) {
this.selector =
a.selector;
this.context = a.context
}
return this.setArray(c.isArray(a) ? a : c.makeArray(a))
}
};
c.extend = c.fn.extend = function extend () {
var a =
arguments[0] || {},
d = 1,
f = arguments.length,
j = false,
q;
if (typeof a === "boolean") {
j = a;
a = arguments[1] || {};
d = 2
}
if (typeof a !== "object" && !c.isFunction(a)) a = {};
if (f == d) {
a = this;
--d
}
for (; d < f; d++) if ((q = arguments[d]) != null) for (var t in q) {
var y = a[t],
A = q[t];
if (a !== A) if (j && A && typeof A === "object" && !A.nodeType) a[t] = c.extend(j, y || (A.length != null ? [] : {}), A);
else if (A !== void 0) a[t] = A
}
return a
};
c.extend({
noConflict: function noConflict (a) {
n.$ =
B;
if (a) n.jQuery = w;
return c
},
isFunction: 2,
each: function each (a, d, f) {
var j, q = 0,
t = a.length;
if (f) if (t === void 0) for (j in a) {
if (d.apply(a[j], f) === false) break
} else for (; q < t;) {
if (d.apply(a[q++], f) === false) break
} else if (t === void 0) for (j in a) {
if (d.call(a[j], j, a[j]) === false) break
} else for (f = a[0]; q < t && d.call(f, q, f) !== false; f = a[++q]);
return a
},
className: {
add: function add (a, d) {
c.each((d || "").split(/\s+/), function (f, j) {
if (a.nodeType == 1 && !c.className.has(a.className, j)) a.className += (a.className ? " " : "") + j
})
},
remove: function remove (a, d) {
if (a.nodeType == 1) a.className = d !== void 0 ? c.grep(a.className.split(/\s+/), function (f) {
return !c.className.has(d, f)
}).join(" ") : ""
},
has: function has (a, d) {
return a && c.inArray(d, (a.className || a).toString().split(/\s+/)) > -1
}
},
swap: function swap (a, d, f) {
var j = {};
for (var q in d) {
j[q] = a.style[q];
a.style[q] = d[q]
}
f.call(a);
for (q in d) a.style[q] = j[q]
},
css: function css (a, d, f, j) {
if (d == "width" || d == "height") {
var q;
f = {
position: "absolute",
visibility: "hidden",
display: "block"
};
var t = d == "width" ? ["Left", "Right"] : ["Top", "Bottom"],
y = function () {
q = d == "width" ? a.offsetWidth : a.offsetHeight;
j !== "border" && c.each(t, function () {
j || (q -= parseFloat(c.curCSS(a, "padding" + this, true)) || 0);
if (j === "margin") q += parseFloat(c.curCSS(a, "margin" + this, true)) || 0;
else q -= parseFloat(c.curCSS(a, "border" + this + "Width", true)) || 0
})
};
a.offsetWidth !== 0 ? y() : c.swap(a, f, y);
return Math.max(0, Math.round(q))
}
return c.curCSS(a, d, f)
},
curCSS: function curCSS (a, d, f) {
var j, q = a.style;
if (d == "opacity" && !c.support.opacity) {
j = c.attr(q, "opacity");
return j == "" ? "1" : j
}
if (d.match(/float/i)) d = W;
if (!f && q && q[d]) j = q[d];
else if (F.getComputedStyle) {
if (d.match(/float/i)) d = "float";
d = d.replace(/([A-Z])/g, "-$1").toLowerCase();
if (a = F.getComputedStyle(a, null)) j = a.getPropertyValue(d);
if (d == "opacity" && j == "") j = "1"
} else if (a.currentStyle) {
j = d.replace(/\-(\w)/g, function (t, y) {
return y.toUpperCase()
});
j = a.currentStyle[d] || a.currentStyle[j];
if (!/^\d+(px)?$/i.test(j) && /^\d/.test(j)) {
d = q.left;
f = a.runtimeStyle.left;
a.runtimeStyle.left = a.currentStyle.left;
q.left = j || 0;
j = q.pixelLeft + "px";
q.left = d;
a.runtimeStyle.left = f
}
}
return j
},
clean: function clean (a, d, f) {
d = d || document;
if (typeof d.createElement === "undefined") d = d.ownerDocument || d[0] && d[0].ownerDocument || document;
if (!f && a.length === 1 && typeof a[0] === "string") {
var j = /^<(\w+)\s*\/?>$/.exec(a[0]);
if (j) return [d.createElement(j[1])]
}
c.each(a, function (y, A) {
if (typeof A === "number") A += "";
if (A) {
if (typeof A === "string") {
A = A.replace(/(<(\w+)[^>]*?)\/>/g, function (M, Q, S) {
return S.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? M : Q + "></" + S + ">"
});
y = A.replace(/^\s+/, "").substring(0, 10).toLowerCase();
var L = !y.indexOf("<opt") && [1, "<select multiple='multiple'>", "</select>"] || !y.indexOf("<leg") && [1, "<fieldset>", "</fieldset>"] || y.match(/^<(thead|tbody|tfoot|colg|cap)/) && [1, "<table>", "</table>"] || !y.indexOf("<tr") && [2, "<table><tbody>", "</tbody></table>"] || (!y.indexOf("<td") || !y.indexOf("<th")) && [3, "<table><tbody><tr>", "</tr></tbody></table>"] || !y.indexOf("<col") && [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"] || !c.support.htmlSerialize && [1, "div<div>", "</div>"] || [0, "", ""];
for (t.innerHTML = L[1] + A + L[2]; L[0]--;) t = t.lastChild;
if (!c.support.tbody) {
var N = /<tbody/i.test(A);
y = !y.indexOf("<table") && !N ? t.firstChild && t.firstChild.childNodes : L[1] == "<table>" && !N ? t.childNodes : [];
for (L = y.length - 1; L >= 0; --L) c.nodeName(y[L], "tbody") && !y[L].childNodes.length && y[L].parentNode.removeChild(y[L])
}!c.support.leadingWhitespace && /^\s/.test(A) && t.insertBefore(d.createTextNode(A.match(/^\s*/)[0]), t.firstChild);
A = c.makeArray(t.childNodes)
}
if (A.nodeType) q.push(A);
else q = c.merge(q, A)
}
});
if (f) {
for (a = 0; q[a]; a++) if (c.nodeName(q[a], "script") && (!q[a].type || q[a].type.toLowerCase() === "text/javascript")) j.push(q[a].parentNode ? q[a].parentNode.removeChild(q[a]) : q[a]);
else {
q[a].nodeType === 1 && q.splice.apply(q, [a + 1, 0].concat(c.makeArray(q[a].getElementsByTagName("script"))));
f.appendChild(q[a])
}
return j
}
return q
},
attr: function attr (a, d, f) {
if (!(!a || a.nodeType == 3 || a.nodeType == 8)) {
var j = !c.isXMLDoc(a),
q = f !== void 0;
d = j && c.props[d] || d;
if (a.tagName) {
var t = /href|src|style/.test(d);
if (d in a && j && !t) {
if (q) {
if (d == "type" && c.nodeName(a, "input") && a.parentNode) throw "type property can't be changed";
a[d] = f
}
if (c.nodeName(a, "form") && a.getAttributeNode(d)) return a.getAttributeNode(d).nodeValue;
if (d == "tabIndex") return (d = a.getAttributeNode("tabIndex")) && d.specified ? d.value : a.nodeName.match(/(button|input|object|select|textarea)/i) ? 0 : a.nodeName.match(/^(a|area)$/i) && a.href ? 0 : void 0;
return a[d]
}
if (!c.support.style && j && d == "style") return c.attr(a.style, "cssText", f);
q && a.setAttribute(d, "" + f);
a = !c.support.hrefNormalized && j && t ? a.getAttribute(d, 2) : a.getAttribute(d);
return a === null ? void 0 : a
}
if (!c.support.opacity && d == "opacity") {
if (q) {
a.zoom = 1;
a.filter = (a.filter || "").replace(/alpha\([^)]*\)/, "") + (parseInt(f) + "" == "NaN" ? "" : "alpha(opacity=" + f * 100 + ")")
}
return a.filter && a.filter.indexOf("opacity=") >= 0 ? parseFloat(a.filter.match(/opacity=([^)]*)/)[1]) / 100 + "" : ""
}
d = d.replace(/-([a-z])/ig, function (y, A) {
return A.toUpperCase()
});
if (q) a[d] = f;
return a[d]
}
},
makeArray: function makeArray (a) {
var d = [];
if (a != null) {
var f = a.length;
if (f == null || typeof a === "string" || c.isFunction(a) || a.setInterval) d[0] = a;
else for (; f;) d[--f] = a[f]
}
return d
},
inArray: function inArray (a, d) {
for (var f = 0, j = d.length; f < j; f++) if (d[f] === a) return f;
return -1
},
merge: function merge (a, d) {
var f = 0,
j, q = a.length;
if (c.support.getAll) for (;
(j = d[f++]) != null;) a[q++] = j;
else for (;
(j =
d[f++]) != null;) if (j.nodeType != 8) a[q++] = j;
return a
},
});
})();
</script>

View File

@ -0,0 +1,16 @@
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<button>Click me</button>
</body>
</html>

View File

@ -0,0 +1,288 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script>
(function top () {
var c = n.jQuery = n.$ = function dollar (a, d) {
return new c.fn.init(a, d)
}
c.fn = c.prototype = {
init: function init (a, d) {
a = a || document;
if (a.nodeType) {
this[0] = a;
this.length = 1;
this.context = a;
return this
}
if (typeof a === "string") {
var f = r.exec(a);
if (f && (f[1] || !d)) if (f[1]) a = c.clean([f[1]], d);
else {
if ((d = document.getElementById(f[3])) && d.id != f[3]) return c().find(a);
f = c(d || []);
f.context = document;
f.selector = a;
return f
} else return c(d).find(a)
} else if (c.isFunction(a)) return c(document).ready(a);
if (a.selector && a.context) {
this.selector =
a.selector;
this.context = a.context
}
return this.setArray(c.isArray(a) ? a : c.makeArray(a))
}
};
c.extend = c.fn.extend = function extend () {
var a =
arguments[0] || {},
d = 1,
f = arguments.length,
j = false,
q;
if (typeof a === "boolean") {
j = a;
a = arguments[1] || {};
d = 2
}
if (typeof a !== "object" && !c.isFunction(a)) a = {};
if (f == d) {
a = this;
--d
}
for (; d < f; d++)
if ((q = arguments[d]) != null) {
for (var t in q) {
(function _forin_body_1(t) {
var y = a[t],
A = q[t];
if (a !== A)
if (j && A && typeof A === "object" && !A.nodeType) a[t] = c.extend(j, y || (A.length != null ? [] : {}), A);
else if (A !== void 0) a[t] = A
})(t);
}
}
return a
};
c.extend({
noConflict: function noConflict (a) {
n.$ =
B;
if (a) n.jQuery = w;
return c
},
isFunction: 2,
each: function each (a, d, f) {
var j, q = 0,
t = a.length;
if (f) if (t === void 0) { for (j in a) {
if ((function _forin_body_2(j) {
if (d.apply(a[j], f) === false) return true;
else return false;
})(j)) {
break;
}
} } else for (; q < t;) {
if (d.apply(a[q++], f) === false) break
} else if (t === void 0) { for (j in a) {
if ((function _forin_body_3(j) {
if (d.call(a[j], j, a[j]) === false)
return true;
else
return false;
})(j)) {
break
}
}
} else for (f = a[0]; q < t && d.call(f, q, f) !== false; f = a[++q]);
return a
},
className: {
add: function add (a, d) {
c.each((d || "").split(/\s+/), function (f, j) {
if (a.nodeType == 1 && !c.className.has(a.className, j)) a.className += (a.className ? " " : "") + j
})
},
remove: function remove (a, d) {
if (a.nodeType == 1) a.className = d !== void 0 ? c.grep(a.className.split(/\s+/), function (f) {
return !c.className.has(d, f)
}).join(" ") : ""
},
has: function has (a, d) {
return a && c.inArray(d, (a.className || a).toString().split(/\s+/)) > -1
}
},
swap: function swap (a, d, f) {
var j = {};
for (var q in d) {
(function _forin_body_4(q) {
j[q] = a.style[q];
a.style[q] = d[q]
})(q);
}
f.call(a);
for (q in d) {
(function _forin_body_5(q) {
a.style[q] = j[q]
})(q);
}
},
css: function css (a, d, f, j) {
if (d == "width" || d == "height") {
var q;
f = {
position: "absolute",
visibility: "hidden",
display: "block"
};
var t = d == "width" ? ["Left", "Right"] : ["Top", "Bottom"],
y = function () {
q = d == "width" ? a.offsetWidth : a.offsetHeight;
j !== "border" && c.each(t, function () {
j || (q -= parseFloat(c.curCSS(a, "padding" + this, true)) || 0);
if (j === "margin") q += parseFloat(c.curCSS(a, "margin" + this, true)) || 0;
else q -= parseFloat(c.curCSS(a, "border" + this + "Width", true)) || 0
})
};
a.offsetWidth !== 0 ? y() : c.swap(a, f, y);
return Math.max(0, Math.round(q))
}
return c.curCSS(a, d, f)
},
curCSS: function curCSS (a, d, f) {
var j, q = a.style;
if (d == "opacity" && !c.support.opacity) {
j = c.attr(q, "opacity");
return j == "" ? "1" : j
}
if (d.match(/float/i)) d = W;
if (!f && q && q[d]) j = q[d];
else if (F.getComputedStyle) {
if (d.match(/float/i)) d = "float";
d = d.replace(/([A-Z])/g, "-$1").toLowerCase();
if (a = F.getComputedStyle(a, null)) j = a.getPropertyValue(d);
if (d == "opacity" && j == "") j = "1"
} else if (a.currentStyle) {
j = d.replace(/\-(\w)/g, function (t, y) {
return y.toUpperCase()
});
j = a.currentStyle[d] || a.currentStyle[j];
if (!/^\d+(px)?$/i.test(j) && /^\d/.test(j)) {
d = q.left;
f = a.runtimeStyle.left;
a.runtimeStyle.left = a.currentStyle.left;
q.left = j || 0;
j = q.pixelLeft + "px";
q.left = d;
a.runtimeStyle.left = f
}
}
return j
},
clean: function clean (a, d, f) {
d = d || document;
if (typeof d.createElement === "undefined") d = d.ownerDocument || d[0] && d[0].ownerDocument || document;
if (!f && a.length === 1 && typeof a[0] === "string") {
var j = /^<(\w+)\s*\/?>$/.exec(a[0]);
if (j) return [d.createElement(j[1])]
}
c.each(a, function (y, A) {
if (typeof A === "number") A += "";
if (A) {
if (typeof A === "string") {
A = A.replace(/(<(\w+)[^>]*?)\/>/g, function (M, Q, S) {
return S.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? M : Q + "></" + S + ">"
});
y = A.replace(/^\s+/, "").substring(0, 10).toLowerCase();
var L = !y.indexOf("<opt") && [1, "<select multiple='multiple'>", "</select>"] || !y.indexOf("<leg") && [1, "<fieldset>", "</fieldset>"] || y.match(/^<(thead|tbody|tfoot|colg|cap)/) && [1, "<table>", "</table>"] || !y.indexOf("<tr") && [2, "<table><tbody>", "</tbody></table>"] || (!y.indexOf("<td") || !y.indexOf("<th")) && [3, "<table><tbody><tr>", "</tr></tbody></table>"] || !y.indexOf("<col") && [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"] || !c.support.htmlSerialize && [1, "div<div>", "</div>"] || [0, "", ""];
for (t.innerHTML = L[1] + A + L[2]; L[0]--;) t = t.lastChild;
if (!c.support.tbody) {
var N = /<tbody/i.test(A);
y = !y.indexOf("<table") && !N ? t.firstChild && t.firstChild.childNodes : L[1] == "<table>" && !N ? t.childNodes : [];
for (L = y.length - 1; L >= 0; --L) c.nodeName(y[L], "tbody") && !y[L].childNodes.length && y[L].parentNode.removeChild(y[L])
}!c.support.leadingWhitespace && /^\s/.test(A) && t.insertBefore(d.createTextNode(A.match(/^\s*/)[0]), t.firstChild);
A = c.makeArray(t.childNodes)
}
if (A.nodeType) q.push(A);
else q = c.merge(q, A)
}
});
if (f) {
for (a = 0; q[a]; a++) if (c.nodeName(q[a], "script") && (!q[a].type || q[a].type.toLowerCase() === "text/javascript")) j.push(q[a].parentNode ? q[a].parentNode.removeChild(q[a]) : q[a]);
else {
q[a].nodeType === 1 && q.splice.apply(q, [a + 1, 0].concat(c.makeArray(q[a].getElementsByTagName("script"))));
f.appendChild(q[a])
}
return j
}
return q
},
attr: function attr (a, d, f) {
if (!(!a || a.nodeType == 3 || a.nodeType == 8)) {
var j = !c.isXMLDoc(a),
q = f !== void 0;
d = j && c.props[d] || d;
if (a.tagName) {
var t = /href|src|style/.test(d);
if (d in a && j && !t) {
if (q) {
if (d == "type" && c.nodeName(a, "input") && a.parentNode) throw "type property can't be changed";
a[d] = f
}
if (c.nodeName(a, "form") && a.getAttributeNode(d)) return a.getAttributeNode(d).nodeValue;
if (d == "tabIndex") return (d = a.getAttributeNode("tabIndex")) && d.specified ? d.value : a.nodeName.match(/(button|input|object|select|textarea)/i) ? 0 : a.nodeName.match(/^(a|area)$/i) && a.href ? 0 : void 0;
return a[d]
}
if (!c.support.style && j && d == "style") return c.attr(a.style, "cssText", f);
q && a.setAttribute(d, "" + f);
a = !c.support.hrefNormalized && j && t ? a.getAttribute(d, 2) : a.getAttribute(d);
return a === null ? void 0 : a
}
if (!c.support.opacity && d == "opacity") {
if (q) {
a.zoom = 1;
a.filter = (a.filter || "").replace(/alpha\([^)]*\)/, "") + (parseInt(f) + "" == "NaN" ? "" : "alpha(opacity=" + f * 100 + ")")
}
return a.filter && a.filter.indexOf("opacity=") >= 0 ? parseFloat(a.filter.match(/opacity=([^)]*)/)[1]) / 100 + "" : ""
}
d = d.replace(/-([a-z])/ig, function (y, A) {
return A.toUpperCase()
});
if (q) a[d] = f;
return a[d]
}
},
makeArray: function makeArray (a) {
var d = [];
if (a != null) {
var f = a.length;
if (f == null || typeof a === "string" || c.isFunction(a) || a.setInterval) d[0] = a;
else for (; f;) d[--f] = a[f]
}
return d
},
inArray: function inArray (a, d) {
for (var f = 0, j = d.length; f < j; f++) if (d[f] === a) return f;
return -1
},
merge: function merge (a, d) {
var f = 0,
j, q = a.length;
if (c.support.getAll) for (;
(j = d[f++]) != null;) a[q++] = j;
else for (;
(j =
d[f++]) != null;) if (j.nodeType != 8) a[q++] = j;
return a
},
});
})();
</script>

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD><TITLE>Items</TITLE></HEAD>
<SCRIPT SRC="collection.js">
</SCRIPT>
<SCRIPT>
var items = new collection();
function update_display() {
var form = document.forms[0];
var items_pane = form.items;
items_pane.value = "";
items.forall(
function update_with_item(x) {
items_pane.value = items_pane.value + " " + x;
}
);
}
function add_item() {
var form = document.forms[0];
var item = form.new_item.value;
items.add(item);
update_display();
}
</SCRIPT>
<BODY>
<FORM ID="theform" METHOD = "post" NAME = "login" ACTION="javascript: add_item();">
New Item: <INPUT TYPE = "text" NAME = "new_item"/><BR>
<INPUT TYPE="submit" NAME="add_item" VALUE = "Add Item"/><BR>
<HR/>
Items: <INPUT TYPE = "textarea" NAME = "items" COLS = 40 ROWS = 10/>
</FORM>
</BODY>
</HTML>

View File

@ -0,0 +1,17 @@
<title>My Page</title>
<form name="myform" action="simple.php" method="POST">
<input type="checkbox" name="option1" value="o1"> Milk
<input type="checkbox" name="option2" value="o2" checked> Butter
<input type="checkbox" name="option3" value="o3"> Cheese
<input type="text" name="name" value="Mickey" size="20">
</form>

View File

@ -0,0 +1,19 @@
<HTML>
<TITLE>encodeURI Sanitation</TITLE>
Hi
<SCRIPT>
var pos=document.URL.indexOf("name=")+5;
var txt = document.URL.substring(pos,document.URL.length); // bad thing
encodedTxt = encodeURI(txt); // sanitizer
document.write(encodedTxt); // safe use
</SCRIPT>
<BR>
Welcome to our system
</HTML>

View File

@ -0,0 +1,29 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>SBMjs Basic24</title>
</head>
<body>
<a id ="x" href ="javascript:alert(1)"/>
<script>
var Enumerable = {
each: function(iterator, context) {
var index = 0;
iterator = iterator.bind(context);
try {
this._each(function(value) {
iterator(value, index++);
});
} catch (e) {
if (e != $break) throw e;
}
return this;
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,8 @@
<HTML>
<HEAD>
<script src="2.js"> </script>
</HEAD>
<BODY>
asdasd
</BODY>
</HTML>

View File

@ -0,0 +1,32 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>WebChess Login</title>
</head>
<body>
<h2>WebChess Login</h2>
<form method="post" action="simple.php">
<p>
Nick: <input name="txtNick" type="text" size="15" />
<br />
Password: <input name="pwdPassword" type="password" size="15" />
</p>
<p>
<input name="ToDo" value="Login" type="hidden" />
<input name="login" value="login" type="submit" />
<input name="newAccount" value="New Account" type="button" onClick="window.open('my.php', '_self')"/>
</p>
</form>
<p>Version 0.9.0, last updated September 2nd, 2004</p>
</body>
</html>

View File

@ -0,0 +1,33 @@
<HTML>
<TITLE>Welcome!</TITLE>
Hi
<SCRIPT>
var x = function _f1() {
};
function _f2(x) {
x();
}
_f2(window.x);
window.z = function _f3() {
};
function _f4(x) {
x();
}
_f4(z);
</SCRIPT>
<BR>
Welcome to our system
</HTML>

View File

@ -0,0 +1,17 @@
// $Id: drupal.js,v 1.41.2.4 2009/07/21 08:59:10 goba Exp $
var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale': {} };
/**
* Set the variable that indicates if JavaScript behaviors should be applied
*/
Drupal.jsEnabled = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById;
// Global Killswitch on the <html> element
if (Drupal.jsEnabled) {
//Do some code
}

View File

@ -0,0 +1 @@
Function.call();

View File

@ -0,0 +1,28 @@
function a() {
if (arguments.length >= 1) {
arguments[0]();
if (arguments.length >= 2) {
arguments[1]();
}
}
}
function x() {
print("x");
}
function y() {
print("y");
}
function z() {
print("z");
}
function wrong() {
print("wrong");
}
a(x);
a(y, z, wrong);

View File

@ -0,0 +1,22 @@
function f() {
for(var p in arguments)
arguments[p].g();
}
f.g = function g1() {};
var o = {
f: f,
g: function g2() { }
}
var oo = {
g: function g3() { }
}
// at the IR level, this call has three arguments: (1) the function object for f, (2) o, (3), oo
// however, only the last one ends up in the arguments array
o.f(oo);
// make g1 and g2 reachable so we can check assertions
f.g();
o.g();

View File

@ -0,0 +1,33 @@
function copyObj(to, from) {
for(var p in from) {
(function _forin_body (name) {
to[name] = from[name];
})(p);
}
}
function testForIn( x ) {
var z;
for(var y in x) {
if (y in x) {
z = (x[y])();
}
}
}
var obj = {
foo: function testForIn1() { return 7; },
bar: function testForIn2() { return "whatever"; }
}
testForIn(obj);
(function _check_obj_foo () { obj.foo(); })();
(function _check_obj_bar () { obj.bar(); })();
var copy = new Object();
copyObj(copy, obj);
(function _check_copy_foo () { copy.foo(); })();
(function _check_copy_bar () { copy.bar(); })();

View File

@ -0,0 +1,37 @@
function identity(x) {
return x;
}
function copyObj(to, from) {
for(var p in from) {
(function _forin_body (name) {
to[name] = identity(from[name]);
})(p);
}
}
function testForIn( x ) {
var z;
for(var y in x) {
if (y in x) {
z = (x[y])();
}
}
}
var obj = {
foo: function testForIn1() { return 7; },
bar: function testForIn2() { return "whatever"; }
}
testForIn(obj);
(function _check_obj_foo () { obj.foo(); })();
(function _check_obj_bar () { obj.bar(); })();
var copy = new Object();
copyObj(copy, obj);
(function _check_copy_foo () { copy.foo(); })();
(function _check_copy_bar () { copy.bar(); })();

View File

@ -0,0 +1,21 @@
function copyObjRec(to, from) {
for (var p in from) {
(function _forin_body(name) {
to[name] = from[name];
copyObjRec(to,from[name]);
})(p);
}
}
var obj = {
foo: function testForIn1() { return 7; },
bar: function testForIn2() { return "whatever"; }
}
obj.baz = obj;
var copy = new Object();
copyObjRec(copy, obj);

View File

@ -0,0 +1 @@
(p,x.f)(0);

View File

@ -0,0 +1,18 @@
Function.prototype.useCall = function f1(){
var self = this;
return function f1_inner(a, b){
self.call(this, a, b);
return this;
};
};
Function.prototype.extend = function f2(key, value){
this[key] = value;
}.useCall();
Number.extend('foobaz', function f3(min, max){
return min;
});
var r = Number.foobaz(3, 4);

View File

@ -0,0 +1,91 @@
function testSwitch( x ) {
var result = -1;
switch ( x ) {
case 3:
result = 7;
case 4:
case 5: {
result = result+3;
break;
}
case 6:
result = 2;
default:
result += 4;
}
return result;
}
function testDoWhile( x ) {
var result = 6;
do {
if (x > 100)
continue;
else if (x < 0)
break;
else
result += 1;
} while (--x > 4);
return result;
}
function testWhile( x ) {
var result = 6;
while (--x > 4) {
if (x > 100)
continue;
else if (x < 0)
break;
else
result += 1;
}
return result;
}
function testFor( x ) {
for(var result = 6; x > 4; x--) {
if (x > 100)
continue;
else if (x < 0)
break;
else
result += 1;
}
return result;
}
function testReturn( x ) {
if (x < 17)
return 8;
x++;
return x;
}
function testDeadLoop( x ) {
while (x < 17) {
return x++;
}
while (x < 17) {
if (x != 5) continue;
return x++;
}
return 0;
}
testSwitch( 7 );
testDoWhile( 5 );
testWhile( 11 );
testFor( 16 );
testReturn( 2 );
testDeadLoop( 12 );

View File

@ -0,0 +1 @@
if (1 < 2) q = 42;

View File

@ -0,0 +1,7 @@
var standalone = false;
try {
document; // ReferenceError
} catch(error) {
standalone = true;
}
assert(standalone);

View File

@ -0,0 +1,12 @@
var x;
function f() {
do {
if (f()) {
x++;
break;
}
} while (false);
}
f();

View File

@ -0,0 +1,33 @@
var left = {
inner: function left_inner(x) {
return x+1;
},
outer: function left_outer(x) {
return this.inner(x+1);
}
};
var right = {
inner: function right_inner(x) {
return Math.abs(x);
},
outer: function right_outer(x) {
return this.inner(-x);
}
};
var x = 3;
if (x > Math.random()) {
x = left;
} else {
x = right;
}
x.outer(7);

View File

@ -0,0 +1,11 @@
(function(x) {
switch(x) {
case Ext.Date:
return 1;
break;
}
return -1;
})(0);

View File

@ -0,0 +1,14 @@
function testForIn( x ) {
var z;
for(var y in x) {
if (y in x) {
z = (x[y])();
}
}
}
testForIn({
foo: function testForIn1() { return 7; },
bar: function testForIn2() { return "whatever"; }
});

View File

@ -0,0 +1,18 @@
function biz() { return this; }
var q = biz;
var o = { m: function theOne() {} }
var r = q.apply(o);
r.m()
function id(y) { return y; }
function theTwo() {}
var p = id;
var s = p.apply(null, [theTwo]);
s();
// test invoking with non-array argsList
p.apply(null, o);

View File

@ -0,0 +1,9 @@
// test use of arguments array
function useArgs() {
return arguments[2];
}
var o = {}
function theThree() {}
var a = useArgs;
var b = a.apply(o, [o,o,theThree]);
b();

View File

@ -0,0 +1,12 @@
function foo(x) { return x; }
function bar(x) { return x + 1; }
if (p > 3) {
z = foo;
} else {
z = bar;
}
z.call(null, 3);

View File

@ -0,0 +1,16 @@
function outer(outerArg) {
var local = 3;
function inner1(inner1Arg) {
outerArg = inner1Arg + 1;
};
var fun = function(inner2Arg) { return inner2Arg + outerArg; };
inner1( fun(6) );
}

View File

@ -0,0 +1,5 @@
function biz(p) { return p; }
var z = (function foo() { return this; })();
var x = z.biz(3);

View File

@ -0,0 +1,3 @@
this.f = function foo() {};
f();

View File

@ -0,0 +1,45 @@
function Polygon() {
this.edges = 8;
this.regular = false;
this.shape = function shape() { return "rectangle"; };
this.area = function area() { return -1; };
}
function objectMasquerading () {
function Rectangle(top_len,side_len) {
this.temp = Polygon;
this.temp();
this.temp = null;
this.edges = 4;
this.top = top_len;
this.side = side_len;
this.area = function area() { return this.top*this.sides; };
}
return new Rectangle(3, 5);
}
function sharedClassObject() {
function Rectangle(top_len, side_len) {
this.edges = 4;
this.top = top_len;
this.side = side_len;
this.area = function area() { return this.top*this.sides; };
}
Rectangle.prototype = new Polygon();
return new Rectangle(3, 7);
}
var rec1 = objectMasquerading();
rec1.area();
rec1.shape();
var rec2 = sharedClassObject();
rec2.area();
rec2.shape();

View File

@ -0,0 +1,5 @@
var x = {};
var y = x instanceof Object;
var z = x instanceof Function;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
x1 = "a";
x2 = "a";
x3 = "a";
x4 = "a";
x5 = "a";
x6 = "a";
x7 = "a";
x8 = "a";
x9 = "a";
x10 = "a";
x11 = "a";
x12 = "a";
x13 = "a";
x14 = "a";
x15 = "a";
x16 = "a";
x17 = "a";
x18 = "a";
x19 = "a";
x20 = "a";
x21 = "a";
x22 = "a";
x23 = "a";
x24 = "a";
x25 = "a";
x26 = "a";
function foo() {
var y = x1 +
x2 +
x3 +
x4 +
x5 +
x6 +
x7 +
x8 +
x9 +
x10 +
x11 +
x12 +
x13 +
x14 +
x15 +
x16 +
x17 +
x18 +
x19 +
x20 +
x21 +
x22 +
x23 +
x24 +
x25;
alert(y);
x26 = y;
}
new foo();

View File

@ -0,0 +1,12 @@
var o = { h: function() {} };
function f(g) {
g();
o.h(function() {
g;
});
}
function g() {}
f(g);

View File

@ -0,0 +1,23 @@
var propName = "f";
var reachable1 = function reachable1() { return 3; };
var reachable2 = function reachable2() { return 4; };
var m = function m(x,y) {
function n(a,b,p,r1,r2) {
var n_inner = function n_inner(p_inner) {
this[p_inner] = this.f1;
return this;
}
a.f1 = r1;
n_inner.call(a,p);
b.f1 = r2;
n_inner.call(b,p)
}
n(x,y,propName,reachable1,reachable2);
}
var a = {};
var b = {};
m(a,b);
var p = a[propName]();
var q = b[propName]();

View File

@ -0,0 +1,115 @@
function testSwitch( x ) {
var result = -1;
switch ( x ) {
case 3:
result = 7;
case 4:
case 5: {
result = result+3;
break;
}
case 6:
result = 2;
default:
result += 4;
}
return result;
}
function testIfConvertedSwitch( x, y ) {
var result = -1;
switch ( x ) {
case y:
result = 7;
case y+1:
case y+2: {
result = result+3;
break;
}
case y-1:
result = 2;
default:
result += 4;
}
return result;
}
function testDoWhile( x ) {
var result = 6;
do {
if (x > 100)
continue;
else if (x < 0)
break;
else
result += 1;
} while (--x > 4);
return result;
}
function testWhile( x ) {
var result = 6;
while (--x > 4) {
if (x > 100)
continue;
else if (x < 0)
break;
else
result += 1;
}
return result;
}
function testFor( x ) {
for(var result = 6; x > 4; x--) {
if (x > 100)
continue;
else if (x < 0)
break;
else
result += 1;
}
return result;
}
function testReturn( x ) {
if (x < 17)
return 8;
x++;
return x;
}
function testDeadLoop( x ) {
while (x < 17) {
return x++;
}
while (x < 17) {
if (x != 5) continue;
return x++;
}
return 0;
}
testSwitch( 7 );
testIfConvertedSwitch( 7, 3 );
testDoWhile( 5 );
testWhile( 11 );
testFor( 16 );
testReturn( 2 );
testDeadLoop( 12 );

View File

@ -0,0 +1,20 @@
function a() {
return 0;
}
var b = function bf(x) {
return x + 1;
}
function c(x) {
return x - 1;
}
var ma = a, mb = b, mc = c;
ma();
mb(7);
mc(8);

View File

@ -0,0 +1,11 @@
function f(x) {
return function ff(y) {
return function fff(z) {
return x+y+z;
}
}
}
var g1 = f(1);
var g2 = g1(2);
var g3 = g2(3);

View File

@ -0,0 +1,10 @@
function foo(x) {
function bar() {
x = function i_am_reachable() {}
}
bar();
return x;
}
var y = foo(null);
y();

View File

@ -0,0 +1,12 @@
var fun1 = new Function("a", "b", "c", "return a+b+c");
var fun2 = new Function("a, b, c", "return a+b+c");
var fun3 = new Function("a, b", "c", "return a+b+c");
var x = fun1(5, 5, 6);
var y = fun2(5, 7, 1);
var z = fun3(3, 5, 2);

View File

@ -0,0 +1,50 @@
function objects_are_fun(arg1, arg2) {
var local = new Object();
var g = 7;
local.f = arg1.foo;
local.f();
local.otherMethod = function nothing(arg1) {
return arg1 - 7;
};
local[g] = arg2[ "bar" ];
local[g]();
}
var arg1;
var arg2 = new Object();
arg1 = {
foo: function whatever() {
return 3 + 7;
}
}
arg2.bar = function other() {
return this.otherMethod( 3 );
}
arg2.otherMethod = function something(arg1) {
return arg1 + 5;
}
arg2.bar( );
objects_are_fun( arg1, arg2 );
var numObj = new Number(4);
var strObj = new String("whatever");
var foo = strObj.toLowerCase();
var whatnot = [ , , , 7, numObj, arg2, strObj ];
whatnot[ 5 ].otherMethod( 7 );
delete arg2.bar();
delete whatnot[ 5 ];
delete arg2;

View File

@ -0,0 +1,9 @@
function f() {
switch (0) {
default:
break;
}
oParsedResponse || 0;
}
f();

View File

@ -0,0 +1,389 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<!--
Possible channels of interference, explored in this document or general properties we would like the portlet markup fragment to have
1. A global variable created in HEAD
2. A global built in object (e.g. navigator)
3. (Later)Access Keys, Tab Index (who wins if there is a conflict, eg. override Alt+F)
4. Dynamically modifying the DOM, Disallowed HTML Tags
5. Direct access by traversing the DOM Tree
6. (Later)Shared prototype objects
7. (Later)Cookies (essentially a global built in object which is writeable)
8. Reference to 'this'
9. The shared namespace, shared scope (understand how the scope works)
10. Dynamically add javascript event handlers.
11. Use of 'eval', self-modifying code
12. Shared style sheets
13. Access to shared library functions, eg. parseInt()
14. Maintain general structural integrity of the document - e.g. tags should appear where they should according to the DTD
TODO:
// creating a new function using a prototype, can the new function access the local variable of the event handler which creates the new function?
// when you create a new function in different html contexts, what is the value of this?
// The parser automatically inserts HTML Elements, e.g. TBODY in the table. We have to handle that. The swing html parser doesn't recognize TBODY, though.
-->
<style>
.test{color: red;}
.odd{background-color: white;}
.even{background-color: gray;}
</style>
<script language=javascript>
<!--
//
// 1. A global value that all portlets might need to access (read/write?)
// Global variable that the portal would like the portlets to make use of
// However, this like all other system objects should be made readonly by analysis
var now=new Date,t1=0;
t1=now.getTime();
-->
</script>
<title>Example Portal Page with two Portlets</title>
</head>
<body>
<table>
<tbody>
<tr>
<td>This will maliciously be removed by a portlet if you click on the text in the gray box</td><td>That should be avoided</td>
</tr>
<tr>
<td width="40%" class=odd>
<div>
<!-- Start: Portlet 1 Markup Fragment -->
<script type="text/javascript">
<!--
// 2. Use of a system global object might be required. Such accesses should be made readonly
this.agt = navigator.userAgent.toLowerCase();
this.ie = (this.agt.indexOf("msie") != -1);
if(this.ie) {
document.write("<p>Sorry, we do not support Internet Explorer");
document.close();
} else {
document.write("<p>We applaud your taste in browsers!");
}
// The following line is erased using a style element in the malicious portlet
document.write("<p class=test>The time you started visiting this page is : " + t1 + "</p>");
-->
</script>
<h1>Plan a dinner with friends</h1><br>
<h2>Enter the names of Restaurants in order of descending preference</h2>
<form action="http://www.google.com/search" name=f onsubmit="sub(this);">
<input type=hidden name=hl value=en>
<input type=hidden name=q value="">
<script type="text/javascript">
<!--
var counter=2;
function sub(fm) {
var qstring = document.f.name1.value + " " + document.f.conf1.value + " restaurant ";
document.f.q.value = qstring;
var then = new Date;
alert("You took " + ((then.getTime()-t1)/1000) + " seconds to submit your preferences.");
return 1;
}
function createLinkElem(target, str) {
var moveElem = document.createElement("TD");
moveElem.appendChild(createLink(target, str));
return moveElem;
}
function createLink(target,str) {
var fnt = document.createElement("FONT");
fnt.setAttribute("size","-1");
fnt.appendChild(document.createTextNode(str));
var lnk = document.createElement("A");
lnk.setAttribute("href","#");
lnk.setAttribute("onclick",target);
lnk.appendChild(fnt);
return lnk;
}
function createInsertNode() {
var inElem = document.createElement("TR");
var elem = document.createElement("TD");
elem.setAttribute("colspan","6");
elem.setAttribute("align","center");
var lnk = createLink("insertRow(this);","Insert Row");
// creating an event handler by directly assigning the value of the onclick property
lnk.onclick = iRow;
elem.appendChild(lnk);
inElem.appendChild(elem);
return inElem;
}
function iRow() {
insertRow(this);
}
function mUp() {
moveUp(this);
}
function boxNode(nm, str) {
var elem = document.createElement("TD");
var inp = document.createElement("INPUT");
inp.setAttribute("maxlength","2048");
inp.setAttribute("size","55");
inp.setAttribute("name",nm);
inp.setAttribute("value","");
inp.setAttribute("title",str);
elem.appendChild(inp);
return elem;
}
function createRow(num) {
var newElem = document.createElement("TR");
var lnk = createLinkElem("moveUp(this);", "Move Up");
// creating an event handler using the addEventListener method
lnk.addEventListener('click', mUp, false);
newElem.appendChild(lnk);
var elemChild = document.createElement("TD");
elemChild.appendChild(document.createTextNode(num));
newElem.appendChild(elemChild);
newElem.appendChild(boxNode("name"+num,"Name "+num));
newElem.appendChild(boxNode("conf"+num,"Location "+num));
newElem.appendChild(createLinkElem("moveDown(this);","Move Down"));
newElem.appendChild(createLinkElem("deleteElem(this);","Delete Row"));
newElem.setAttribute("id","bar");
newElem.setAttribute("index",num);
newElem.setAttribute("rowIndex", 5);
alert(newElem.getAttribute("rowIndex"));
return newElem;
}
function insertRow(telement) {
var chld = getRow(telement);
var par = chld.parentNode;
var prev = prevRow(chld);
var numE,num;
if(prev) {
numE = prev.cells[1];
var num = numE.firstChild.nodeValue;
if(num=="Rank") {
num = 1;
} else {
num = parseInt(numE.firstChild.nodeValue) + 1;
}
} else {
num = 1;
}
par.insertBefore(createInsertNode(), chld);
par.insertBefore(createRow(num), chld);
chld = nextRow(chld);
while(chld) {
incNumber(chld, true);
chld = nextRow(chld);
}
}
function incNumber(trow, inc) {
if(trow.cells.length != 6) return;
// alert("before removing" + trow.getAttribute("id") + " = " + trow.id);
// trow.id = null;
// alert("after removing" + trow.getAttribute("id") + " = " + trow.id);
// alert("before removing" + trow.getAttribute("index") + " = " + trow.index);
// trow.index = null;
// alert("after removing" + trow.getAttribute("index") + " = " + trow.index);
alert(trow.getAttribute("rowIndex"));
var node = trow.cells[1];
var num = node.firstChild.nodeValue;
num = parseInt(num);
if(inc) {
num++;
} else {
num--;
}
trow.setAttribute("index", num);
node.firstChild.nodeValue=num+".";
node = trow.cells[2];
node = node.firstChild;
node.setAttribute("name","name"+num);
node.setAttribute("title","Name "+num);
node = trow.cells[3];
node = node.firstChild;
node.setAttribute("name","conf"+num);
node.setAttribute("title","Location "+num);
}
function prevRow(telement) {
if(!telement) {
return null;
}
var prev = telement.previousSibling;
while(prev && prev.nodeName != "TR") {
prev = prev.previousSibling;
}
return prev;
}
function nextRow(telement) {
if(!telement) {
return null;
}
var next = telement.nextSibling;
while(next && next.nodeName != "TR") {
next = next.nextSibling;
}
return next;
}
function getRow(telement) {
var chld = telement.parentNode;
while(chld.nodeName != "TR") {
chld = chld.parentNode;
}
return chld;
}
function moveUp(telement) {
var trow = getRow(telement);
var prev = prevRow(prevRow(trow));
var par = trow.parentNode;
if(prevRow(prev)) {
incNumber(trow,false);
incNumber(prev,true);
var next = nextRow(trow);
var remove = par.removeChild(trow);
par.insertBefore(remove,prev);
remove = par.removeChild(prev);
par.insertBefore(remove,next);
}
}
function moveDown(telement) {
var trow = getRow(telement);
var next = nextRow(nextRow(trow));
var par = trow.parentNode;
if(next) {
incNumber(trow,true);
incNumber(next,false);
var follo = nextRow(trow);
var remove = par.removeChild(trow);
par.insertBefore(remove,next);
remove = par.removeChild(next);
par.insertBefore(remove,follo);
}
}
function deleteElem(telement) {
var tr = getRow(telement);
follow = nextRow(tr);
var par = tr.parentNode;
var prev = prevRow(tr);
par.removeChild(prev);
par.removeChild(tr);
while(follow) {
incNumber(follow, false);
follow = nextRow(follow);
}
}
-->
</script>
<table>
<tbody>
<tr>
<td>&nbsp;</td><td align=center>Rank</td> <td align=center>Name of Restaurant</td> <td align=center>Location</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr><td colspan=6 align=center><a href="#" onclick="insertRow(this);"><font size="-1">Insert Row</font></a></td></tr>
<tr id="bar" rowIndex="5">
<td><a href="#" onclick="moveUp(this);"><font size="-1">Move Up</font></a></td>
<td>1.</td>
<td><input maxlength=2048 size=55 name="name1" value="" title="Name 1"></td>
<td><input maxlength=2048 size=55 name="conf1" value="" title="Location 1"></td>
<td><font size="-1"><a href="#" onclick="moveDown(this);">Move Down</a></font></td>
<td><font size="-1"><a href="#" onclick="deleteElem(this);">Delete Row</a></font>
</tr>
<tr><td colspan=6 align=center><a href="#" onclick="insertRow(this);"><font size="-1">Insert Row</font></a></td></tr>
</tbody>
</table>
<p><center><input type=submit value="Submit Preferences" name=btnI></center>
</form>
<!-- End: Portlet 1 Markup Fragment -->
</div>
</td>
<td width="40%" class=even>
<div>
<!-- Start Portlet 2 Markup Fragment -->
<p id="secret" onclick="malicious(this)">This portlet contains information that is top secret. Thou shalt not read it</p>
<!-- Malicious style element -->
<!--
<style>
.test{color: white;}
</style>
-->
<script type="text/javascript">
<!--
function malicious(elem) {
var par = elem.parentNode;
// Creating a disallowed tag
var base = document.createElement("BASE");
base.setAttribute("href","http://www.hacker.com/");
par.appendChild(base);
// create a table
// var tab = document.createElement("TABLE");
// var tbody = document.createElement("TBODY");
// var tr = document.createElement("TR");
var td = document.createElement("TD");
var txt = document.createTextNode("Text");
td.appendChild(txt);
// tr.appendChild(td);
// tbody.appendChild(tr);
// tab.appendChild(td);
par.appendChild(td);
// TBODY is not automatically inserted
// Accessing and messing with other parts of the tree
while(par.nodeName != "TBODY") {
par = par.parentNode;
}
// anything outside the Restricted DOM Spec should be disallowed
par.firstChild.innerHTML = "This is crazy!";
alert(par.firstChild);
par.removeChild(par.firstChild);
}
// The following line writes into a shared global variable, and should be stopped
t1 = 1000;
// Write access to system level objects should be disallowed
window.status = "Malicious Portlet";
-->
</script>
<!-- End: Portlet 2 Markup Fragment -->
</div>
</td>
</tbody>
</table>
</body>
</html>

View File

@ -0,0 +1,28 @@
function A(){
}
A.prototype.foo = function foo_of_A(){
console.log("foo_of_A");
}
function B(){
}
B.prototype.foo = function foo_of_B(){
console.log("foo_of_B");
}
function test1(){
var a = new A
console.log("calling foo_of_A");
a.foo()
}
function test2(){
var b = new B
console.log("calling foo_of_B");
b.foo()
}
test1()
test2()

View File

@ -0,0 +1,10 @@
var m = function f() {
var x = {};
function g() {
x["foo"] = {};
f();
}
g();
}
m();

View File

@ -0,0 +1,42 @@
var obj = {
repr:function(o){
if(typeof (o)=="undefined"){
return "undefined";
}else{
if(o===null){
return "null";
}
}
try{
if(typeof (o.__repr__)=="function"){
return o.__repr__();
}else{
if(typeof (o.repr)=="function"&&o.repr!=arguments.callee){
return o.repr();
}
}
return MochiKit.Base.reprRegistry.match(o);
}
catch(e){
if(typeof (o.NAME)=="string"&&(o.toString==Function.prototype.toString||o.toString==Object.prototype.toString)){
return o.NAME;
}
}
try{
var _d8=(o+"");
}
catch(e){
return "["+typeof (o)+"]";
}
if(typeof (o)=="function"){
o=_d8.replace(/^\s+/,"");
var idx=o.indexOf("{");
if(idx!=-1){
o=o.substr(0,idx)+"{...}";
}
}
return _d8;
}
};
obj.repr(obj);

View File

@ -0,0 +1,6 @@
var o = {
f: function foo() { return this; },
g: function bar() {}
}
o.f().g();

View File

@ -0,0 +1,15 @@
function A() {}
A.prototype.f = function foo() {
return this;
};
var a1 = new A(), a2 = new A();
a1.g = function bar1() {};
a2.g = function bar2() {};
var x1 = a1.f();
var x2 = a2.f();
(function test1() { x1.g(); })();
(function test2() { x2.g(); })();

View File

@ -0,0 +1,7 @@
function f(){
switch (a){
case b:
return "wow"
}
}
f();

View File

@ -0,0 +1,6 @@
function Z(dom, selector){
dom = dom || emptyArray;
dom.__proto__ = Z.prototype;
dom.selector = selector || '';
return dom;
}

View File

@ -0,0 +1,4 @@
if (window.addEventListener) {
Event.prototype = window.Event.prototype || document.createEvent('HTMLEvents').__proto__;
Object.extend(Event.prototype, methods);
}

View File

@ -0,0 +1,10 @@
function f() {
switch (0) {
default:
break;
}
oParsedResponse || 0;
}
f();

View File

@ -0,0 +1,13 @@
function foo() {
function baz() {
return function f1() {};
}
function boo() {
baz = function biz() { return function i_am_reachable() {}; }
}
boo();
return baz();
}
var x = foo();
x();

View File

@ -0,0 +1,114 @@
function outer( x ) {
x++;
var z = x;
function inner( y ) {
x += y;
z += 1
x++
};
var innerName = inner;
function inner2( y ) {
if (y < 3) innerName = inner3;
innerName( y );
}
function inner3( y ) {
for(x = 0; x < 10; x++) {
y++;
}
}
inner2( x );
inner( 7 );
inner3( 2 );
(function indirect( f, x ) { f(x); })( innerName, 6 );
function level1() {
function level5() {
x++;
return x;
}
function level4() {
return level5();
}
function level3() {
if (x == 3) {
level4();
}
return x;
}
function level2() {
if (x > 2) {
level3();
return x;
} else {
return 7;
}
}
x++;
if (x < 7) {
level2();
}
return x;
}
level1();
return x+z;
}
function c2() {
}
function c3() {
}
function fa2(x) {
x();
}
function fa3(x) {
x();
}
function aa() {
var c1 = function _c1() {
}
var fa = function _fa1(x) {
x();
}
function bb(x) {
fa = x;
}
fa(c1);
bb(fa2);
fa(c2);
bb(fa3);
fa(c3);
}
var result = outer( 5 );
aa();

View File

@ -0,0 +1,96 @@
function trivial(one, two) {
var local = two + 7;
if (local > 5)
return one;
else {
return function inc(i) { return i + 1; } ( two );
}
}
function silly(one, two) {
var local = two + 7;
var result;
if (local > Math.E)
result = --two;
else {
result = 5;
result = result<<1;
}
return result;
}
var weird = function weirder ( one ) {
var result = Math.abs( one );
var i;
for(i = 0; i < 7; i++) {
if ( ! ( (one + i) < 5 ) ) {
result = (6, result / i);
}
}
return result;
}
var strange = function stranger ( one ) {
var result = ~one;
result /= 7;
var i = 0;
do {
if ( (one * i) < -5 ) {
result = result % i;
}
} while (++i <= 7);
return result;
}
var fun = function fib(x) {
return (x < 2)? 1: (fib(x-1) + fib(x-2));
}
function bad(one, two) {
var local = one + 7;
var result;
switch (local) {
case 1:
case 2:
case 3:
case 4:
result = +5;
result = result>>>2;
break;
case 5:
case 6:
case 7:
result = two>>1;
break;
default:
result =-1;
}
return result;
}
function rubbish(one, two) {
if (one(5))
return one( 3 );
else
return rubbish(two, one);
}
if (1 < 2) q = 42;
rubbish(strange, weird);
var F;
if ( bad(2, 3) )
F = fun;
else
F = strange;
trivial(3, 2);
if ( F(6) !== 0 )
bad(4, 5);
else
weird( silly( "whatever", 7 ) );

View File

@ -0,0 +1,87 @@
function trivial(one, two) {
var local = two + 7;
if (local > 5)
return one;
else {
return two;
}
}
function silly(one, two) {
var local = two + 7;
var result = 0;
if (local > Math.E)
result = --two;
else {
result = 5;
result = result<<1;
}
return result;
}
function weirder ( one ) {
var result = Math.abs( one );
for(var i = 0; i < 7; i++) {
if ( ! ( (one + i) < 5 ) ) {
result = (6, result / i);
} else {
result = 7;
}
}
return result;
}
function stranger ( one ) {
var result = ~one;
result /= 7;
var i = 0;
do {
if ( (one * i) < -5 ) {
result = result % i;
} else {
result = 4;
}
} while (++i <= 7);
return result;
}
function fib(x) {
return (x < 2)? 1: (fib(x-1) + fib(x-2));
}
function bad(one, two) {
var local = one + 7;
var result = 0;
switch (local) {
case 1:
case 2:
case 3:
case 4:
result = +5;
result = result>>>2;
break;
case 5:
case 6:
case 7:
result = two>>1;
break;
default:
result =-1;
}
return result;
}
function rubbish(one, two) {
if (one(5))
return one( 3 );
else
return rubbish(two, one);
}
rubbish(stranger, weirder);
trivial(3, 2);
bad(4, 5);
weirder( silly( "whatever", 7 ) );

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
function getOp(x, op) {
return x[ "operator" + op ];
}
function plusNum(y) {
return this.val + y;
}
var obj = { val: 7, operatorPlus: plusNum };
var result = ( getOp(obj, "Plus") )( 6 );

View File

@ -0,0 +1,9 @@
var stuff = new String("this is a string of words");
var words = stuff.split(" ");
var firstWord = words[0];
var firstWordUpper = firstWord.toUpperCase();

View File

@ -0,0 +1,76 @@
function targetOne( x ) {
return x;
}
function targetTwo( x ) {
throw x;
}
function tryCatch( x, targetOne, targetTwo ) {
try {
if (x.one < 7)
targetOne( x );
else
targetTwo( x );
} catch (e) {
e.two();
}
}
function tryFinally( x, targetOne, targetTwo ) {
try {
if (x.one < 7)
return targetOne( x );
else
targetTwo( x );
} finally {
x.two();
}
x.three();
}
function tryFinallyLoop( x, targetTwo ) {
while (x.one < 7) {
try {
if (x.one < 3)
break;
else
targetTwo( x );
} finally {
x.two();
}
}
}
function tryCatchFinally( x, targetOne, targetTwo ) {
try {
if (x.one < 7)
targetOne( x );
else
targetTwo( x );
} catch (e) {
e.two();
} finally {
x.three();
}
}
o = {
one: -12,
two: function two () {
return this;
},
three: function three () {
return 8;
}
};
tryCatch(o, targetOne, targetTwo);
tryFinally(o, targetOne, targetTwo);
tryFinallyLoop(o, targetTwo);
tryCatchFinally(o, targetOne, targetTwo);

View File

@ -0,0 +1,17 @@
function Obj(x) {
var state = x;
this.set = function setit(x) { state = x; };
this.get = function getit() { return state; };
};
var obj = new Obj( function tester1() { return 3; } );
var test1 = ( obj.get() )();
obj.set( function tester2() { return 7; } );
var test2 = ( obj.get() )();

View File

@ -0,0 +1,8 @@
function im_with_stupid(stupid, x) {
with (stupid) {
return x+3;
}
}
var foo = new Object();
var bar = im_with_stupid(foo, 7);

View File

@ -0,0 +1,15 @@
Function.prototype.wrap = function f_wrap(){
var self = this;
return function wrapper(x, y, z){
return self(x, y, z);
};
};
var extend = function f_extend(thi$, key, value){
thi$[key] = value;
}.wrap();
extend(Number, 'g', function i_am_reachable(x){ return x+19; });
Number.g(23);

View File

@ -0,0 +1,15 @@
Function.prototype.wrap = function f_wrap(){
var self = this;
return function wrapper(x, y, z){
return (function wrapper_inner() { self(x, y, z); })();
};
};
var extend = function f_extend(thi$, key, value){
thi$[key] = value;
}.wrap();
extend(Number, 'g', function i_am_reachable(x){ return x+19; });
Number.g(23);

View File

@ -0,0 +1,24 @@
function f_wrap() {
var y = null;
return function wrapper() {
return { set: function set(p) {
y = p;
}, get: function get() {
return y;
}
};
}
}
var w = f_wrap();
var x = w();
var s = function i_am_reachable() {};
x.set(s);
var t = x.get();
t();

View File

@ -1,85 +0,0 @@
/******************************************************************************
* Copyright (c) 2002 - 2006 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*****************************************************************************/
package com.ibm.wala.cast.js.test;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
/**
* The main plugin class to be used in the desktop.
*/
public class JavaScriptTestPlugin extends Plugin {
//The shared instance.
private static JavaScriptTestPlugin plugin;
//Resource bundle.
private ResourceBundle resourceBundle;
/**
* The constructor.
*/
public JavaScriptTestPlugin() {
super();
plugin = this;
}
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception {
super.start(context);
}
/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception {
super.stop(context);
plugin = null;
resourceBundle = null;
}
/**
* Returns the shared instance.
*/
public static JavaScriptTestPlugin getDefault() {
return plugin;
}
/**
* Returns the string from the plugin's resource bundle,
* or 'key' if not found.
*/
public static String getResourceString(String key) {
ResourceBundle bundle = JavaScriptTestPlugin.getDefault().getResourceBundle();
try {
return (bundle != null) ? bundle.getString(key) : key;
} catch (MissingResourceException e) {
return key;
}
}
/**
* Returns the plugin's resource bundle,
*/
public ResourceBundle getResourceBundle() {
try {
if (resourceBundle == null)
resourceBundle = ResourceBundle.getBundle("com.ibm.domo.js.test.JavaScriptTestPluginResources");
} catch (MissingResourceException x) {
resourceBundle = null;
}
return resourceBundle;
}
}

View File

@ -136,4 +136,7 @@ public class CAstAnalysisScope extends AnalysisScope {
return 1;
}
public String toString() {
return super.toString() + "\n" + theLoader + ": " + getModules(theLoader);
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="source"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.wala.ide.jdt</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

Some files were not shown because too many files have changed in this diff Show More