Ejemplo n.º 1
0
 /// <summary>
 /// Returns the exception resulting from the last method call. This attribute
 /// exists only in the scope of the current CEF value object.
 /// </summary>
 public CefV8Exception GetException()
 {
     ThrowIfObjectIsInvalid();
     return(CefV8Exception.FromOrDefault(
                cef_v8value_t.invoke_get_exception(this.ptr)
                ));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Evaluates the specified JavaScript code using this context's global object.
        /// On success |retval| will be set to the return value, if any, and the
        /// function will return true. On failure |exception| will be set to the
        /// exception, if any, and the function will return false.
        /// </summary>
        public bool Eval(string code, out CefV8Value retval, out CefV8Exception exception)
        {
            cef_v8value_t *    n_retval    = null;
            cef_v8exception_t *n_exception = null;

            fixed(char *code_str = code)
            {
                var n_code = new cef_string_t(code_str, code != null ? code.Length : 0);

                var n_result = cef_v8context_t.invoke_eval(this.ptr, &n_code, &n_retval, &n_exception);

                if (n_result != 0)
                {
                    retval    = CefV8Value.From(n_retval);
                    exception = null;
                    return(true);
                }
                else
                {
                    retval    = null;
                    exception = CefV8Exception.From(n_exception);
                    return(false);
                }
            }
        }
        /// <summary>
        /// Called for global uncaught exceptions. Execution of this callback is
        /// disabled by default. To enable set
        /// CefSettings.uncaught_exception_stack_size &gt; 0.
        /// </summary>
        private void on_uncaught_exception(cef_v8context_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_v8context_t *context, cef_v8exception_t *exception, cef_v8stack_trace_t *stackTrace)
        {
            ThrowIfObjectDisposed();

            var m_browser    = CefBrowser.From(browser);
            var m_frame      = CefFrame.From(frame);
            var m_context    = CefV8Context.From(context);
            var m_exception  = CefV8Exception.From(exception);
            var m_stackTrace = CefV8StackTrace.From(stackTrace);

            this.OnUncaughtException(m_browser, m_frame, m_context, m_exception, m_stackTrace);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Evaluates the specified JavaScript code using this context's global object.
        /// On success |retval| will be set to the return value, if any, and the
        /// function will return true. On failure |exception| will be set to the
        /// exception, if any, and the function will return false.
        /// </summary>
        public bool Eval(string code, out CefV8Value retval, out CefV8Exception exception)
        {
            cef_v8value_t* n_retval = null;
            cef_v8exception_t* n_exception = null;
            fixed (char* code_str = code)
            {
                var n_code = new cef_string_t(code_str, code != null ? code.Length : 0);

                var n_result = cef_v8context_t.invoke_eval(this.ptr, &n_code, &n_retval, &n_exception);
                if (n_result != 0)
                {
                    retval = CefV8Value.From(n_retval);
                    exception = null;
                    return true;
                }
                else
                {
                    retval = null;
                    exception = CefV8Exception.From(n_exception);
                    return false;
                }
            }
        }
 /// <summary>
 /// Called for global uncaught exceptions. Execution of this callback is
 /// disabled by default. To enable set
 /// CefSettings.uncaught_exception_stack_size &gt; 0.
 /// </summary>
 protected abstract void OnUncaughtException(CefBrowser browser, CefFrame frame, CefV8Context context, CefV8Exception exception, CefV8StackTrace stackTrace);
 /// <summary>
 /// Called for global uncaught exceptions. Execution of this callback is
 /// disabled by default. To enable set
 /// CefSettings.uncaught_exception_stack_size &gt; 0.
 /// </summary>
 protected abstract void OnUncaughtException(CefBrowser browser, CefFrame frame, CefV8Context context, CefV8Exception exception, CefV8StackTrace stackTrace);