class WebHtmlBrowser extends WebDriverWidget
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
WebHtmlBrowser.Handler
Handler implementation to allow hooking up navigation events.
|
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
effectiveContextPath
The effective context path
|
private java.lang.String |
effectiveResourceBase
The effective resource base
|
private java.lang.String |
generatedContextPath
The context-path which was generated based on a whitelisted entry
|
private java.net.URI |
generatedResourceBase
The resource-base which was generated based on a whitelisted entry
|
private org.eclipse.jetty.server.handler.ContextHandler |
handler
The custom handler for hooking up navigation events
|
private static java.lang.String |
HTML_MIME_TYPE
Default mime type
|
private boolean |
injectDriver
Driver injection flag.
|
private static CentralLogger |
LOG
logger
|
static java.lang.String |
P2J_HTMLBROWSER_DRIVER_JS
Name of the driver js file
|
static java.lang.String |
PARENT_ORIGIN
Parent-origin token
|
private static java.lang.String |
pwd
Process work dir
|
private static java.nio.charset.Charset |
UTF8
UTF-8 charset
|
visible, websock, widgetId, window| Constructor and Description |
|---|
WebHtmlBrowser(int widgetId,
GuiWebSocket websock)
Initialize the web component.
|
| Modifier and Type | Method and Description |
|---|---|
private org.apache.tika.metadata.Metadata |
autodetectContent(java.io.InputStream is)
Runs autodetection on the content represented by input stream.
|
void |
destroy()
Destroy the driver-specific widget.
|
private java.lang.String |
getContextPath()
Retrieve a context path specific for this web browser.
|
private java.lang.String |
getResourceBase()
Retrieve a resource base specific for this web browser.
|
private java.util.Map.Entry<java.lang.String,java.net.URI> |
getWhitelistEntry(java.net.URI path)
Check if a provided path is inside a whitelisted entry.
|
private void |
initHandler(java.lang.String localFile,
FileSystem fileSystem)
Parse the input resource and if this is an HTML read its base tag.
|
java.lang.Object |
invokeWidgetCommand(java.lang.String command,
java.lang.Object[] args)
Invokes a command on this widget.
|
private void |
openHTMLString(java.lang.String html)
Assigns the supplied string as the html content in the widget.
|
private boolean |
openUrl(java.lang.String urlString)
Open the specified URL.
|
private org.jsoup.nodes.Document |
parseHTML(java.io.InputStream in,
java.lang.String charset)
Attempts to parse the supplied input data as html content.
|
void |
placeWidget(NativeRectangle bounds)
Place the driver-specific widget at the specified bounds, using the currently selected
window.
|
private void |
resetHandler()
This resets the handlers for this browser and should be called when the state of the
CONTEXT-PATH or RESOUCE-BASE is changed.
|
boolean |
setWidgetAttribute(java.lang.String attr,
java.lang.String val)
Set an attribute for a widget implemented at the driver level.
|
private void |
transformHTML(java.io.InputStream inputHTML,
java.io.OutputStream outputHTML,
java.lang.String charset)
The HTML rendered on the Web client should have local hrefs resolved.
|
config, getWindow, setEnabled, setVisible, setWidgetBounds, setWindowclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinvokeWidgetCommandprivate static final CentralLogger LOG
private static final java.nio.charset.Charset UTF8
private static final java.lang.String HTML_MIME_TYPE
public static final java.lang.String PARENT_ORIGIN
public static final java.lang.String P2J_HTMLBROWSER_DRIVER_JS
private static final java.lang.String pwd
private org.eclipse.jetty.server.handler.ContextHandler handler
private java.lang.String generatedContextPath
private java.net.URI generatedResourceBase
private boolean injectDriver
private java.lang.String effectiveResourceBase
private java.lang.String effectiveContextPath
public WebHtmlBrowser(int widgetId,
GuiWebSocket websock)
widgetId - The widget's ID.websock - The web socket.public boolean setWidgetAttribute(java.lang.String attr,
java.lang.String val)
This works only for GUI drivers.
attr - The attribute name.val - The attribute's value.true if setting this attribute completed.public java.lang.Object invokeWidgetCommand(java.lang.String command,
java.lang.Object[] args)
command - The command to invoke.args - Optional event arguments.public void placeWidget(NativeRectangle bounds)
placeWidget in interface DriverWidgetplaceWidget in class WebDriverWidgetbounds - Widget bounds.public void destroy()
destroy in interface DriverWidgetdestroy in class WebDriverWidgetprivate void initHandler(java.lang.String localFile,
FileSystem fileSystem)
localFile - The local file representing the requested resource.fileSystem - File system resource.private boolean openUrl(java.lang.String urlString)
urlString - The URL to open.true if the open request is successfully passed to JS driver.private void openHTMLString(java.lang.String html)
html - The html string.private org.apache.tika.metadata.Metadata autodetectContent(java.io.InputStream is)
is - The stream to autodetect.private org.jsoup.nodes.Document parseHTML(java.io.InputStream in,
java.lang.String charset)
null is returned.in - The input data.java.io.IOExceptionprivate void transformHTML(java.io.InputStream inputHTML,
java.io.OutputStream outputHTML,
java.lang.String charset)
inputHTML - The file which contains the input HTML.outputHTML - The file in which we should dump a HTML with resolved hrefs.private java.util.Map.Entry<java.lang.String,java.net.URI> getWhitelistEntry(java.net.URI path)
null is returned.
This means that this path can't be made available through Web. Otherwise, a context-path is returned to
be mapped to the provided path as it is whitelisted.path - The path to be checked.null if this path can't be made available through Web. A context-path otherwise.private java.lang.String getContextPath()
private java.lang.String getResourceBase()
null.private void resetHandler()