diff -r bb1e59f5cff3 -r 6193e735f4d1 rt/vm/src/test/java/org/apidesign/vm4brwsr/TestVM.java --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/TestVM.java Sat Oct 05 07:23:48 2013 +0200 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/TestVM.java Fri Oct 11 09:58:03 2013 +0200 @@ -24,23 +24,33 @@ import java.net.URL; import java.util.Enumeration; import javax.script.Invocable; +import javax.script.ScriptContext; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import static org.testng.Assert.*; -final class TestVM { +public final class TestVM { private final Invocable code; private final CharSequence codeSeq; private final Object bck2brwsr; + private BytesLoader resources; private TestVM(Invocable code, CharSequence codeSeq) throws ScriptException, NoSuchMethodException { this.code = code; this.codeSeq = codeSeq; - this.bck2brwsr = code.invokeFunction("bck2brwsr"); + this.bck2brwsr = ((ScriptEngine)code).eval("bck2brwsr(function(n) { return loader.get(n); })"); + ((ScriptEngine)code).getContext().setAttribute("loader", this, ScriptContext.ENGINE_SCOPE); } + public void register(BytesLoader res) { + this.resources = res; + } + + public byte[] get(String res) throws IOException { + return resources != null ? resources.get(res) : null; + } public Object execCode( String msg, Class clazz, String method,