Search in sources :

Example 1 with DocumentProxy

use of com.gargoylesoftware.htmlunit.javascript.host.html.DocumentProxy in project htmlunit by HtmlUnit.

the class HTMLCollectionFrames method initialize.

/**
 * Initializes this window.
 * @param webWindow the web window corresponding to this window
 * @param pageToEnclose the page that will become the enclosing page
 */
public void initialize(final WebWindow webWindow, final Page pageToEnclose) {
    webWindow_ = webWindow;
    webWindow_.setScriptableObject(this);
    windowProxy_ = new WindowProxy(webWindow_);
    if (pageToEnclose instanceof XmlPage) {
        document_ = new XMLDocument();
    } else {
        document_ = new HTMLDocument();
    }
    document_.setParentScope(this);
    document_.setPrototype(getPrototype(document_.getClass()));
    document_.setWindow(this);
    if (pageToEnclose instanceof SgmlPage) {
        final SgmlPage page = (SgmlPage) pageToEnclose;
        document_.setDomNode(page);
        if (page.isHtmlPage()) {
            final HtmlPage htmlPage = (HtmlPage) page;
            htmlPage.addAutoCloseable(this);
        }
    }
    documentProxy_ = new DocumentProxy(webWindow_);
    navigator_ = new Navigator();
    navigator_.setParentScope(this);
    navigator_.setPrototype(getPrototype(navigator_.getClass()));
    screen_ = new Screen(getWebWindow().getScreen());
    screen_.setParentScope(this);
    screen_.setPrototype(getPrototype(screen_.getClass()));
    history_ = new History();
    history_.setParentScope(this);
    history_.setPrototype(getPrototype(history_.getClass()));
    location_ = new Location();
    location_.setParentScope(this);
    location_.setPrototype(getPrototype(location_.getClass()));
    location_.initialize(this, pageToEnclose);
    final Console console = new Console();
    console.setWebWindow(webWindow_);
    console.setParentScope(this);
    console.setPrototype(getPrototype(console.getClass()));
    console_ = console;
    applicationCache_ = new ApplicationCache();
    applicationCache_.setParentScope(this);
    applicationCache_.setPrototype(getPrototype(applicationCache_.getClass()));
    // like a JS new Object()
    final Context ctx = Context.getCurrentContext();
    controllers_ = ctx.newObject(this);
    if (webWindow_ instanceof TopLevelWindow) {
        final WebWindow opener = ((TopLevelWindow) webWindow_).getOpener();
        if (opener != null) {
            opener_ = opener.getScriptableObject();
        }
    }
}
Also used : Context(net.sourceforge.htmlunit.corejs.javascript.Context) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HTMLDocument(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument) XMLDocument(com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocument) WebWindow(com.gargoylesoftware.htmlunit.WebWindow) SgmlPage(com.gargoylesoftware.htmlunit.SgmlPage) XmlPage(com.gargoylesoftware.htmlunit.xml.XmlPage) DocumentProxy(com.gargoylesoftware.htmlunit.javascript.host.html.DocumentProxy) TopLevelWindow(com.gargoylesoftware.htmlunit.TopLevelWindow)

Aggregations

SgmlPage (com.gargoylesoftware.htmlunit.SgmlPage)1 TopLevelWindow (com.gargoylesoftware.htmlunit.TopLevelWindow)1 WebWindow (com.gargoylesoftware.htmlunit.WebWindow)1 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)1 DocumentProxy (com.gargoylesoftware.htmlunit.javascript.host.html.DocumentProxy)1 HTMLDocument (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument)1 XMLDocument (com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocument)1 XmlPage (com.gargoylesoftware.htmlunit.xml.XmlPage)1 Context (net.sourceforge.htmlunit.corejs.javascript.Context)1