use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement in project htmlunit by HtmlUnit.
the class TextRange method getHtmlText.
/**
* Retrieves the HTML fragment contained within the range.
* @return the HTML fragment contained within the range
*/
@JsxGetter
public String getHtmlText() {
final org.w3c.dom.Node node = range_.getCommonAncestorContainer();
if (null == node) {
return "";
}
final HTMLElement element = (HTMLElement) getScriptableFor(node);
// TODO: not quite right, but good enough for now
return element.getOuterHTML();
}
use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement in project htmlunit by HtmlUnit.
the class MouseEvent method getScreenY.
/**
* The vertical coordinate at which the event occurred relative to the origin of the screen
* coordinate system. The value of this attribute is initialized lazily, in order to optimize
* performance (it requires CSS parsing).
*
* @return the vertical coordinate
*/
@JsxGetter
public int getScreenY() {
if (screenY_ == null) {
final HTMLElement target = (HTMLElement) getTarget();
screenY_ = Integer.valueOf(target.getPosY() + 10);
}
return screenY_.intValue();
}
use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement in project htmlunit by HtmlUnit.
the class HtmlTableRowTest method cellScriptObjectIsReturnedByScript.
/**
* Ensure that the JavaScript object returned by the script fragment is the
* same one the DOM node thinks it's wrapped by.
*/
@Test
public void cellScriptObjectIsReturnedByScript() {
final String cmd = "document.getElementById('cell')";
final HTMLElement jselement = (HTMLElement) page_.executeJavaScript(cmd).getJavaScriptResult();
assertSame(jselement, cell_.getScriptableObject());
}
use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement in project htmlunit by HtmlUnit.
the class HtmlTableRowTest method scriptCanGetOriginalCell.
// these next few test our assumptions about how scripts affect the DOM
/**
* Ensure that the JavaScript object returned by the script fragment really
* refers to the same DOM node we think it should.
*/
@Test
public void scriptCanGetOriginalCell() {
final String cmd = "document.getElementById('cell')";
final Object object = page_.executeJavaScript(cmd).getJavaScriptResult();
final HtmlElement cellElement = ((HTMLElement) object).getDomNodeOrDie();
assertSame(cell_, cellElement);
}
use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement in project htmlunit by HtmlUnit.
the class HTMLCollectionFrames method scrollByLines.
/**
* Scrolls the window content down by the specified number of lines.
* @param lines the number of lines to scroll down
*/
@JsxFunction({ FF, FF_ESR })
public void scrollByLines(final int lines) {
final HTMLElement body = document_.getBody();
if (body != null) {
body.setScrollTop(body.getScrollTop() + (19 * lines));
final Event event = new Event(body, Event.TYPE_SCROLL);
body.fireEvent(event);
}
}
Aggregations