fix NPE when using the debugger

This commit is contained in:
Wouter Groeneveld 2011-06-28 14:12:29 +02:00
parent 2ce4f02f97
commit 9aca411bbd
2 changed files with 121 additions and 121 deletions

View File

@ -9,6 +9,7 @@ import org.junit.Before;
import org.junit.runner.Description;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunNotifier;
import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.NativeArray;
import org.mozilla.javascript.tools.debugger.Main;
@ -35,7 +36,7 @@ public class JasmineTestRunner extends Runner {
Main debugger = null;
if (this.suiteAnnotation.debug()) {
debugger = this.rhinoContext.createDebugger();
debugger = createDebugger();
}
this.rhinoContext = setUpRhinoScope();
@ -62,6 +63,23 @@ public class JasmineTestRunner extends Runner {
context.evalJS("jasmine.getEnv().addReporter(new jasmine.DelegatorJUnitReporter());");
}
private Main createDebugger() {
Main debugger = new Main("JS Debugger");
debugger.setExitAction(new Runnable() {
public void run() {
System.exit(0);
}
});
debugger.attachTo(ContextFactory.getGlobal());
debugger.pack();
debugger.setSize(600, 460);
debugger.setVisible(true);
return debugger;
}
private JasmineSuite getJasmineSuiteAnnotationFromTestClass() {
JasmineSuite suiteAnnotation = testClass.getAnnotation(JasmineSuite.class);
if (suiteAnnotation == null) {

View File

@ -5,7 +5,6 @@ import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.tools.debugger.Main;
import org.mozilla.javascript.tools.shell.Global;
public class RhinoContext {
@ -134,21 +133,4 @@ public class RhinoContext {
public void exit() {
Context.exit();
}
public Main createDebugger() {
Main debugger = new Main("JS Rhino Debugger");
debugger.setExitAction(new Runnable() {
public void run() {
System.exit(0);
}
});
debugger.attachTo(ContextFactory.getGlobal());
debugger.pack();
debugger.setSize(600, 460);
debugger.setVisible(true);
return debugger;
}
}