final ExecutionResult executionResult = state.execute(environment.getExecutor(), this);
if (executionResult == null) {
return AsyncResult.done(null);
}
final KarmaConsoleView consoleView = KarmaConsoleView.get(executionResult);
if (consoleView == null) {
throw new RuntimeException("KarmaConsoleView was expected!");
}
final KarmaServer karmaServer = consoleView.getKarmaExecutionSession().getKarmaServer();
if (karmaServer.areBrowsersReady()) {
final DebuggableWebBrowser debuggableWebBrowser =
new KarmaDebugBrowserSelector(karmaServer.getCapturedBrowsers(), environment).selectDebugEngine();
return prepareDebugger(environment.getProject(), debuggableWebBrowser, new RunProfileStarter() {
@Nullable
@Override
public RunContentDescriptor execute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
if (debuggableWebBrowser == null) {
return null;
}
final Url url = Urls.newFromEncoded(karmaServer.formatUrl("/debug.html"));
final DebuggableFileFinder fileFinder = getDebuggableFileFinder(karmaServer);
XDebugSession session = XDebuggerManager.getInstance(env.getProject()).startSession(
env,
new XDebugProcessStarter() {
@Override
@NotNull
public XDebugProcess start(@NotNull final XDebugSession session) {
JavaScriptDebugEngine debugEngine = debuggableWebBrowser.getDebugEngine();
WebBrowser browser = debuggableWebBrowser.getWebBrowser();
JSDebugProcess<?> debugProcess = debugEngine.createDebugProcess(session, browser, fileFinder, url, executionResult, true);
debugProcess.setElementsInspectorEnabled(false);
debugProcess.setLayouter(consoleView.createDebugLayouter(debugProcess));
return debugProcess;
}
}
);
return session.getRunContentDescriptor();