public void CompileThenExecuteScript() { using (var tc = new TestContext()) { var scriptRoot = new Rooted <JSScriptPtr>(tc); Assert.IsTrue(JSAPI.CompileScript( tc, tc.Global, "function fn() { return global_v; }; global_v = 3;", JSCompileOptions.Default, scriptRoot )); Assert.IsTrue(scriptRoot.Value.IsNonzero); Assert.IsTrue(tc.Global["global_v"].IsNullOrUndefined); Assert.IsTrue(JSAPI.ExecuteScript(tc, tc.Global, scriptRoot)); Assert.AreEqual(3, tc.Global["global_v"].ToManaged(tc)); tc.Global["global_v"] = new JS.Value(5); var invokeResult = tc.Global["fn"].InvokeFunction(tc, JSHandleObject.Zero); Assert.AreEqual(5, invokeResult.Value.ToManaged(tc)); } }