Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.WebWindow


    /**
     * Returns the "length" property.
     * @return the "length" property
     */
    public int jsxGet_length() {
        final WebWindow w = getWindow().getWebWindow();
        return w.getHistory().getLength();
    }
View Full Code Here


    /**
     * JavaScript function "back".
     */
    public void jsxFunction_back() {
        final WebWindow w = getWindow().getWebWindow();
        try {
            w.getHistory().back();
        }
        catch (final IOException e) {
            Context.throwAsScriptRuntimeEx(e);
        }
    }
View Full Code Here

    /**
     * JavaScript function "forward".
     */
    public void jsxFunction_forward() {
        final WebWindow w = getWindow().getWebWindow();
        try {
            w.getHistory().forward();
        }
        catch (final IOException e) {
            Context.throwAsScriptRuntimeEx(e);
        }
    }
View Full Code Here

    /**
     * JavaScript function "go".
     * @param relativeIndex the relative index
     */
    public void jsxFunction_go(final int relativeIndex) {
        final WebWindow w = getWindow().getWebWindow();
        try {
            w.getHistory().go(relativeIndex);
        }
        catch (final IOException e) {
            Context.throwAsScriptRuntimeEx(e);
        }
    }
View Full Code Here

                // If we're just setting or modifying the hash, avoid a server hit.
                jsxSet_hash(newLocation);
                return;
            }

            final WebWindow webWindow = getWindow().getWebWindow();
            webWindow.getWebClient().download(webWindow, "", new WebRequestSettings(url), "JS set location");
        }
        catch (final MalformedURLException e) {
            LOG.error("jsxSet_location('" + newLocation + "') Got MalformedURLException", e);
            throw e;
        }
View Full Code Here

        document_ = new HTMLDocument();
        document_.setPrototype(openerJSWindow.getPrototype(HTMLDocument.class));
        document_.setParentScope(this);

        final WebWindow openerWindow = openerJSWindow.getWebWindow();
        // create the "page" associated to the document
        final WebWindow popupPseudoWindow = new PopupPseudoWebWindow(openerWindow.getWebClient());
        // take the WebResponse of the opener (not really correct, but...)
        final WebResponse webResponse = openerWindow.getEnclosedPage().getWebResponse();
        final HtmlPage popupPage = new HtmlPage(null, webResponse, popupPseudoWindow);
        setDomNode(popupPage);
        popupPseudoWindow.setEnclosedPage(popupPage);
        final HtmlHtml html = (HtmlHtml) HTMLParser.getFactory(HtmlHtml.TAG_NAME).createElement(
                popupPage, HtmlHtml.TAG_NAME, null);
        popupPage.appendChild(html);
        final HtmlBody body = (HtmlBody) HTMLParser.getFactory(HtmlBody.TAG_NAME).createElement(
                popupPage, HtmlBody.TAG_NAME, null);
View Full Code Here

     * @throws FailingHttpStatusCodeException if the server returns a failing status code AND the property
     * {@link WebClient#setThrowExceptionOnFailingStatusCode(boolean)} is set to true.
     */
    @Override
    public void initialize() throws IOException, FailingHttpStatusCodeException {
        final WebWindow enclosingWindow = getEnclosingWindow();
        if (getWebResponse().getRequestSettings().getUrl() == WebClient.URL_ABOUT_BLANK) {
            // a frame contains first a faked "about:blank" before its real content specified by src gets loaded
            if (enclosingWindow instanceof FrameWindow
                    && getWebResponse().getRequestSettings().getUrl() == WebClient.URL_ABOUT_BLANK
                    && !((FrameWindow) enclosingWindow).getFrameElement().isContentLoaded()) {
                return;
            }

            // save the URL that should be used to resolve relative URLs in this page
            if (enclosingWindow instanceof TopLevelWindow) {
                final TopLevelWindow topWindow = (TopLevelWindow) enclosingWindow;
                final WebWindow openerWindow = topWindow.getOpener();
                if (openerWindow != null && openerWindow.getEnclosedPage() != null) {
                    baseUrl_ = openerWindow.getEnclosedPage().getWebResponse()
                    .getRequestSettings().getUrl();
                }
            }
        }
        loadFrames();
View Full Code Here

     */
    public URL getFullyQualifiedUrl(String relativeUrl) throws MalformedURLException {
        URL baseUrl;
        if (base_ == null) {
            baseUrl = getWebResponse().getRequestSettings().getUrl();
            final WebWindow window = getEnclosingWindow();
            final boolean frame = (window != window.getTopWindow());
            if (frame) {
                final boolean frameSrcIsNotSet = (baseUrl == WebClient.URL_ABOUT_BLANK);
                final boolean frameSrcIsJs = "javascript".equals(baseUrl.getProtocol());
                final boolean jsFrameUseParentUrl = getWebClient().getBrowserVersion()
                    .hasFeature(BrowserVersionFeatures.JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW);
                if (frameSrcIsNotSet || (frameSrcIsJs && jsFrameUseParentUrl)) {
                    baseUrl = ((HtmlPage) window.getTopWindow().getEnclosedPage()).getWebResponse()
                        .getRequestSettings().getUrl();
                }
            }
            else if (baseUrl_ != null) {
                baseUrl = baseUrl_;
View Full Code Here

        if (!getWebClient().isJavaScriptEnabled()) {
            return true;
        }

        // Execute the specified event on the document element.
        final WebWindow window = getEnclosingWindow();
        final Window jsWindow = (Window) window.getScriptObject();
        if (jsWindow != null) {
            final HtmlElement element = getDocumentElement();
            final Event event = new Event(element, eventType);
            element.fireEvent(event);
            if (!isOnbeforeunloadAccepted(this, event)) {
View Full Code Here

     */
    private void executeRefreshIfNeeded() throws IOException {
        // If this page is not in a frame then a refresh has already happened,
        // most likely through the JavaScript onload handler, so we don't do a
        // second refresh.
        final WebWindow window = getEnclosingWindow();
        if (window == null) {
            return;
        }

        final String refreshString = getRefreshStringOrNull();
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.WebWindow

Copyright © 2018 www.massapicom. 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.