Example #1
0
        /// <summary>
        /// This code (and the two methods above) were taken from https://bitbucket.org/duanyao/moz-devtools-patch
        /// with thanks to Duane Yao.
        /// It starts up a server that allows FireFox to be used to inspect and debug the content of geckofx windows.
        /// See the ReadMe in remoteDebugging for instructions.
        /// Note that this should NOT be done in production. There are security issues.
        /// </summary>
        static void StartDebugServer()
        {
            GeckoPreferences.User["devtools.debugger.remote-enabled"] = true;

            // It seems these files MUST be in a subdirectory of the application directory. At least, I haven't figured out
            // how it can be anywhere else. Therefore the build copies the necessary files there.
            // If you try to change it, be aware that the chrome.manifest file contains the name of the parent folder;
            // if you rename the folder and don't change the name there, you get navigation errors in the code below and
            // remote debugging doesn't work.
            var chromeDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "remoteDebugging");
            registerChromeDir(chromeDir);
            _debugServerStarter = new GeckoWebBrowser();
            _debugServerStarter.NavigationError += (s, e) => {
                Console.WriteLine(">>>StartDebugServer error: " + e.ErrorCode.ToString("X"));
                _debugServerStarter.Dispose();
                _debugServerStarter = null;
            };
            _debugServerStarter.DocumentCompleted += (s, e) => {
                Console.WriteLine(">>>StartDebugServer complete");
                _debugServerStarter.Dispose();
                _debugServerStarter = null;
            };
            _debugServerStarter.Navigate("chrome://remoteDebugging/content/moz-remote-debug.html");
        }