/** * Creates a new instance of HtmlUnitContextFactory. * * @param webClient the web client using this factory */ public HtmlUnitContextFactory(final WebClient webClient) { webClient_ = webClient; browserVersion_ = webClient.getBrowserVersion(); errorReporter_ = new StrictErrorReporter(); }
/** * Creates a new HTTP web connection instance. * @param webClient the WebClient that is using this connection */ public HttpWebConnection(final WebClient webClient) { webClient_ = webClient; htmlUnitCookieSpecProvider_ = new HtmlUnitCookieSpecProvider(webClient.getBrowserVersion()); usedOptions_ = new WebClientOptions(); }
/** * Creates a new instance of HtmlUnitContextFactory. * * @param webClient the web client using this factory */ public HtmlUnitContextFactory(final WebClient webClient) { WebAssert.notNull("webClient", webClient); webClient_ = webClient; browserVersion_ = webClient.getBrowserVersion(); errorReporter_ = new StrictErrorReporter(); }
/** * Creates a new instance of HtmlUnitContextFactory. * * @param webClient the web client using this factory */ public HtmlUnitContextFactory(final WebClient webClient) { WebAssert.notNull("webClient", webClient); webClient_ = webClient; browserVersion_ = webClient.getBrowserVersion(); errorReporter_ = new StrictErrorReporter(); }
private void initMSXMLActiveX() { msxmlActiveXObjectFactory_ = new MSXMLActiveXObjectFactory(); // TODO [IE] initialize in #init or in #initialize? try { msxmlActiveXObjectFactory_.init(getBrowserVersion()); } catch (final Exception e) { LOG.error("Exception while initializing MSXML ActiveX for the page", e); throw new ScriptException(null, e); // BUG: null is not useful. } }
/** * Creates an instance for the specified {@link WebClient}. * * @param webClient the client that will own this engine */ public JavaScriptEngine(final WebClient webClient) { webClient_ = webClient; contextFactory_ = new HtmlUnitContextFactory(webClient); initTransientFields(); jsConfig_ = JavaScriptConfiguration.getInstance(webClient.getBrowserVersion()); }
/** * Gets the browser version currently used. * @return the browser version */ public BrowserVersion getBrowserVersion() { final DomNode node = getDomNodeOrNull(); if (node != null) { return node.getPage().getWebClient().getBrowserVersion(); } return getWindow().getWebWindow().getWebClient().getBrowserVersion(); }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br> * * Helper for a common call sequence. * @param feature the feature to check * @return {@code true} if the currently emulated browser has this feature. */ public boolean hasFeature(final BrowserVersionFeatures feature) { return getPage().getWebClient().getBrowserVersion().hasFeature(feature); }
/** * {@inheritDoc} */ @Override public DisplayStyle getDefaultStyleDisplay() { if (getPage().getWebClient().getBrowserVersion().hasFeature(SLOT_CONTENTS)) { return DisplayStyle.CONTENTS; } return DisplayStyle.INLINE; } }
/** * Gets the browser version currently used. * @return the browser version */ protected BrowserVersion getBrowserVersion() { final DomNode node = getDomNodeOrNull(); if (node != null) { return node.getPage().getWebClient().getBrowserVersion(); } return getWindow().getWebWindow().getWebClient().getBrowserVersion(); }
/** * Adds the headers that are sent with every request to the specified {@link WebRequestSettings} instance. * @param wrs the <tt>WebRequestSettings</tt> instance to modify */ private void addDefaultHeaders(final WebRequestSettings wrs) { // Add standard HtmlUnit headers. wrs.setAdditionalHeader("Accept", "*/*"); wrs.setAdditionalHeader("Accept-Language", getBrowserVersion().getBrowserLanguage()); // Add user-specified headers last so that they can override HtmlUnit defaults. wrs.getAdditionalHeaders().putAll(requestHeaders_); }
/** {@inheritDoc} */ public void comment(final char[] ch, final int start, final int length) { handleCharacters(); final String data = String.valueOf(ch, start, length); if (!data.startsWith("[CDATA") || !page_.getWebClient().getBrowserVersion().isIE()) { final DomComment comment = new DomComment(page_, data); currentNode_.appendChild(comment); } }
/** * Adds the headers that are sent with every request to the specified {@link WebRequestSettings} instance. * @param wrs the <tt>WebRequestSettings</tt> instance to modify */ private void addDefaultHeaders(final WebRequestSettings wrs) { // Add standard HtmlUnit headers. wrs.setAdditionalHeader("Accept", "*/*"); wrs.setAdditionalHeader("Accept-Language", getBrowserVersion().getBrowserLanguage()); // Add user-specified headers last so that they can override HtmlUnit defaults. wrs.getAdditionalHeaders().putAll(requestHeaders_); }
/** {@inheritDoc} */ public void comment(final char[] ch, final int start, final int length) { handleCharacters(); final String data = String.valueOf(ch, start, length); if (!data.startsWith("[CDATA") || !page_.getWebClient().getBrowserVersion().isIE()) { final DomComment comment = new DomComment(page_, data); currentNode_.appendChild(comment); } }
/** * {@inheritDoc} */ @Override public boolean handles(final Event event) { if (MouseEvent.TYPE_MOUSE_OVER.equals(event.getType()) && getPage().getWebClient().getBrowserVersion().hasFeature(EVENT_ONMOUSEOVER_FOR_DISABLED_OPTION)) { return true; } return super.handles(event); } }
/** * {@inheritDoc} */ @Override public Page mouseOver(final boolean shiftKey, final boolean ctrlKey, final boolean altKey, final int button) { final SgmlPage page = getPage(); if (page.getWebClient().getBrowserVersion().hasFeature(EVENT_ONMOUSEOVER_NEVER_FOR_SELECT_OPTION)) { return page; } return super.mouseOver(shiftKey, ctrlKey, altKey, button); }
/** * {@inheritDoc} * @see SubmittableElement#setDefaultChecked(boolean) */ @Override public void setDefaultChecked(final boolean defaultChecked) { defaultCheckedState_ = defaultChecked; if (getPage().getWebClient().getBrowserVersion().isFirefox()) { setChecked(defaultChecked); } }
/** * {@inheritDoc} * @see SubmittableElement#setDefaultChecked(boolean) */ @Override public void setDefaultChecked(final boolean defaultChecked) { defaultCheckedState_ = defaultChecked; if (getPage().getWebClient().getBrowserVersion().isFirefox()) { setChecked(defaultChecked); } }
/** * {@inheritDoc} Also sets the value attribute when emulating Netscape browsers. * @see SubmittableElement#setDefaultValue(String) * @see HtmlFileInput#setDefaultValue(String) */ public void setDefaultValue(final String defaultValue) { final boolean modifyValue = getPage().getWebClient().getBrowserVersion().isFirefox(); setDefaultValue(defaultValue, modifyValue); }
private Worker(final Context cx, final Window owningWindow, final String url) throws Exception { setParentScope(owningWindow); setPrototype(getPrototype(getClass())); final WebClient webClient = getWindow().getWebWindow().getWebClient(); workerScope_ = new DedicatedWorkerGlobalScope(owningWindow, cx, webClient.getBrowserVersion(), this); workerScope_.loadAndExecute(url, null); }