net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableScript Java Examples

The following examples show how to use net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableScript. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebClientUtils.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Attaches a visual (GUI) debugger to the specified client.
 * @param client the client to which the visual debugger is to be attached
 * @see <a href="http://www.mozilla.org/rhino/debugger.html">Mozilla Rhino Debugger Documentation</a>
 */
public static void attachVisualDebugger(final WebClient client) {
    final ScopeProvider sp = null;
    final HtmlUnitContextFactory cf = ((JavaScriptEngine) client.getJavaScriptEngine()).getContextFactory();
    final Main main = Main.mainEmbedded(cf, sp, "HtmlUnit JavaScript Debugger");
    main.getDebugFrame().setExtendedState(Frame.MAXIMIZED_BOTH);

    final SourceProvider sourceProvider = new SourceProvider() {
        @Override
        public String getSource(final DebuggableScript script) {
            String sourceName = script.getSourceName();
            if (sourceName.endsWith("(eval)") || sourceName.endsWith("(Function)")) {
                return null; // script is result of eval call. Rhino already knows the source and we don't
            }
            if (sourceName.startsWith("script in ")) {
                sourceName = StringUtils.substringBetween(sourceName, "script in ", " from");
                for (final WebWindow ww : client.getWebWindows()) {
                    final WebResponse wr = ww.getEnclosedPage().getWebResponse();
                    if (sourceName.equals(wr.getWebRequest().getUrl().toString())) {
                        return wr.getContentAsString();
                    }
                }
            }
            return null;
        }
    };
    main.setSourceProvider(sourceProvider);
}
 
Example #2
Source File: DebuggerImpl.java    From htmlunit with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public DebugFrame getFrame(final Context cx, final DebuggableScript functionOrScript) {
    return new DebugFrameImpl(functionOrScript);
}
 
Example #3
Source File: DebuggerAdapter.java    From htmlunit with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void handleCompilationDone(final Context cx, final DebuggableScript functionOrScript, final String source) {
    // Empty.
}
 
Example #4
Source File: DebuggerAdapter.java    From htmlunit with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public DebugFrame getFrame(final Context cx, final DebuggableScript fnOrScript) {
    return new DebugFrameAdapter();
}
 
Example #5
Source File: DebuggerImpl.java    From HtmlUnit-Android with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public DebugFrame getFrame(final Context cx, final DebuggableScript functionOrScript) {
    return new DebugFrameImpl(functionOrScript);
}
 
Example #6
Source File: DebuggerAdapter.java    From HtmlUnit-Android with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void handleCompilationDone(final Context cx, final DebuggableScript functionOrScript, final String source) {
    // Empty.
}
 
Example #7
Source File: DebuggerAdapter.java    From HtmlUnit-Android with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public DebugFrame getFrame(final Context cx, final DebuggableScript fnOrScript) {
    return new DebugFrameAdapter();
}
 
Example #8
Source File: CallStackFrame.java    From jenkins-test-harness with MIT License 4 votes vote down vote up
public CallStackFrame(JavaScriptDebugger owner, DebuggableScript fnOrScript) {
    this.owner = owner;
    this.fnOrScript = fnOrScript;
}
 
Example #9
Source File: JavaScriptDebugger.java    From jenkins-test-harness with MIT License 4 votes vote down vote up
public void handleCompilationDone(Context cx, DebuggableScript fnOrScript, String source) {
}
 
Example #10
Source File: JavaScriptDebugger.java    From jenkins-test-harness with MIT License 4 votes vote down vote up
public DebugFrame getFrame(Context cx, DebuggableScript fnOrScript) {
    return new CallStackFrame(this,fnOrScript);
}
 
Example #11
Source File: DebugFrameImpl.java    From htmlunit with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new debug frame.
 *
 * @param functionOrScript the function or script to which this frame corresponds
 */
public DebugFrameImpl(final DebuggableScript functionOrScript) {
    functionOrScript_ = functionOrScript;
}
 
Example #12
Source File: DebugFrameImpl.java    From HtmlUnit-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new debug frame.
 *
 * @param functionOrScript the function or script to which this frame corresponds
 */
public DebugFrameImpl(final DebuggableScript functionOrScript) {
    functionOrScript_ = functionOrScript;
}