/* * Transfer functions */ public static Value evaluate( DOMObjects nativeObject, FunctionCalls.CallInfo call, State s, Solver.SolverInterface c) { switch (nativeObject) { case ACTIVE_X_OBJECT_OPEN: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 5); /* Value method =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value url =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeUndef(); } case ACTIVE_X_OBJECT_SET_REQUEST_HEADER: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value header =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value value =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeUndef(); } case ACTIVE_X_OBJECT_SEND: { NativeFunctions.expectParameters(nativeObject, call, c, 0, 1); return Value.makeUndef(); } case ACTIVE_X_OBJECT_ABORT: { NativeFunctions.expectParameters(nativeObject, call, c, 0, 0); return Value.makeUndef(); } case ACTIVE_X_OBJECT_GET_RESPONSE_HEADER: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value header =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeAnyStr(); } case ACTIVE_X_OBJECT_GET_ALL_RESPONSE_HEADERS: { NativeFunctions.expectParameters(nativeObject, call, c, 0, 0); return Value.makeAnyStr(); } case ACTIVE_X_OBJECT_CONSTRUCTOR: { // TODO: Check if this is sound. return Value.makeObject(INSTANCES).joinUndef(); } default: { throw new AnalysisException("Unknown Native Object: " + nativeObject); } } }
public static void build(Solver.SolverInterface c) { State s = c.getState(); PropVarOperations pv = c.getAnalysis().getPropVarOperations(); CONSTRUCTOR = new ObjectLabel(DOMObjects.HTMLHRELEMENT_CONSTRUCTOR, ObjectLabel.Kind.FUNCTION); PROTOTYPE = new ObjectLabel(DOMObjects.HTMLHRELEMENT_PROTOTYPE, ObjectLabel.Kind.OBJECT); INSTANCES = new ObjectLabel(DOMObjects.HTMLHRELEMENT_INSTANCES, ObjectLabel.Kind.OBJECT); // Constructor Object s.newObject(CONSTRUCTOR); pv.writePropertyWithAttributes( CONSTRUCTOR, "length", Value.makeNum(0).setAttributes(true, true, true)); pv.writePropertyWithAttributes( CONSTRUCTOR, "prototype", Value.makeObject(PROTOTYPE).setAttributes(true, true, true)); s.writeInternalPrototype(CONSTRUCTOR, Value.makeObject(InitialStateBuilder.FUNCTION_PROTOTYPE)); pv.writeProperty(DOMWindow.WINDOW, "HTMLHRElement", Value.makeObject(CONSTRUCTOR)); // Prototype Object s.newObject(PROTOTYPE); s.writeInternalPrototype(PROTOTYPE, Value.makeObject(HTMLElement.ELEMENT_PROTOTYPE)); // Multiplied Object s.newObject(INSTANCES); s.writeInternalPrototype(INSTANCES, Value.makeObject(PROTOTYPE)); /* * Properties. */ // DOM Level 1 createDOMProperty(INSTANCES, "align", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "noShade", Value.makeAnyBool(), c); createDOMProperty(INSTANCES, "size", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "width", Value.makeAnyStr(), c); s.multiplyObject(INSTANCES); INSTANCES = INSTANCES.makeSingleton().makeSummary(); /* * Functions. */ // No functions. }
public static void build(State s) { CONSTRUCTOR = new ObjectLabel(DOMObjects.HTMLBASEELEMENT_CONSTRUCTOR, ObjectLabel.Kind.FUNCTION); PROTOTYPE = new ObjectLabel(DOMObjects.HTMLBASEELEMENT_PROTOTYPE, ObjectLabel.Kind.OBJECT); INSTANCES = new ObjectLabel(DOMObjects.HTMLBASEELEMENT_INSTANCES, ObjectLabel.Kind.OBJECT); // Constructor Object s.newObject(CONSTRUCTOR); s.writePropertyWithAttributes( CONSTRUCTOR, "length", Value.makeNum(0).setAttributes(true, true, true)); s.writePropertyWithAttributes( CONSTRUCTOR, "prototype", Value.makeObject(PROTOTYPE).setAttributes(true, true, true)); s.writeInternalPrototype(CONSTRUCTOR, Value.makeObject(InitialStateBuilder.OBJECT_PROTOTYPE)); s.writeProperty(DOMWindow.WINDOW, "HTMLBaseElement", Value.makeObject(CONSTRUCTOR)); // Prototype Object s.newObject(PROTOTYPE); s.writeInternalPrototype(PROTOTYPE, Value.makeObject(HTMLElement.ELEMENT_PROTOTYPE)); // Multiplied Object s.newObject(INSTANCES); s.writeInternalPrototype(INSTANCES, Value.makeObject(PROTOTYPE)); /* * Properties. */ // DOM LEVEL 1 createDOMProperty(s, INSTANCES, "href", Value.makeAnyStr()); createDOMProperty(s, INSTANCES, "target", Value.makeAnyStr()); s.multiplyObject(INSTANCES); INSTANCES = INSTANCES.makeSingleton().makeSummary(); /* * Functions. */ // No functions. }
public static void build(Solver.SolverInterface c) { State s = c.getState(); PropVarOperations pv = c.getAnalysis().getPropVarOperations(); CONSTRUCTOR = new ObjectLabel(DOMObjects.HTMLOBJECTELEMENT_CONSTRUCTOR, ObjectLabel.Kind.FUNCTION); PROTOTYPE = new ObjectLabel(DOMObjects.HTMLOBJECTELEMENT_PROTOTYPE, ObjectLabel.Kind.OBJECT); INSTANCES = new ObjectLabel(DOMObjects.HTMLOBJECTELEMENT_INSTANCES, ObjectLabel.Kind.OBJECT); // Constructor Object s.newObject(CONSTRUCTOR); pv.writePropertyWithAttributes( CONSTRUCTOR, "length", Value.makeNum(0).setAttributes(true, true, true)); pv.writePropertyWithAttributes( CONSTRUCTOR, "prototype", Value.makeObject(PROTOTYPE).setAttributes(true, true, true)); s.writeInternalPrototype(CONSTRUCTOR, Value.makeObject(InitialStateBuilder.FUNCTION_PROTOTYPE)); pv.writeProperty(DOMWindow.WINDOW, "HTMLObjectElement", Value.makeObject(CONSTRUCTOR)); // Prototype Object s.newObject(PROTOTYPE); s.writeInternalPrototype(PROTOTYPE, Value.makeObject(HTMLElement.ELEMENT_PROTOTYPE)); // Multiplied Object s.newObject(INSTANCES); s.writeInternalPrototype(INSTANCES, Value.makeObject(PROTOTYPE)); /* * Properties. */ // DOM Level 1 createDOMProperty( INSTANCES, "form", Value.makeObject(HTMLFormElement.INSTANCES).setReadOnly(), c); createDOMProperty(INSTANCES, "code", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "align", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "archive", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "border", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "codeBase", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "codeType", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "data", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "declare", Value.makeAnyBool(), c); createDOMProperty(INSTANCES, "height", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "hspace", Value.makeAnyNum(), c); createDOMProperty(INSTANCES, "name", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "standby", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "tabIndex", Value.makeAnyNum(), c); createDOMProperty( INSTANCES, "type", Value.makeAnyStr().restrictToNotStrIdentifierParts() /* mime-type */, c); createDOMProperty(INSTANCES, "useMap", Value.makeAnyStr(), c); createDOMProperty(INSTANCES, "vspace", Value.makeAnyNum(), c); createDOMProperty(INSTANCES, "width", Value.makeAnyStr(), c); // DOM Level 2 createDOMProperty( INSTANCES, "contentDocument", Value.makeObject(DOMDocument.INSTANCES).setReadOnly(), c); s.multiplyObject(INSTANCES); INSTANCES = INSTANCES.makeSingleton().makeSummary(); /* * Functions. */ // No functions. }
public static void build(Solver.SolverInterface c) { State s = c.getState(); PropVarOperations pv = c.getAnalysis().getPropVarOperations(); CONSTRUCTOR = new ObjectLabel(DOMObjects.ELEMENT_CONSTRUCTOR, ObjectLabel.Kind.FUNCTION); PROTOTYPE = new ObjectLabel(DOMObjects.ELEMENT_PROTOTYPE, ObjectLabel.Kind.OBJECT); INSTANCES = new ObjectLabel(DOMObjects.ELEMENT_INSTANCES, ObjectLabel.Kind.OBJECT); // Constructor Object s.newObject(CONSTRUCTOR); pv.writePropertyWithAttributes( CONSTRUCTOR, "length", Value.makeNum(0).setAttributes(true, true, true)); pv.writePropertyWithAttributes( CONSTRUCTOR, "prototype", Value.makeObject(PROTOTYPE).setAttributes(true, true, true)); s.writeInternalPrototype(CONSTRUCTOR, Value.makeObject(InitialStateBuilder.OBJECT_PROTOTYPE)); pv.writeProperty(DOMWindow.WINDOW, "Element", Value.makeObject(CONSTRUCTOR)); // Prototype s.newObject(PROTOTYPE); s.writeInternalPrototype(PROTOTYPE, Value.makeObject(DOMNode.PROTOTYPE)); // Multiplied object s.newObject(INSTANCES); s.writeInternalPrototype(INSTANCES, Value.makeObject(PROTOTYPE)); /* * Properties. */ // DOM Level 1 createDOMProperty(INSTANCES, "tagName", Value.makeAnyStr(), c); s.multiplyObject(INSTANCES); INSTANCES = INSTANCES.makeSingleton().makeSummary(); /* * Functions. */ // Unknown createDOMFunction( PROTOTYPE, DOMObjects.ELEMENT_GET_BOUNDING_CLIENT_RECT, "getBoundingClientRect", 0, c); // DOM Level 1 createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_GET_ATTRIBUTE, "getAttribute", 1, c); createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_SET_ATTRIBUTE, "setAttribute", 2, c); createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_REMOVE_ATTRIBUTE, "removeAttribute", 1, c); createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_GET_ATTRIBUTE_NODE, "getAttributeNode", 1, c); createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_SET_ATTRIBUTE_NODE, "setAttributeNode", 2, c); createDOMFunction( PROTOTYPE, DOMObjects.ELEMENT_REMOVE_ATTRIBUTE_NODE, "removeAttributeNode", 1, c); createDOMFunction( PROTOTYPE, DOMObjects.ELEMENT_GET_ELEMENTS_BY_TAGNAME, "getElementsByTagName", 1, c); // DOM Level 2 createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_GET_ATTRIBUTE_NS, "getAttributeNS", 2, c); createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_SET_ATTRIBUTE_NS, "setAttributeNS", 3, c); createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_REMOVE_ATTRIBUTE_NS, "removeAttributeNS", 2, c); createDOMFunction( PROTOTYPE, DOMObjects.ELEMENT_GET_ATTRIBUTE_NODE_NS, "getAttributeNodeNS", 2, c); createDOMFunction( PROTOTYPE, DOMObjects.ELEMENT_SET_ATTRIBUTE_NODE_NS, "setAttributeNodeNS", 3, c); createDOMFunction( PROTOTYPE, DOMObjects.ELEMENT_GET_ELEMENTS_BY_TAGNAME_NS, "getElementsByTagNameNS", 2, c); createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_HAS_ATTRIBUTE, "hasAttribute", 1, c); createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_HAS_ATTRIBUTE_NS, "hasAttributeNS", 2, c); // DOM Level 3 createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_SET_ID_ATTRIBUTE, "setIdAttribute", 2, c); createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_SET_ID_ATTRIBUTE_NS, "setIdAttributeNS", 3, c); createDOMFunction( PROTOTYPE, DOMObjects.ELEMENT_SET_ID_ATTRIBUTE_NODE, "setIdAttributeNode", 2, c); // DOM Level 2 createDOMProperty( DOMAttr.INSTANCES, "ownerElement", Value.makeObject(INSTANCES).setReadOnly(), c); // semistandard createDOMFunction(PROTOTYPE, DOMObjects.ELEMENT_QUERY_SELECTOR_ALL, "querySelectorAll", 1, c); }
/** Transfer Functions. */ public static Value evaluate(DOMObjects nativeObject, CallInfo call, Solver.SolverInterface c) { State s = c.getState(); switch (nativeObject) { case ELEMENT_GET_ATTRIBUTE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeAnyStr(); } case ELEMENT_SET_ATTRIBUTE: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value value =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeUndef(); } case ELEMENT_REMOVE_ATTRIBUTE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeUndef(); } case ELEMENT_GET_ATTRIBUTE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value namespace =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeAnyStr(); } case ELEMENT_GET_ATTRIBUTE_NODE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeObject(DOMAttr.INSTANCES); } case ELEMENT_GET_ATTRIBUTE_NODE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value namespace =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeObject(DOMAttr.INSTANCES); } case ELEMENT_GET_BOUNDING_CLIENT_RECT: { NativeFunctions.expectParameters(nativeObject, call, c, 0, 0); return Value.makeObject(ClientBoundingRect.INSTANCES); } case ELEMENT_GET_ELEMENTS_BY_TAGNAME: { // TODO: needs precision, but cannot do like document.getElementsByTagName() bc. State is // for everything NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeObject(DOMNodeList.INSTANCES); } case ELEMENT_GET_ELEMENTS_BY_TAGNAME_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value namespace =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeObject(DOMNodeList.INSTANCES); } case ELEMENT_HAS_ATTRIBUTE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeAnyBool(); } case ELEMENT_HAS_ATTRIBUTE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value namespace =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeAnyBool(); } case ELEMENT_REMOVE_ATTRIBUTE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value namespaceURI =*/ Conversion.toString( NativeFunctions.readParameter(call, s, 0), c); /* Value localName =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeUndef(); } case ELEMENT_REMOVE_ATTRIBUTE_NODE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); return DOMConversion.toAttr(NativeFunctions.readParameter(call, s, 0), c); } case ELEMENT_SET_ATTRIBUTE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 3, 3); /* Value namespace =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c) .joinNull(); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); /* Value value =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 2), c); return Value.makeUndef(); } case ELEMENT_SET_ATTRIBUTE_NODE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value newAttr =*/ DOMConversion.toAttr(NativeFunctions.readParameter(call, s, 0), c); return Value.makeObject(DOMAttr.INSTANCES).joinNull(); } case ELEMENT_SET_ATTRIBUTE_NODE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value newAttr =*/ DOMConversion.toAttr(NativeFunctions.readParameter(call, s, 0), c); return Value.makeObject(DOMAttr.INSTANCES).joinNull(); } case ELEMENT_SET_ID_ATTRIBUTE: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value isId =*/ Conversion.toBoolean(NativeFunctions.readParameter(call, s, 1)); return Value.makeUndef(); } case ELEMENT_SET_ID_ATTRIBUTE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 3, 3); /* Value namespaceURI =*/ Conversion.toString( NativeFunctions.readParameter(call, s, 0), c); /* Value localName =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); /* Value isId =*/ Conversion.toBoolean(NativeFunctions.readParameter(call, s, 2)); return Value.makeUndef(); } case ELEMENT_SET_ID_ATTRIBUTE_NODE: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value idAttr =*/ DOMConversion.toAttr(NativeFunctions.readParameter(call, s, 0), c); /* Value isId =*/ Conversion.toBoolean(NativeFunctions.readParameter(call, s, 1)); return Value.makeUndef(); } case ELEMENT_QUERY_SELECTOR_ALL: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); return Value.makeObject(DOMNodeList.INSTANCES); } default: { throw new AnalysisException("Unknown Native Object: " + nativeObject); } } }
public static void build(State s) { CONSTRUCTOR = new ObjectLabel(DOMObjects.ACTIVE_X_OBJECT_CONSTRUCTOR, ObjectLabel.Kind.FUNCTION); PROTOTYPE = new ObjectLabel(DOMObjects.ACTIVE_X_OBJECT_PROTOTYPE, ObjectLabel.Kind.OBJECT); INSTANCES = new ObjectLabel(DOMObjects.ACTIVE_X_OBJECT_INSTANCES, ObjectLabel.Kind.OBJECT); // Constructor Object s.newObject(CONSTRUCTOR); s.writePropertyWithAttributes( CONSTRUCTOR, "length", Value.makeNum(0).setAttributes(true, true, true)); s.writePropertyWithAttributes( CONSTRUCTOR, "prototype", Value.makeObject(PROTOTYPE).setAttributes(true, true, true)); s.writeInternalPrototype(CONSTRUCTOR, Value.makeObject(InitialStateBuilder.OBJECT_PROTOTYPE)); // TODO modelling choice: ActiveXObject is IE only.. // s.writeProperty(DOMWindow.WINDOW, "ActiveXObject", Value.makeObject(CONSTRUCTOR)); // Prototype object s.newObject(PROTOTYPE); s.writeInternalPrototype(PROTOTYPE, Value.makeObject(InitialStateBuilder.OBJECT_PROTOTYPE)); // Multiplied object s.newObject(INSTANCES); s.writeInternalPrototype(INSTANCES, Value.makeObject(PROTOTYPE)); /* * Constants. */ createDOMProperty(s, PROTOTYPE, "UNSENT", Value.makeNum(0)); createDOMProperty(s, PROTOTYPE, "OPENED", Value.makeNum(1)); createDOMProperty(s, PROTOTYPE, "HEADERS_RECEIVED", Value.makeNum(2)); createDOMProperty(s, PROTOTYPE, "LOADING", Value.makeNum(3)); createDOMProperty(s, PROTOTYPE, "DONE", Value.makeNum(4)); /* * Properties. */ createDOMProperty(s, INSTANCES, "readyState", Value.makeAnyNumUInt().setReadOnly()); createDOMProperty(s, INSTANCES, "status", Value.makeAnyNumUInt().setReadOnly()); createDOMProperty(s, INSTANCES, "statusText", Value.makeAnyStr().setReadOnly()); if (Options.get().isReturnJSON()) { createDOMProperty(s, INSTANCES, "responseText", Value.makeJSONStr()); } else { createDOMProperty(s, INSTANCES, "responseText", Value.makeAnyStr()); } // TODO createDOMProperty(s, INSTANCES, "responseXML", // Value.makeObject(DOMDocument.DOCUMENT).setReadOnly(), DOMSpec.LEVEL_2); /* * Functions. */ createDOMFunction(s, PROTOTYPE, DOMObjects.ACTIVE_X_OBJECT_OPEN, "open", 5); createDOMFunction(s, PROTOTYPE, DOMObjects.ACTIVE_X_OBJECT_SEND, "send", 1); createDOMFunction( s, PROTOTYPE, DOMObjects.ACTIVE_X_OBJECT_SET_REQUEST_HEADER, "setRequestHeader", 2); createDOMFunction(s, PROTOTYPE, DOMObjects.ACTIVE_X_OBJECT_ABORT, "abort", 0); createDOMFunction( s, PROTOTYPE, DOMObjects.ACTIVE_X_OBJECT_GET_RESPONSE_HEADER, "getResponseHeader", 1); createDOMFunction( s, PROTOTYPE, DOMObjects.ACTIVE_X_OBJECT_GET_ALL_RESPONSE_HEADERS, "getAllResponseHeaders", 0); // Multiply object s.multiplyObject(INSTANCES); INSTANCES = INSTANCES.makeSingleton().makeSummary(); }