Пример #1
0
        public TestContext(JSRuntime runtime = null)
        {
            Assert.IsTrue(JSAPI.IsInitialized);

            if (runtime == null)
            {
                Runtime     = new JSRuntime();
                OwnsRuntime = true;
            }
            else
            {
                Runtime     = runtime;
                OwnsRuntime = false;
            }

            Context          = new JSContext(Runtime);
            Request          = Context.Request();
            Global           = new JSGlobalObject(Context);
            CompartmentEntry = Context.EnterCompartment(Global);

            if (!JSAPI.InitStandardClasses(Context, Global))
            {
                throw new Exception("Failed to initialize standard classes");
            }
        }