htmlunit-2.7

(e);
    }
  }
  
  public Object jsxFunction_showModelessDialog(String url, Object arguments, String features)
  {
    WebWindow ww = getWebWindow();
    WebClient client = ww.getWebClient();
    try
    {
      URL completeUrl = ((HtmlPage)getDomNodeOrDie()).getFullyQualifiedUrl(url);
      DialogWindow dialog = client.openDialogWindow(completeUrl, ww, arguments);
      return (Window)dialog.getScriptObject();
    }
    catch (IOException e)
    {
      throw Context.throwAsScriptRuntimeEx(e);
    }
  }
  
  public Object jsxGet_controllers()
  {
    return controllers_;
  }
  
  public void jsxSet_controllers(Object value)
  {
    controllers_ = value;
  }
  
  private class DomHtmlAttributeChangeListenerImpl
    implements DomChangeListener, HtmlAttributeChangeListener, Serializable
  {
    private static final long serialVersionUID = -4651000523078926322L;
    
    private DomHtmlAttributeChangeListenerImpl() {}
    
    public void nodeAdded(DomChangeEvent event)
    {
      nodeChanged(event.getChangedNode());
    }
    
    public void nodeDeleted(DomChangeEvent event)
    {
      nodeChanged(event.getChangedNode());
    }
    
    public void attributeAdded(HtmlAttributeChangeEvent event)
    {
      nodeChanged(event.getHtmlElement());
    }
    
    public void attributeRemoved(HtmlAttributeChangeEvent event)
    {
      nodeChanged(event.getHtmlElement());
    }
    
    public void attributeReplaced(HtmlAttributeChangeEvent event)
    {
      nodeChanged(event.getHtmlElement());
    }
    
    private void nodeChanged(DomNode changed)
    {
      if ((changed instanceof HtmlStyle))
      {
        synchronized (computedStyles_)
        {
          computedStyles_.clear();
        }
        return;
      }
      if ((changed instanceof HtmlLink))
      {
        String rel = ((HtmlLink)changed).getRelAttribute().toLowerCase();
        if ("stylesheet".equals(rel))
        {
          synchronized (computedStyles_)
          {
            computedStyles_.clear();
          }
          return;
        }
      }
      synchronized (computedStyles_)
      {
        Object i = computedStyles_.entrySet().iterator();
        while (((Iterator)i).hasNext())
        {
          Object entry = (Map.Entry)((Iterator)i).next();
          DomNode node = ((Node)((Map.Entry)entry).getKey()).getDomNodeOrDie();
          if ((changed == node) || (changed.getParentNode() == node.getParentNode()) || (changed.isAncestorOf(node))) {
            ((Iterator)i).remove();
          }
        }
      }
    }
  }
  
  private static class FrameToWindowTransformer
    implements Transformer, Serializable
  {
    private static final long serialVersionUID = -8504605115217901029L;
    
    public Object transform(Object obj)
    {
      if ((obj instanceof BaseFrame)) {
        return ((BaseFrame)obj).getEnclosedWindow();
      }
      return ((FrameWindow)obj).getFrameElement().getEnclosedWindow();
    }
  }
  
  public String jsxFunction_ScriptEngine()
  {
    return "JScript";
  }
  
  public int jsxFunction_ScriptEngineBuildVersion()
  {
    return 12345;
  }
  
  public int jsxFunction_ScriptEngineMajorVersion()
  {
    return 5;
  }
  
  public int jsxFunction_ScriptEngineMinorVersion()
  {
    return (int)getBrowserVersion().getBrowserVersionNumeric();
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.Window
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.ScriptResult;
import com.gargoylesoftware.htmlunit.SgmlPage;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebWindow;
import com.gargoylesoftware.htmlunit.html.DomDocumentFragment;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLHtmlElement;
import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLSerializer;
import com.gargoylesoftware.htmlunit.xml.XmlPage;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Function;
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
import net.sourceforge.htmlunit.corejs.javascript.Undefined;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;

public class Node
  extends SimpleScriptable
{
  private static final long serialVersionUID = -5695262053081637445L;
  private HTMLCollection childNodes_;
  private EventListenersContainer eventListenersContainer_;
  public static final short ELEMENT_NODE = 1;
  public static final short ATTRIBUTE_NODE = 2;
  public static final short TEXT_NODE = 3;
  public static final short CDATA_SECTION_NODE = 4;
  public static final short ENTITY_REFERENCE_NODE = 5;
  public static final short ENTITY_NODE = 6;
  public static final short PROCESSING_INSTRUCTION_NODE = 7;
  public static final short COMMENT_NODE = 8;
  public static final short DOCUMENT_NODE = 9;
  public static final short DOCUMENT_TYPE_NODE = 10;
  public static final short DOCUMENT_FRAGMENT_NODE = 11;
  public static final short NOTATION_NODE = 12;
  public static final short DOCUMENT_POSITION_DISCONNECTED = 1;
  public static final short DOCUMENT_POSITION_PRECEDING = 2;
  public static final short DOCUMENT_POSITION_FOLLOWING = 4;
  public static final short DOCUMENT_POSITION_CONTAINS = 8;
  public static final short DOCUMENT_POSITION_CONTAINED_BY = 16;
  public static final short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
  
  public short jsxGet_nodeType()
  {
    return getDomNodeOrDie().getNodeType();
  }
  
  public String jsxGet_nodeName()
  {
    return getDomNodeOrDie().getNodeName();
  }
  
  public String jsxGet_nodeValue()
  {
    return getDomNodeOrDie().getNodeValue();
  }
  
  public void jsxSet_nodeValue(String newValue)
  {
    getDomNodeOrDie().setNodeValue(newValue);
  }
  
  public Object jsxFunction_appendChild(Object childObject)
  {
    Object appendedChild = null;
    if ((childObject instanceof Node))
    {
      Node childNode = (Node)childObject;
      if (!isNodeInsertable(childNode))
      {
        if (getBrowserVersion().isIE()) {
          return childObject;
        }
        throw Context.reportRuntimeError("Node cannot be inserted at the specified point in the hierarchy");
      }
      DomNode childDomNode = childNode.getDomNodeOrDie();
      
      DomNode parentNode = getDomNodeOrDie();
      
      parentNode.appendChild(childDomNode);
      appendedChild = childObject;
      if ((!(parentNode instanceof SgmlPage)) && (!(this instanceof DocumentFragment)) && (parentNode.getParentNode() == null) && (getBrowserVersion().isIE()))
      {
        DomDocumentFragment fragment = parentNode.getPage().createDomDocumentFragment();
        fragment.appendChild(parentNode);
      }
    }
    return appendedChild;
  }
  
  private boolean isNodeInsertable(Node childObject)
  {
    return !(childObject instanceof HTMLHtmlElement);
  }
  
  public Object jsxFunction_cloneNode(boolean deep)
  {
    DomNode domNode = getDomNodeOrDie();
    DomNode clonedNode = domNode.cloneNode(deep);
    
    Node jsClonedNode = getJavaScriptNode(clonedNode);
    if (getBrowserVersion().isIE()) {
      copyEventListenersWhenNeeded(domNode, clonedNode);
    }
    return jsClonedNode;
  }
  
  private void copyEventListenersWhenNeeded(DomNode domNode, DomNode clonedNode)
  {
    Node jsNode = (Node)domNode.getScriptObject();
    if (jsNode != null)
    {
      Node jsClonedNode = getJavaScriptNode(clonedNode);
      jsClonedNode.getEventListenersContainer().copyFrom(jsNode.getEventListenersContainer());
    }
    DomNode child = domNode.getFirstChild();
    DomNode clonedChild = clonedNode.getFirstChild();
    while ((child != null) && (clonedChild != null))
    {
      copyEventListenersWhenNeeded(child, clonedChild);
      child = child.getNextSibling();
      clonedChild = clonedChild.getNextSibling();
    }
  }
  
  public static Object jsxFunction_insertBefore(Context context, Scriptable thisObj, Object[] args, Function function)
  {
    return ((Node)thisObj).jsxFunction_insertBefore(args);
  }
  
  protected Object jsxFunction_insertBefore(Object[] args)
  {
    Object newChildObject = args[0];
    Object refChildObject;
    Object refChildObject;
    if (args.length > 1) {
      refChildObject = args[1];
    } else {
      refChildObject = Undefined.instance;
    }
    Object appendedChild = null;
    if ((newChildObject instanceof Node))
    {
      Node newChild = (Node)newChildObject;
      DomNode newChildNode = newChild.getDomNodeOrDie();
      if (!isNodeInsertable(newChild))
      {
        if (getBrowserVersion().isIE()) {
          return newChildNode;
        }
        throw Context.reportRuntimeError("Node cannot be inserted at the specified point in the hierarchy");
      }
      if ((newChildNode instanceof DomDocumentFragment))
      {
        DomDocumentFragment fragment = (DomDocumentFragment)newChildNode;
        for (DomNode child : fragment.getChildren()) {
          jsxFunction_insertBefore(new Object[] { child.getScriptObject(), refChildObject });
        }
        return newChildObject;
      }
      DomNode refChildNode;
      if (refChildObject == Undefined.instance)
      {
        DomNode refChildNode;
        if (getBrowserVersion().isIE())
        {
          if (args.length > 1) {
            throw Context.reportRuntimeError("Invalid argument.");
          }
          refChildNode = null;
        }
        else
        {
          DomNode refChildNode;
          if (args.length == 2) {
            refChildNode = null;
          } else {
            throw Context.reportRuntimeError("insertBefore: not enough arguments");
          }
        }
      }
      else
      {
        DomNode refChildNode;
        if (refChildObject != null) {
          refChildNode = ((Node)refChildObject).getDomNodeOrDie();
        } else {
          refChildNode = null;
        }
      }
      DomNode domNode = getDomNodeOrDie();
      if (refChildNode != null)
      {
        refChildNode.insertBefore(newChildNode);
        appendedChild = newChildObject;
      }
      else
      {
        domNode.appendChild(newChildNode);
        appendedChild = newChildObject;
      }
      if ((domNode.getParentNode() == null) && (getWindow().getWebWindow().getWebClient().getBrowserVersion().isIE()))
      {
        DomDocumentFragment fragment = domNode.getPage().createDomDocumentFragment();
        fragment.appendChild(domNode);
      }
    }
    return appendedChild;
  }
  
  public boolean jsxFunction_isSameNode(Object other)
  {
    return other == this;
  }
  
  public Object jsxFunction_removeChild(Object childObject)
  {
    Object removedChild = null;
    if ((childObject instanceof Node))
    {
      DomNode childNode = ((Node)childObject).getDomNodeOrDie();
      
      childNode.remove();
      removedChild = childObject;
    }
    return removedChild;
  }
  
  public boolean jsxFunction_hasChildNodes()
  {
    return getDomNodeOrDie().getChildren().iterator().hasNext();
  }
  
  public HTMLCollection jsxGet_childNodes()
  {
    if (childNodes_ == null)
    {
      childNodes_ = new HTMLCollection(this);
      childNodes_.initFromChildren(getDomNodeOrDie());
    }
    return childNodes_;
  }
  
  public Object jsxFunction_replaceChild(Object newChildObject, Object oldChildObject)
  {
    Object removedChild = null;
    if ((newChildObject instanceof DocumentFragment))
    {
      DocumentFragment fragment = (DocumentFragment)newChildObject;
      Node firstNode = null;
      Node refChildObject = ((Node)oldChildObject).jsxGet_nextSibling();
      for (DomNode node : fragment.getDomNodeOrDie().getChildren()) {
        if (firstNode == null)
        {
          jsxFunction_replaceChild(node.getScriptObject(), oldChildObject);
          firstNode = (Node)node.getScriptObject();
        }
        else
        {
          jsxFunction_insertBefore(new Object[] { node.getScriptObject(), refChildObject });
        }
      }
      if (firstNode == null) {
        jsxFunction_removeChild(oldChildObject);
      }
      removedChild = oldChildObject;
    }
    else if (((newChildObject instanceof Node)) && ((oldChildObject instanceof Node)))
    {
      Node newChild = (Node)newChildObject;
      if (!isNodeInsertable(newChild)) {
        throw Context.reportRuntimeError("Node cannot be inserted at the specified point in the hierarchy");
      }
      DomNode newChildNode = newChild.getDomNodeOrDie();
      
      DomNode oldChildNode = ((Node)oldChildObject).getDomNodeOrDie();
      oldChildNode.replace(newChildNode);
      removedChild = oldChildObject;
    }
    return removedChild;
  }
  
  public Node jsxGet_parentNode()
  {
    return getJavaScriptNode(getDomNodeOrDie().getParentNode());
  }
  
  public Node jsxGet_nextSibling()
  {
    return getJavaScriptNode(getDomNodeOrDie().getNextSibling());
  }
  
  public Node jsxGet_previousSibling()
  {
    return getJavaScriptNode(getDomNodeOrDie().getPreviousSibling());
  }
  
  public Node jsxGet_firstChild()
  {
    return getJavaScriptNode(getDomNodeOrDie().getFirstChild());
  }
  
  public Node jsxGet_lastChild()
  {
    return getJavaScriptNode(getDomNodeOrDie().getLastChild());
  }
  
  protected Node getJavaScriptNode(DomNode domNode)
  {
    if (domNode == null) {
      return null;
    }
    return (Node)getScriptableFor(domNode);
  }
  
  public boolean jsxFunction_attachEvent(String type, Function listener)
  {
    return getEventListenersContainer().addEventListener(StringUtils.substring(type, 2), listener, false);
  }
  
  public void jsxFunction_addEventListener(String type, Function listener, boolean useCapture)
  {
    getEventListenersContainer().addEventListener(type, listener, useCapture);
  }
  
  private EventListenersContainer getEventListenersContainer()
  {
    if (eventListenersContainer_ == null) {
      eventListenersContainer_ = new EventListenersContainer(this);
    }
    return eventListenersContainer_;
  }
  
  public void jsxFunction_detachEvent(String type, Function listener)
  {
    jsxFunction_removeEventListener(StringUtils.substring(type, 2), listener, false);
  }
  
  public void jsxFunction_removeEventListener(String type, Function listener, boolean useCapture)
  {
    getEventListenersContainer().removeEventListener(type, listener, useCapture);
  }
  
  public ScriptResult executeEvent(Event event)
  {
    if (eventListenersContainer_ != null)
    {
      HtmlPage page = (HtmlPage)getDomNodeOrDie().getPage();
      boolean isIE = getBrowserVersion().isIE();
      Window window = (Window)page.getEnclosingWindow().getScriptObject();
      Object[] args = { event };
      Object[] propHandlerArgs;
      Object[] propHandlerArgs;
      if (isIE) {
        propHandlerArgs = ArrayUtils.EMPTY_OBJECT_ARRAY;
      } else {
        propHandlerArgs = args;
      }
      window.setCurrentEvent(event);
      try
      {
        return eventListenersContainer_.executeListeners(event, args, propHandlerArgs);
      }
      finally
      {
        window.setCurrentEvent(null);
      }
    }
    return null;
  }
  
  public ScriptResult fireEvent(Event event)
  {
    HtmlPage page = (HtmlPage)getDomNodeOrDie().getPage();
    boolean ie = getBrowserVersion().isIE();
    Window window = (Window)page.getEnclosingWindow().getScriptObject();
    Object[] args = { event };
    
    event.startFire();
    ScriptResult result = null;
    Event previousEvent = window.getCurrentEvent();
    window.setCurrentEvent(event);
    try
    {
      EventListenersContainer windowsListeners = getWindow().getEventListenersContainer();
      
      event.setEventPhase((short)1);
      result = windowsListeners.executeCapturingListeners(event, args);
      if (event.isPropagationStopped()) {
        return result;
      }
      Object parents = new ArrayList();
      DomNode node = getDomNodeOrDie();
      while (node != null)
      {
        ((List)parents).add(node);
        node = node.getParentNode();
      }
      ScriptResult r;
      for (int i = ((List)parents).size() - 1; i >= 0; i--)
      {
        DomNode curNode = (DomNode)((List)parents).get(i);
        Node jsNode = (Node)curNode.getScriptObject();
        EventListenersContainer elc = eventListenersContainer_;
        if (elc != null)
        {
          r = elc.executeCapturingListeners(event, args);
          result = ScriptResult.combine(r, result, ie);
          if (event.isPropagationStopped()) {
            return result;
          }
        }
      }
      Object[] propHandlerArgs;
      Object[] propHandlerArgs;
      if (ie) {
        propHandlerArgs = ArrayUtils.EMPTY_OBJECT_ARRAY;
      } else {
        propHandlerArgs = args;
      }
      event.setEventPhase((short)2);
      node = getDomNodeOrDie();
      while (node != null)
      {
        Node jsNode = (Node)node.getScriptObject();
        EventListenersContainer elc = eventListenersContainer_;
        if (elc != null)
        {
          ScriptResult r = elc.executeBubblingListeners(event, args, propHandlerArgs);
          result = ScriptResult.combine(r, result, ie);
          if (event.isPropagationStopped()) {
            return result;
          }
        }
        node = node.getParentNode();
        event.setEventPhase((short)3);
      }
      ScriptResult r = windowsListeners.executeBubblingListeners(event, args, propHandlerArgs);
      result = ScriptResult.combine(r, result, ie);
    }
    finally
    {
      event.endFire();
      window.setCurrentEvent(previousEvent);
    }
    return result;
  }
  
  public Function getEventHandler(String eventName)
  {
    if (eventListenersContainer_ == null) {
      return null;
    }
    return eventListenersContainer_.getEventHandler(StringUtils.substring(eventName, 2));
  }
  
  public void setEventHandler(String eventName, Function eventHandler)
  {
    setEventHandlerProp(eventName, eventHandler);
  }
  
  protected void setEventHandlerProp(String eventName, Object value)
  {
    getEventListenersContainer().setEventHandlerProp(StringUtils.substring(eventName.toLowerCase(), 2), value);
  }
  
  protected Object getEventHandlerProp(String eventName)
  {
    if (eventListenersContainer_ == null) {
      return null;
    }
    return eventListenersContainer_.getEventHandlerProp(StringUtils.substring(eventName.toLowerCase(), 2));
  }
  
  public Object jsxGet_ownerDocument()
  {
    Object document = getDomNodeOrDie().getOwnerDocument();
    if (document == null) {
      return null;
    }
    return ((SgmlPage)document).getScriptObject();
  }
  
  public String jsxGet_prefix()
  {
    DomNode domNode = getDomNodeOrDie();
    String prefix = domNode.getPrefix();
    if ((getBrowserVersion().isIE()) && ((prefix == null) || ((domNode.getPage() instanceof HtmlPage)))) {
      return "";
    }
    return prefix;
  }
  
  public String jsxGet_localName()
  {
    return getDomNodeOrDie().getLocalName();
  }
  
  public String jsxGet_namespaceURI()
  {
    String namespaceURI = getDomNodeOrDie().getNamespaceURI();
    if ((namespaceURI == null) && (getBrowserVersion().isIE())) {
      return "";
    }
    return namespaceURI;
  }
  
  public void setDomNode(DomNode domNode)
  {
    super.setDomNode(domNode);
    if ((getBrowserVersion().isIE()) && (!(getDomNodeOrDie().getPage() instanceof HtmlPage)))
    {
      ActiveXObject.addProperty(this, "namespaceURI", true, false);
      ActiveXObject.addProperty(this, "prefix", true, false);
    }
  }
  
  public short jsxFunction_compareDocumentPosition(Node node)
  {
    return getDomNodeOrDie().compareDocumentPosition(node.getDomNodeOrDie());
  }
  
  public void jsxFunction_normalize()
  {
    getDomNodeOrDie().normalize();
  }
  
  public Object jsxGet_xml()
  {
    DomNode node = getDomNodeOrDie();
    if ((node.getPage() instanceof XmlPage))
    {
      if ((this instanceof Element))
      {
        XMLSerializer serializer = new XMLSerializer();
        serializer.setParentScope(getParentScope());
        String xml = serializer.jsxFunction_serializeToString(this);
        if ((getBrowserVersion().isIE()) && (xml.endsWith("\r\n"))) {
          xml = xml.substring(0, xml.length() - 2);
        }
        return xml;
      }
      return node.asXml();
    }
    return Undefined.instance;
  }
  
  public String jsxGet_textContent()
  {
    return getDomNodeOrDie().getTextContent();
  }
  
  public void jsxSet_textContent(Object value)
  {
    getDomNodeOrDie().setTextContent(value == null ? null : Context.toString(value));
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.Node
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.CookieManager;
import com.gargoylesoftware.htmlunit.PluginConfiguration;
import com.gargoylesoftware.htmlunit.PluginConfiguration.MimeType;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebWindow;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;

public final class Navigator
  extends SimpleScriptable
{
  private static final long serialVersionUID = 6741787912716453833L;
  private PluginArray plugins_;
  private MimeTypeArray mimeTypes_;
  
  public String jsxGet_appCodeName()
  {
    return getBrowserVersion().getApplicationCodeName();
  }
  
  public String jsxGet_appMinorVersion()
  {
    return getBrowserVersion().getApplicationMinorVersion();
  }
  
  public String jsxGet_appName()
  {
    return getBrowserVersion().getApplicationName();
  }
  
  public String jsxGet_appVersion()
  {
    return getBrowserVersion().getApplicationVersion();
  }
  
  public String jsxGet_browserLanguage()
  {
    return getBrowserVersion().getBrowserLanguage();
  }
  
  public String jsxGet_language()
  {
    return getBrowserVersion().getBrowserLanguage();
  }
  
  public boolean jsxGet_cookieEnabled()
  {
    return getWindow().getWebWindow().getWebClient().getCookieManager().isCookiesEnabled();
  }
  
  public String jsxGet_cpuClass()
  {
    return getBrowserVersion().getCpuClass();
  }
  
  public boolean jsxGet_onLine()
  {
    return getBrowserVersion().isOnLine();
  }
  
  public String jsxGet_platform()
  {
    return getBrowserVersion().getPlatform();
  }
  
  public String jsxGet_product()
  {
    return "Gecko";
  }
  
  public String jsxGet_systemLanguage()
  {
    return getBrowserVersion().getSystemLanguage();
  }
  
  public String jsxGet_userAgent()
  {
    return getBrowserVersion().getUserAgent();
  }
  
  public String jsxGet_userLanguage()
  {
    return getBrowserVersion().getUserLanguage();
  }
  
  public Object jsxGet_plugins()
  {
    initPlugins();
    return plugins_;
  }
  
  private void initPlugins()
  {
    if (plugins_ != null) {
      return;
    }
    plugins_ = new PluginArray();
    plugins_.setParentScope(this);
    plugins_.setPrototype(getPrototype(PluginArray.class));
    
    mimeTypes_ = new MimeTypeArray();
    mimeTypes_.setParentScope(this);
    mimeTypes_.setPrototype(getPrototype(MimeTypeArray.class));
    for (PluginConfiguration pluginConfig : getBrowserVersion().getPlugins())
    {
      plugin = new Plugin(pluginConfig.getName(), pluginConfig.getDescription(), pluginConfig.getFilename());
      
      plugin.setParentScope(this);
      plugin.setPrototype(getPrototype(Plugin.class));
      plugins_.add(plugin);
      for (PluginConfiguration.MimeType mimeTypeConfig : pluginConfig.getMimeTypes())
      {
        MimeType mimeType = new MimeType(mimeTypeConfig.getType(), mimeTypeConfig.getDescription(), mimeTypeConfig.getSuffixes(), plugin);
        
        mimeType.setParentScope(this);
        mimeType.setPrototype(getPrototype(MimeType.class));
        mimeTypes_.add(mimeType);
        plugin.add(mimeType);
      }
    }
    Plugin plugin;
  }
  
  public Object jsxGet_mimeTypes()
  {
    initPlugins();
    return mimeTypes_;
  }
  
  public boolean jsxFunction_javaEnabled()
  {
    return getWindow().getWebWindow().getWebClient().isAppletEnabled();
  }
  
  public boolean jsxFunction_taintEnabled()
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.Navigator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;

public class Screen
  extends SimpleScriptable
{
  private static final long serialVersionUID = 7775024295042666245L;
  private int left_;
  private int top_;
  private int width_;
  private int height_;
  private int colorDepth_;
  private int bufferDepth_;
  private int dpi_;
  private boolean fontSmoothingEnabled_;
  private int updateInterval_;
  
  public Screen()
  {
    left_ = 0;
    top_ = 0;
    width_ = 1024;
    height_ = 768;
    colorDepth_ = 24;
    bufferDepth_ = 24;
    dpi_ = 96;
    fontSmoothingEnabled_ = true;
    updateInterval_ = 0;
  }
  
  public int jsxGet_availHeight()
  {
    return height_;
  }
  
  public int jsxGet_availLeft()
  {
    return left_;
  }
  
  public int jsxGet_availTop()
  {
    return top_;
  }
  
  public int jsxGet_availWidth()
  {
    return width_;
  }
  
  public int jsxGet_bufferDepth()
  {
    return bufferDepth_;
  }
  
  public void jsxSet_bufferDepth(int bufferDepth)
  {
    bufferDepth_ = bufferDepth;
  }
  
  public int jsxGet_colorDepth()
  {
    return colorDepth_;
  }
  
  public int jsxGet_deviceXDPI()
  {
    return dpi_;
  }
  
  public int jsxGet_deviceYDPI()
  {
    return dpi_;
  }
  
  public boolean jsxGet_fontSmoothingEnabled()
  {
    return fontSmoothingEnabled_;
  }
  
  public int jsxGet_height()
  {
    return height_;
  }
  
  public int jsxGet_left()
  {
    return left_;
  }
  
  public void jsxSet_left(int left)
  {
    left_ = left;
  }
  
  public int jsxGet_logicalXDPI()
  {
    return dpi_;
  }
  
  public int jsxGet_logicalYDPI()
  {
    return dpi_;
  }
  
  public int jsxGet_pixelDepth()
  {
    return colorDepth_;
  }
  
  public int jsxGet_top()
  {
    return top_;
  }
  
  public void jsxSet_top(int top)
  {
    top_ = top;
  }
  
  public int jsxGet_updateInterval()
  {
    return updateInterval_;
  }
  
  public void jsxSet_updateInterval(int updateInterval)
  {
    updateInterval_ = updateInterval;
  }
  
  public int jsxGet_width()
  {
    return width_;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.Screen
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebWindow;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import java.io.IOException;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;

public class History
  extends SimpleScriptable
{
  private static final long serialVersionUID = -285158453206844475L;
  
  public Object[] getIds()
  {
    Object[] ids = super.getIds();
    if (getBrowserVersion().isFirefox())
    {
      int len = getWindow().getWebWindow().getHistory().getLength();
      if (len > 0)
      {
        Object[] allIds = new Object[ids.length + len];
        System.arraycopy(ids, 0, allIds, 0, ids.length);
        for (int i = 0; i < len; i++) {
          allIds[(ids.length + i)] = new Integer(i);
        }
        ids = allIds;
      }
    }
    return ids;
  }
  
  public boolean has(int index, Scriptable start)
  {
    if (getBrowserVersion().isFirefox())
    {
      History h = (History)start;
      if ((index >= 0) && (index < h.jsxGet_length())) {
        return true;
      }
    }
    return super.has(index, start);
  }
  
  public Object get(int index, Scriptable start)
  {
    History h = (History)start;
    if ((index < 0) || (index >= h.jsxGet_length())) {
      return NOT_FOUND;
    }
    return jsxFunction_item(index);
  }
  
  public int jsxGet_length()
  {
    WebWindow w = getWindow().getWebWindow();
    return w.getHistory().getLength();
  }
  
  public void jsxFunction_back()
  {
    WebWindow w = getWindow().getWebWindow();
    try
    {
      w.getHistory().back();
    }
    catch (IOException e)
    {
      Context.throwAsScriptRuntimeEx(e);
    }
  }
  
  public void jsxFunction_forward()
  {
    WebWindow w = getWindow().getWebWindow();
    try
    {
      w.getHistory().forward();
    }
    catch (IOException e)
    {
      Context.throwAsScriptRuntimeEx(e);
    }
  }
  
  public void jsxFunction_go(int relativeIndex)
  {
    WebWindow w = getWindow().getWebWindow();
    try
    {
      w.getHistory().go(relativeIndex);
    }
    catch (IOException e)
    {
      Context.throwAsScriptRuntimeEx(e);
    }
  }
  
  public String jsxGet_current()
  {
    throw Context.reportRuntimeError("Permission denied to get property History.current");
  }
  
  public String jsxGet_previous()
  {
    throw Context.reportRuntimeError("Permission denied to get property History.previous");
  }
  
  public String jsxGet_next()
  {
    throw Context.reportRuntimeError("Permission denied to get property History.next");
  }
  
  public String jsxFunction_item(int index)
  {
    throw Context.reportRuntimeError("Permission denied to call method History.item");
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.History
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebRequestSettings;
import com.gargoylesoftware.htmlunit.WebResponse;
import com.gargoylesoftware.htmlunit.WebWindow;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.util.UrlUtils;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Location
  extends SimpleScriptable
{
  private static final long serialVersionUID = -2907220432378132233L;
  private static final Log LOG = LogFactory.getLog(Location.class);
  private static final String UNKNOWN = "null";
  private Window window_;
  private String hash_;
  
  public void initialize(Window window)
  {
    window_ = window;
    if ((window_ != null) && (window_.getWebWindow().getEnclosedPage() != null)) {
      hash_ = window_.getWebWindow().getEnclosedPage().getWebResponse().getRequestSettings().getUrl().getRef();
    }
  }
  
  public Object getDefaultValue(Class<?> hint)
  {
    if ((hint == null) || (String.class.equals(hint))) {
      return jsxGet_href();
    }
    return super.getDefaultValue(hint);
  }
  
  public String toString()
  {
    if (window_ != null) {
      return jsxGet_href();
    }
    return "[Uninitialized]";
  }
  
  public void jsxFunction_assign(String url)
    throws IOException
  {
    jsxSet_href(url);
  }
  
  public void jsxFunction_reload(boolean force)
    throws IOException
  {
    String url = jsxGet_href();
    if ("null".equals(url)) {
      LOG.error("Unable to reload location: current URL is unknown.");
    } else {
      jsxSet_href(url);
    }
  }
  
  public void jsxFunction_replace(String url)
    throws IOException
  {
    jsxSet_href(url);
  }
  
  public String jsxFunction_toString()
  {
    return jsxGet_href();
  }
  
  public String jsxGet_href()
  {
    Page page = window_.getWebWindow().getEnclosedPage();
    if (page == null) {
      return "null";
    }
    try
    {
      URL url = page.getWebResponse().getRequestSettings().getUrl();
      boolean encodeHash = !getBrowserVersion().isIE();
      String hash = getHash(encodeHash);
      if (hash != null) {
        url = UrlUtils.getUrlWithNewRef(url, hash);
      }
      String s = url.toExternalForm();
      if ((s.startsWith("file:/")) && (!s.startsWith("file:///"))) {}
      return "file:///" + s.substring("file:/".length());
    }
    catch (MalformedURLException e)
    {
      LOG.error(e.getMessage(), e);
    }
    return page.getWebResponse().getRequestSettings().getUrl().toExternalForm();
  }
  
  public void jsxSet_href(String newLocation)
    throws IOException
  {
    HtmlPage page = (HtmlPage)getWindow(getStartingScope()).getWebWindow().getEnclosedPage();
    if (newLocation.startsWith("javascript:"))
    {
      String script = newLocation.substring(11);
      page.executeJavaScriptIfPossible(script, "new location value", 1);
      return;
    }
    try
    {
      URL url = page.getFullyQualifiedUrl(newLocation);
      URL oldUrl = page.getWebResponse().getRequestSettings().getUrl();
      if ((url.sameFile(oldUrl)) && (!StringUtils.equals(url.getRef(), oldUrl.getRef())))
      {
        jsxSet_hash(newLocation);
        return;
      }
      WebWindow webWindow = getWindow().getWebWindow();
      webWindow.getWebClient().download(webWindow, "", new WebRequestSettings(url), "JS set location");
    }
    catch (MalformedURLException e)
    {
      LOG.error("jsxSet_location('" + newLocation + "') Got MalformedURLException", e);
      throw e;
    }
  }
  
  public String jsxGet_search()
  {
    String search = getUrl().getQuery();
    if (search == null) {
      return "";
    }
    return "?" + search;
  }
  
  public void jsxSet_search(String search)
    throws Exception
  {
    setUrl(UrlUtils.getUrlWithNewQuery(getUrl(), search));
  }
  
  public String jsxGet_hash()
  {
    String hash = getHash(false);
    if (hash != null) {
      return "#" + hash;
    }
    return "";
  }
  
  private String getHash(boolean encoded)
  {
    if ((hash_ == null) || (hash_.length() == 0)) {
      return null;
    }
    if (encoded) {
      return UrlUtils.encodeAnchor(hash_);
    }
    return hash_;
  }
  
  public void jsxSet_hash(String hash)
  {
    if (hash != null)
    {
      if (hash.startsWith("#")) {
        hash = hash.substring(1);
      }
      boolean decodeHash = !getBrowserVersion().isIE();
      if (decodeHash) {
        hash = UrlUtils.decode(hash);
      }
      hash_ = hash;
    }
    else
    {
      hash_ = null;
    }
  }
  
  public String jsxGet_hostname()
  {
    return getUrl().getHost();
  }
  
  public void jsxSet_hostname(String hostname)
    throws Exception
  {
    setUrl(UrlUtils.getUrlWithNewHost(getUrl(), hostname));
  }
  
  public String jsxGet_host()
  {
    URL url = getUrl();
    int port = url.getPort();
    String host = url.getHost();
    if (port == -1) {
      return host;
    }
    return host + ":" + port;
  }
  
  public void jsxSet_host(String host)
    throws Exception
  {
    int index = host.indexOf(':');
    int port;
    String hostname;
    int port;
    if (index != -1)
    {
      String hostname = host.substring(0, index);
      port = Integer.parseInt(host.substring(index + 1));
    }
    else
    {
      hostname = host;
      port = -1;
    }
    URL url1 = UrlUtils.getUrlWithNewHost(getUrl(), hostname);
    URL url2 = UrlUtils.getUrlWithNewPort(url1, port);
    setUrl(url2);
  }
  
  public String jsxGet_pathname()
  {
    if (WebClient.URL_ABOUT_BLANK == getUrl())
    {
      if (getBrowserVersion().isFirefox()) {
        return "";
      }
      return "/blank";
    }
    return getUrl().getPath();
  }
  
  public void jsxSet_pathname(String pathname)
    throws Exception
  {
    setUrl(UrlUtils.getUrlWithNewPath(getUrl(), pathname));
  }
  
  public String jsxGet_port()
  {
    int port = getUrl().getPort();
    if (port == -1) {
      return "";
    }
    return String.valueOf(port);
  }
  
  public void jsxSet_port(String port)
    throws Exception
  {
    setUrl(UrlUtils.getUrlWithNewPort(getUrl(), Integer.parseInt(port)));
  }
  
  public String jsxGet_protocol()
  {
    return getUrl().getProtocol() + ":";
  }
  
  public void jsxSet_protocol(String protocol)
    throws Exception
  {
    setUrl(UrlUtils.getUrlWithNewProtocol(getUrl(), protocol));
  }
  
  private URL getUrl()
  {
    return window_.getWebWindow().getEnclosedPage().getWebResponse().getRequestSettings().getUrl();
  }
  
  private void setUrl(URL url)
    throws IOException
  {
    window_.getWebWindow().getWebClient().getPage(window_.getWebWindow(), new WebRequestSettings(url));
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.Location
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;

public class OfflineResourceList
  extends SimpleScriptable
{
  private static final long serialVersionUID = -1003302627764098209L;
  public static final short STATUS_UNCACHED = 0;
  public static final short STATUS_IDLE = 1;
  public static final short STATUS_CHECKING = 2;
  public static final short STATUS_DOWNLOADING = 3;
  public static final short STATUS_UPDATEREADY = 4;
  public static final short STATUS_OBSOLETE = 5;
  private short status_ = 0;
  private Object onchecking_;
  private Object onerror_;
  private Object onnoupdate_;
  private Object ondownloading_;
  private Object onprogress_;
  private Object onupdateready_;
  private Object oncached_;
  
  public Object jsxGet_onchecking()
  {
    return onchecking_;
  }
  
  public void jsxSet_onchecking(Object o)
  {
    onchecking_ = o;
  }
  
  public Object jsxGet_onerror()
  {
    return onerror_;
  }
  
  public void jsxSet_onerror(Object o)
  {
    onerror_ = o;
  }
  
  public Object jsxGet_onnoupdate()
  {
    return onnoupdate_;
  }
  
  public void jsxSet_onnoupdate(Object o)
  {
    onnoupdate_ = o;
  }
  
  public Object jsxGet_ondownloading()
  {
    return ondownloading_;
  }
  
  public void jsxSet_ondownloading(Object o)
  {
    ondownloading_ = o;
  }
  
  public Object jsxGet_onprogress()
  {
    return onprogress_;
  }
  
  public void jsxSet_onprogress(Object o)
  {
    onprogress_ = o;
  }
  
  public Object jsxGet_onupdateready()
  {
    return onupdateready_;
  }
  
  public void jsxSet_onupdateready(Object o)
  {
    onupdateready_ = o;
  }
  
  public Object jsxGet_oncached()
  {
    return oncached_;
  }
  
  public void jsxSet_oncached(Object o)
  {
    oncached_ = o;
  }
  
  public short jsxGet_status()
  {
    return status_;
  }
  
  public int jsxGet_length()
  {
    return 0;
  }
  
  public void jsxFunction_add(String uri) {}
  
  public boolean jsxFunction_hasItem(String uri)
  {
    return false;
  }
  
  public String jsxFunction_item(int index)
  {
    return null;
  }
  
  public void jsxFunction_remove(String uri) {}
  
  public void jsxFunction_swapCache() {}
  
  public void jsxFunction_update() {}
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.OfflineResourceList
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.impl.SimpleRange;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import java.util.List;
import net.sourceforge.htmlunit.corejs.javascript.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd