Examples of BaseFunction


Examples of net.sourceforge.htmlunit.corejs.javascript.BaseFunction

        final String scriptCode = textNode.getData();
        if (ie && event != ATTRIBUTE_NOT_DEFINED && forr != ATTRIBUTE_NOT_DEFINED) {
            if ("window".equals(forr)) {
                // everything fine, accepted by IE and FF
                final Window window = (Window) getPage().getEnclosingWindow().getScriptObject();
                final BaseFunction function = new EventHandler(this, event, scriptCode);
                window.jsxFunction_attachEvent(event, function);
            }
            else {
                try {
                    final HtmlElement elt = ((HtmlPage) getPage()).getHtmlElementById(forr);
View Full Code Here

Examples of net.sourceforge.htmlunit.corejs.javascript.BaseFunction

     */
    @Override
    public Object get(final String name, final Scriptable start) {
        // quick and dirty
        if ("toString".equals(name)) {
            return new BaseFunction() {
                //checkstyle bug: http://sourceforge.net/tracker/?func=detail&atid=397078&aid=2853482&group_id=29721
                //private static final long serialVersionUID = 3761409724511435061L;

                @Override
                public Object call(final Context cx, final Scriptable scope,
View Full Code Here

Examples of net.sourceforge.htmlunit.corejs.javascript.BaseFunction

     * "event"
     * @param eventName Name of event such as "onclick" or "onblur", etc
     * @param jsSnippet executable JavaScript code
     */
    public final void setEventHandler(final String eventName, final String jsSnippet) {
        final BaseFunction function = new EventHandler(this, eventName, jsSnippet);
        setEventHandler(eventName, function);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Created event handler " + function.getFunctionName()
                    + " for " + eventName + " on " + this);
        }
    }
View Full Code Here

Examples of net.sourceforge.htmlunit.corejs.javascript.BaseFunction

            return;
        }

        // Rhino should provide the possibility to declare delegate for Functions as it does for properties!!!
        for (final Method method : applet.getClass().getMethods()) {
            final Function f = new BaseFunction() {
                private static final long serialVersionUID = 1748611972272176674L;

                @Override
                public Object call(final Context cx, final Scriptable scope,
                        final Scriptable thisObj, final Object[] args) {
View Full Code Here

Examples of net.sourceforge.htmlunit.corejs.javascript.BaseFunction

     * @param attrValue the attribute value
     */
    protected void createEventHandler(final String eventName, final String attrValue) {
        final HtmlElement htmlElt = getDomNodeOrDie();
        // TODO: check that it is an "allowed" event for the browser, and take care to the case
        final BaseFunction eventHandler = new EventHandler(htmlElt, eventName, attrValue);
        setEventHandler(eventName, eventHandler);
        // forward onload, onclick, ondblclick, ... to window
        if ((htmlElt instanceof HtmlBody || htmlElt instanceof HtmlFrameSet)) {
            getWindow().getEventListenersContainer()
                .setEventHandlerProp(eventName.substring(2), eventHandler);
View Full Code Here

Examples of org.mozilla.javascript.BaseFunction

    }
  public static Function createFunction(final String source, String name) {
    Context context = PersevereContextFactory.getContext();
    try {
      BaseFunction func = (BaseFunction) context.evaluateString(GlobalData.getGlobalScope(), "(" + source + ")", name, 1, null);
      // store the source so we can retain comments et al
      func.put("source", func, source);
      ScriptRuntime.setObjectProtoAndParent(func,GlobalData.getGlobalScope());
      return func;
    }
    catch (Exception e) {
      System.err.println(e.getMessage());
View Full Code Here

Examples of org.mozilla.javascript.BaseFunction

        if (!UserSecurity.hasPermission(SystemPermission.javaScriptCoding))
          throw new SecurityException("User is not permitted to execute code on the server");
        return cx.evaluateString(GlobalData.getGlobalScope(), (String) args[0], "console", 0, null);
      }     
    });
    BaseFunction putHandler = new PersevereNativeFunction() {
      @Override
      public Object call(final Context cx, final Scriptable scope,
          final Scriptable thisObj, Object[] args) {
        // check to make sure all the objects are valid after a schema change
        // TODO: The performance of this could be greatly improved with more information from the put
        PersistableClass schema = (PersistableClass) thisObj;
        if (schema != null) {
          Object propertiesDefinitions = schema.get("properties");
          if (propertiesDefinitions instanceof Persistable && schema.getPrototypeProperty() instanceof Persistable) {
            Persistable prototype = (Persistable) schema.getPrototypeProperty();
              for (Object key : prototype.getIds())
                if (key instanceof String)
                  enforceSchemaForProperty(schema, prototype, (String) key, prototype.get((String) key), true, true, false);
              List<Persistable> instances = (List) schema.get("instances");
              Object[] propertyIds = ((Persistable)propertiesDefinitions).getIds();
              List<String> stringList = new ArrayList();
              for (Object property : propertyIds){
                if (property instanceof String)
                  stringList.add((String) property);
              }
              String[] stringKeys = new String[stringList.size()];
              stringList.toArray(stringKeys);
              for (String key : stringKeys) {
                Object propertyDef = ((Persistable)propertiesDefinitions).get(key);
                //TODO: Allow it to point to another a schema's properties object
                if (propertyDef instanceof Persistable && !(propertyDef instanceof PersistableClass)) {
                  if (((Persistable)propertyDef).get("properties") instanceof Persistable)
                    throw new RuntimeException("Can not create an object validator that does not reference an existing schema");
                }
              }
              if(Boolean.TRUE.equals(schema.get("checkAllInstancesOnSchemaChange", schema))) {
                for (Persistable instance : instances){
                  for (String key : stringKeys) {
                    enforceSchemaForProperty(schema, instance, key, ScriptableObject.getProperty(instance, key), true, true, false);
                  }
                }
              }
          }
        }
        return true;
        }
      public String toString() {
        return "function(resource){/*native code*/}";
      }
    };
    putHandler.put("source", putHandler, "function(){[Native code]}");
    pjsLibrary.put("putHandler", pjsLibrary, putHandler);
    putHandler.setPrototype(ScriptableObject.getFunctionPrototype(GlobalData.getGlobalScope()));
  }
View Full Code Here

Examples of org.mozilla.javascript.BaseFunction

          }
          final Function newFunction = ((Query) key).conditionFunction;
          final Function oldFunction = ((Query) oldQuery).conditionFunction;
          if (oldFunction != null) {
            // create a new function that combines the other two
            ((Query) oldQuery).conditionFunction = new BaseFunction() {
              public Object call(org.mozilla.javascript.Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
                return ScriptRuntime.toBoolean(newFunction.call(cx,  scope, thisObj, args)) ||
                  ScriptRuntime.toBoolean(oldFunction.call(cx, scope, thisObj, args));
              }
            };
View Full Code Here

Examples of org.mozilla.javascript.BaseFunction

  /**
   * ECMA 11.4.3 says that typeof on host object is Implementation-dependent
   */
  public void test0() throws Exception
  {
        final Function f = new BaseFunction()
        {
          @Override
          public Object call(Context _cx, Scriptable _scope, Scriptable _thisObj,
              Object[] _args)
          {
View Full Code Here

Examples of org.mozilla.javascript.BaseFunction

  /**
   * ECMA 11.4.3 says that typeof on host object is Implementation-dependent
   */
  public void test0() throws Exception
  {
        final Function f = new BaseFunction()
        {
          @Override
          public Object call(Context _cx, Scriptable _scope, Scriptable _thisObj,
              Object[] _args)
          {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.