Refine search
return; String status = result.get("status", result).toString(); switch (status) { case "ok": break; case "exception": { String className = String.valueOf(result.get("className", result)); if (debugInformation != null) { String decodedName = debugInformation.getClassNameByJsName(className); String message = String.valueOf(result.get("message", result)); String stack = result.get("stack", result).toString(); StackTraceElement[] decodedStack = null; if (debugInformation != null) {
public void put(String id, Scriptable start, Object value) { if (start == this) start = prototype; prototype.put(id, start, value); }
/** * @see net.sourceforge.htmlunit.corejs.javascript.Scriptable#getIds */ public Object[] getIds() { return obj.getIds(); } /**
private static Scriptable getBase(Scriptable obj, String name) { do { if (obj.has(name, obj)) break; obj = obj.getPrototype(); } while(obj != null); return obj; }
private boolean isRecursiveAttribute(final String name) { for (Scriptable object = getDomNodeOrDie().getScriptObject(); object != null; object = object.getPrototype()) { for (final Object id : object.getIds()) { if (name.equals(Context.toString(id))) { return true; } } } return false; }
/** * {@inheritDoc} */ @Override public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { final Object object = super.call(cx, scope, thisObj, args); if (object instanceof Scriptable) { final Scriptable result = (Scriptable) object; if (result.getPrototype() == null) { final Scriptable proto = getClassPrototype(); if (result != proto) { result.setPrototype(proto); } } if (result.getParentScope() == null) { final Scriptable parent = getParentScope(); if (result != parent) { result.setParentScope(parent); } } } return object; } }
@Override public void put(final String name, final Scriptable start, final Object value) { if (this != start) { super.put(name, start, value); return; } final Scriptable prototype = getPrototype(); if (prototype != null && !"constructor".equals(name) && prototype.get(name, start) != Scriptable.NOT_FOUND) { prototype.put(name, start, value); return; } if (getDomNodeOrNull() != null) { // check if prototype or not final Definition style = StyleAttributes.getDefinition(name, getBrowserVersion()); if (style != null) { final String stringValue = Context.toString(value); setStyleAttribute(style.getAttributeName(), stringValue); return; } } super.put(name, start, value); }
public static Object nameIncrDecr(Scriptable scopeChain, String id, Context cx, int incrDecrMask) { Scriptable target; Object value; search: { do { if (cx.useDynamicScope && scopeChain.getParentScope() == null) { scopeChain = checkDynamicScope(cx.topCallScope, scopeChain); } target = scopeChain; do { value = target.get(id, scopeChain); if (value != Scriptable.NOT_FOUND) { break search; } target = target.getPrototype(); } while (target != null); scopeChain = scopeChain.getParentScope(); } while (scopeChain != null); throw notFoundError(scopeChain, id); } return doScriptableIncrDecr(target, id, scopeChain, value, incrDecrMask); }
/** * Returns the current document instance, using <tt>thisObj</tt> as a hint. * @param thisObj a hint as to the current document (may be the prototype when function is used without "this") * @return the current document instance */ private static HTMLDocument getDocument(final Scriptable thisObj) { // if function is used "detached", then thisObj is the top scope (ie Window), not the real object // cf unit test DocumentTest#testDocumentWrite_AssignedToVar // may be the prototype too // cf DocumentTest#testDocumentWrite_AssignedToVar2 if (thisObj instanceof HTMLDocument && thisObj.getPrototype() instanceof HTMLDocument) { return (HTMLDocument) thisObj; } if (thisObj instanceof DocumentProxy && thisObj.getPrototype() instanceof HTMLDocument) { return (HTMLDocument) ((DocumentProxy) thisObj).getDelegee(); } final Window window = getWindow(thisObj); if (window.getBrowserVersion().hasFeature(HTMLDOCUMENT_FUNCTION_DETACHED)) { return (HTMLDocument) window.getDocument(); } throw Context.reportRuntimeError("Function can't be used detached from document"); }
ids = ((DebuggableObject)scriptable).getAllIds(); } else { ids = scriptable.getIds(); Scriptable proto = scriptable.getPrototype(); Scriptable parent = scriptable.getParentScope(); int extra = 0; if (proto != null) {
/** * {@inheritDoc} */ @Override public Object[] getIds() { final Set<Object> objects = new LinkedHashSet<>(); for (final Object o : super.getIds()) { objects.add(o); } for (Class<?> c = getMethodOrConstructor().getDeclaringClass().getSuperclass(); c != null; c = c.getSuperclass()) { final Object scripatble = getParentScope().get(c.getSimpleName(), this); if (scripatble instanceof Scriptable) { for (Object id : ((Scriptable) scripatble).getIds()) { objects.add(id); } } } return objects.toArray(new Object[objects.size()]); }
private int getRecursiveAttributesLength() { int length = 0; for (Scriptable object = getDomNodeOrDie().getScriptObject(); object != null; object = object.getPrototype()) { length += object.getIds().length; } return length; }
Modifier.isStatic(method.getModifiers())) Object args[] = { Context.getContext(), scope, sealed ? Boolean.TRUE : Boolean.FALSE }; method.invoke(null, args); throw Context.reportRuntimeError1( "msg.zero.arg.ctor", clazz.getName()); String className = proto.getClassName(); superProto = ScriptableObject.getObjectPrototype(scope); proto.setPrototype(superProto); throw Context.reportRuntimeError1( "msg.ctor.multiple.parms", clazz.getName());
/** * @see net.sourceforge.htmlunit.corejs.javascript.Scriptable#getParentScope */ public Scriptable getParentScope() { return obj.getParentScope(); } /**
/** * {@inheritDoc} */ @Override public boolean has(final String name, final Scriptable start) { if (super.has(name, start)) { return true; } for (Class<?> c = getMethodOrConstructor().getDeclaringClass().getSuperclass(); c != null; c = c.getSuperclass()) { final Object scripatble = getParentScope().get(c.getSimpleName(), this); if (scripatble instanceof Scriptable && ((Scriptable) scripatble).has(name, start)) { return true; } } return false; }
@Override public Object get(Context cx) { switch (type) { case SPECIAL_NONE: return ScriptRuntime.getObjectProp(target, name, cx); case SPECIAL_PROTO: return target.getPrototype(); case SPECIAL_PARENT: return target.getParentScope(); default: throw Kit.codeBug(); } }
/** * Return new {@link Scriptable} instance using the default * constructor for the class of the underlying Java method. * Return null to indicate that the call method should be used to create * new objects. */ @Override public Scriptable createObject(Context cx, Scriptable scope) { if (member.isCtor() || parmsLength == VARARGS_CTOR) { return null; } Scriptable result; try { result = (Scriptable) member.getDeclaringClass().newInstance(); } catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); } result.setPrototype(getClassPrototype()); result.setParentScope(getParentScope()); return result; }
private Scriptable js_getClass(Context cx, Scriptable scope, Object[] args) { if (args.length > 0 && args[0] instanceof Wrapper) { Scriptable result = this; Class<?> cl = ((Wrapper) args[0]).unwrap().getClass(); // Evaluate the class name by getting successive properties of // the string to find the appropriate NativeJavaClass object String name = cl.getName(); int offset = 0; for (;;) { int index = name.indexOf('.', offset); String propName = index == -1 ? name.substring(offset) : name.substring(offset, index); Object prop = result.get(propName, result); if (!(prop instanceof Scriptable)) break; // fall through to error result = (Scriptable) prop; if (index == -1) return result; offset = index+1; } } throw Context.reportRuntimeError0("msg.not.java.obj"); }
final ClassConfiguration config = config_.getClassConfiguration(name); Scriptable prototype = entry.getValue(); if (prototype.getPrototype() != null) { prototype = prototype.getPrototype(); // "double prototype" hack for FF prototype.setPrototype(parentPrototype);
/** * @see net.sourceforge.htmlunit.corejs.javascript.Scriptable#setPrototype */ public void setPrototype(Scriptable prototype) { obj.setPrototype(prototype); } /**