com.opera.core.systems.scope
Class AbstractEcmascriptService

java.lang.Object
  extended by com.opera.core.systems.scope.AbstractService
      extended by com.opera.core.systems.scope.AbstractEcmascriptService
All Implemented Interfaces:
IEcmaScriptDebugger
Direct Known Subclasses:
EcmaScriptDebugger, EcmascriptService

public abstract class AbstractEcmascriptService
extends AbstractService
implements IEcmaScriptDebugger


Field Summary
protected  int activeWindowId
          The window our current runtime is contained in.
protected  String currentFramePath
          The frame our current runtime is contained in.
protected  OperaDriver driver
           
protected  int retries
          The number of times we've attempted to retrieve a response from an injected JavaScript sent to the browser.
protected  RuntimeNode root
           
protected  long sleepDuration
          Defines for how long to sleep when retrying to execute a JS command.
protected  IWindowManager windowManager
          The window manager we are using.
 
Fields inherited from class com.opera.core.systems.scope.AbstractService
services
 
Constructor Summary
AbstractEcmascriptService(ScopeServices services, String version)
           
 
Method Summary
protected  String buildEvalString(List<org.openqa.selenium.WebElement> elements, String script, Object... params)
          Build the script to send with arguments.
 void cleanUpRuntimes()
          Cleanup runtimes with the active window id
 String executeJavascript(String using)
          Execute a script and wait for response
 String executeJavascript(String using, boolean responseExpected)
          Execute a script, this method allows fine tuning of responses, we are not interested in return value in some injections
protected  boolean isNumber(String name)
           
protected  Object parseNumber(String value)
           
protected  void processArgument(Object object, StringBuilder builder, List<org.openqa.selenium.WebElement> elements)
           
protected  void recover()
           
protected  void resetCounters()
          Reset the timeout and retries.
 void setDriver(OperaDriver driver)
          Set the driver this service belongs to.
 
Methods inherited from class com.opera.core.systems.scope.AbstractService
buildPayload, executeCommand, executeCommand, getVersion, isVersionInRange, sleep, xpathIterator, xpathPointer, xpathQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.opera.core.systems.scope.services.IEcmaScriptDebugger
addRuntime, callFunctionOnObject, callFunctionOnObject, changeRuntime, changeRuntime, cleanUpRuntimes, examineObjects, examineScriptResult, executeJavascript, executeScript, executeScriptOnObject, getObject, getRuntimeId, init, listFramePaths, readyStateChanged, releaseObject, releaseObjects, removeRuntime, resetFramePath, resetRuntimesList, scriptExecutor, setRuntime, updateRuntime
 

Field Detail

retries

protected int retries
The number of times we've attempted to retrieve a response from an injected JavaScript sent to the browser.


sleepDuration

protected long sleepDuration
Defines for how long to sleep when retrying to execute a JS command. It will be linearly increased using OperaIntervals.SCRIPT_RETRY_INTERVAL.


windowManager

protected IWindowManager windowManager
The window manager we are using.


currentFramePath

protected String currentFramePath
The frame our current runtime is contained in.


activeWindowId

protected int activeWindowId
The window our current runtime is contained in.


driver

protected OperaDriver driver

root

protected RuntimeNode root
Constructor Detail

AbstractEcmascriptService

public AbstractEcmascriptService(ScopeServices services,
                                 String version)
Method Detail

setDriver

public void setDriver(OperaDriver driver)
Description copied from interface: IEcmaScriptDebugger
Set the driver this service belongs to. Needed so that we can create OperaWebElements in this service.

Specified by:
setDriver in interface IEcmaScriptDebugger

resetCounters

protected void resetCounters()
Reset the timeout and retries. It will use the OperaIntervals.SCRIPT_RETRY_INTERVAL as the default value of the sleep interval sleepDuration.


buildEvalString

protected String buildEvalString(List<org.openqa.selenium.WebElement> elements,
                                 String script,
                                 Object... params)
Build the script to send with arguments.

Parameters:
elements - the web elements to send with the script as argument
script - the script to execute, can have references to argument(s)
params - params to send with the script, will be parsed in to arguments
Returns:
the script to be sent to Eval command for execution

processArgument

protected void processArgument(Object object,
                               StringBuilder builder,
                               List<org.openqa.selenium.WebElement> elements)

executeJavascript

public String executeJavascript(String using)
Description copied from interface: IEcmaScriptDebugger
Execute a script and wait for response

Specified by:
executeJavascript in interface IEcmaScriptDebugger
Parameters:
using - script to execute

executeJavascript

public String executeJavascript(String using,
                                boolean responseExpected)
Description copied from interface: IEcmaScriptDebugger
Execute a script, this method allows fine tuning of responses, we are not interested in return value in some injections

Specified by:
executeJavascript in interface IEcmaScriptDebugger
Parameters:
using - script to execute
responseExpected - if true parse the response
Returns:
String representation of the response

recover

protected void recover()

parseNumber

protected Object parseNumber(String value)

isNumber

protected boolean isNumber(String name)

cleanUpRuntimes

public void cleanUpRuntimes()
Description copied from interface: IEcmaScriptDebugger
Cleanup runtimes with the active window id

Specified by:
cleanUpRuntimes in interface IEcmaScriptDebugger


Copyright © 2012. All Rights Reserved.