“IE” script context

Each script context contains its own global object, distinct from the global object in other script contexts.

Many Chakra hosting APIs require an "active" script context, which can be set using Current. Chakra hosting APIs that require a current context to be set will note that explicitly in their documentation.

Exemple #1
0
        /// <summary>
        /// Constructs an instance of the Chakra “IE” JsRT JavaScript engine
        /// </summary>
        /// <param name="enableDebugging">Flag for whether to enable script debugging features</param>
        public ChakraIeJsRtJsEngine(bool enableDebugging)
            : base(JsEngineMode.ChakraIeJsRt, enableDebugging)
        {
            _dispatcher.Invoke(() =>
            {
                try
                {
                    _jsRuntime = CreateJsRuntime();
                    _jsContext = _jsRuntime.CreateContext();
                }
                catch (JsUsageException e)
                {
                    string errorMessage;
                    if (e.ErrorCode == JsErrorCode.WrongThread)
                    {
                        errorMessage = CommonStrings.Runtime_JsEnginesConflictOnMachine;
                    }
                    else
                    {
                        errorMessage = string.Format(CommonStrings.Runtime_IeJsEngineNotLoaded,
                                                     _engineModeName, LOWER_IE_VERSION, e.Message);
                    }

                    throw new JsEngineLoadException(errorMessage, _engineModeName);
                }
                catch (Exception e)
                {
                    throw new JsEngineLoadException(
                        string.Format(CommonStrings.Runtime_IeJsEngineNotLoaded,
                                      _engineModeName, LOWER_IE_VERSION, e.Message), _engineModeName);
                }
            });
        }
Exemple #2
0
        public override object Evaluate(string expression)
        {
            object result = InvokeScript(() =>
            {
                IeJsValue resultValue = IeJsContext.RunScript(expression);

                return(MapToHostType(resultValue));
            });

            return(result);
        }
Exemple #3
0
        public override object Evaluate(string expression, string documentName)
        {
            object result = InvokeScript(() =>
            {
                IeJsValue resultValue = IeJsContext.RunScript(expression, _jsSourceContext++, documentName);

                return(MapToHostType(resultValue));
            });

            return(result);
        }
Exemple #4
0
        protected override void InnerStartDebugging()
        {
            if (Utils.Is64BitProcess())
            {
                var processDebugManager64 = (IProcessDebugManager64) new ProcessDebugManager();
                IDebugApplication64 debugApplication64;
                processDebugManager64.GetDefaultApplication(out debugApplication64);

                IeJsContext.StartDebugging(debugApplication64);
            }
            else
            {
                var processDebugManager32 = (IProcessDebugManager32) new ProcessDebugManager();
                IDebugApplication32 debugApplication32;
                processDebugManager32.GetDefaultApplication(out debugApplication32);

                IeJsContext.StartDebugging(debugApplication32);
            }
        }
Exemple #5
0
 public override void Execute(string code, string documentName)
 {
     InvokeScript(() => IeJsContext.RunScript(code, _jsSourceContext++, documentName));
 }
Exemple #6
0
 public override void Execute(string code)
 {
     InvokeScript(() => IeJsContext.RunScript(code));
 }
 internal static extern JsErrorCode JsCreateContext(IeJsRuntime runtime, IDebugApplication32 debugSite, out IeJsContext newContext);
 internal static extern JsErrorCode JsContextRelease(IeJsContext reference, out uint count);
 internal static extern JsErrorCode JsContextAddRef(IeJsContext reference, out uint count);
 internal static extern JsErrorCode JsSetCurrentContext(IeJsContext context);
Exemple #11
0
 internal static extern JsErrorCode JsSetCurrentContext(IeJsContext context);
 /// <summary>
 /// Initializes a new instance of the <see cref="IeJsScope"/> struct
 /// </summary>
 /// <param name="context">The context to create the scope for</param>
 public IeJsScope(IeJsContext context)
 {
     _disposedFlag = new StatedFlag();
     _previousContext = IeJsContext.Current;
     IeJsContext.Current = context;
 }
Exemple #13
0
 internal static extern JsErrorCode JsGetCurrentContext(out IeJsContext currentContext);
Exemple #14
0
 internal static extern JsErrorCode JsCreateContext(IeJsRuntime runtime, IDebugApplication32 debugSite,
                                                    out IeJsContext newContext);
Exemple #15
0
 internal static extern JsErrorCode JsContextRelease(IeJsContext reference, out uint count);
Exemple #16
0
 internal static extern JsErrorCode JsContextAddRef(IeJsContext reference, out uint count);
Exemple #17
0
 internal static extern JsErrorCode JsGetRuntime(IeJsContext context, out IeJsRuntime runtime);
 internal static extern JsErrorCode JsGetCurrentContext(out IeJsContext currentContext);
 internal static extern JsErrorCode JsGetRuntime(IeJsContext context, out IeJsRuntime runtime);
		/// <summary>
		/// Initializes a new instance of the <see cref="IeJsScope"/> struct
		/// </summary>
		/// <param name="context">The context to create the scope for</param>
		public IeJsScope(IeJsContext context)
		{
			_disposed = false;
			_previousContext = IeJsContext.Current;
			IeJsContext.Current = context;
		}
Exemple #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IeJsScope"/> struct
 /// </summary>
 /// <param name="context">The context to create the scope for</param>
 public IeJsScope(IeJsContext context)
 {
     _disposedFlag       = new StatedFlag();
     _previousContext    = IeJsContext.Current;
     IeJsContext.Current = context;
 }