Debugging a Thunderbird extension - thunderbird

I'm working on a Thunderbird extension, and, unfortunately, can't sort out what's still valid from what's not. There's lots of stuff online, but, most of it is no longer applicable to recent Thunderbird.
At a minimum, I need a way of seeing log messages from the extension, so I can see what's working and what's not. Ideally, I'd like a full debug console. There is a reference on Stackoverflow to Thunderbird Developer Tools, but there doesn't seem to be a way to download them.
I'd also like to be able to execute Javascript that can reference my extension via the console. When I try this via Thunderbird's console, I get error messages. I get this even when using other people's extensions, so I have to assume that extensions are outside the scope of the console
How can I get visibility and interaction to a new Thunderbird extension?

2020 Update:
If you are writing a MailExtension (this is how WebExtension are called for Thunderbird) you should have a look at general debugging in WebExtensions, e.g. https://extensionworkshop.com/documentation/develop/debugging/
You should probably also take a look at the general developer documentation on MailExtension at https://developer.thunderbird.net/add-ons/about-add-ons
The thinks listed below there written for the Legacy Overlay Extension, which do not work in newer Thunderbird versions.
logging messages
As described in https://developer.mozilla.org/en-US/docs/Debugging_JavaScript, there exist 3 different consoles in Gecko. The one best accessible in Thunderbird is the Error Console. You can write messages to it through the nsIConsoleService. If you don't mind that the log messages show up as an error, you can also simply use Components.utils.reportError().
Another way is to log to the (native) console from which Thunderbird is started. This is done through dump().
The newest way to log messages is using the Log.jsm module. It is a very nice wrapper around the different logging methods, and my preferred way to log messages in Thunderbird.
Thunderbird Developer Tools
As you haven't linked to the reference, I'm not 100% sure, but I think you mean the possibility to remotely debug Thunderbird through Firefox. You don't need to download anything to use this, it is already integrated in Thunderbird.
execute Javascript that can reference my extension
Debugging Thunderbird remotely through Firefox gives also access to the console and Scratchpad in the Developer Tools. Both should have also access to the add-on.
You may also want to look at the Tiny JavaScript Debugger. It also allows the execution of arbitrary code while debugging.

Related

How to launch vscode debug configuration from the browser?

I have a test case reporting scheme delivered in HTML that is complex in its own right and not easily ported to a VSCode extension. I would like to launch a Debug Configuration for each failing test case from the browser displaying the report. I have already been able to modify the report and have added a copy/paste widget for each test case's associated command. However I would like to do something to the effect of:
Launch a service as a VSCode extension that can handle requests
Formulate those requests in a way that can dynamically create launch configurations
It may be that I am stuck writing a Debug Adapter without the bells and whistles of interacting with the report.
That being said, if this is a solved problem or has a framework for solving with VSCode (and I realize remote execution could be a Very Bad Thing for VSCode to allow), I have not been able to find it through an existing extension.
I welcome your ideas.
This is perhaps not as open ended as it sounds...my question ultimately is: can VSCode operate as a service to be requested by web interfaces? Even if it could be done via Localhost this would be a boon. If it can be done over ssh with authentication, that would also be a bonus.
One way of getting VSCode to handle requests would be by invoking a vscode:// URI. This requires your extension to implement a URI handler. After the mandatory parts of the URI, you could have arbitrary data with whatever information you need.
Something that might or might not be an issue for your use case is that invoking such a URI triggers a popup in VSCode / doesn't work silently:
For dynamically creating launch configurations, you can use the vscode.debug.startDebugging() API.

How to send Chromium debugger a command (set breakpoint)?

I'm using an advanced text editor (but not a totally IDE) while developing web based applications, so I do rely on Chromium's debugger.
I want to provide an easier way to put a temporary breakpoints in the runtime via text editor's window.
All I need is to be able to send a breakpoint information in the runtime to the Chromium Debugger. Is there a way to achieve this?
You will either need to connect your text editor to the Chrome Developer Tools or write some small(ish) programs that connect to the Chrome Developer Tools and issue the appropriate setBreakpoint command.
Setting the breakpoint is basically just sending some JSON to the Chrome Developer Tools, but for that to work, you need to first ask Chrome for a Websocket connection, connect to that Websocket and then issue your command. There are various ways of automating the Chrome Developer Tools for Pyhon, NodeJS, C# and Perl (written by me), so if you can tell us what language you are comfortable in, we can likely suggest concrete libraries to do the communication with Chrome / Chromium for you.
See also
https://chromedevtools.github.io/devtools-protocol/tot/Debugger#method-setBreakpoint

Packaging a GWT app to run completely offline NOT installed via a "marketplace"

Theres a few questions similar to this, so I'll try to be clear as possible.
We have an existing, fairly large and complex, GWT webgame I have been asked to make work offline. It has to be offline in pretty much the strictest sense.
Imagine we have been told to make it work off a CD Rom.
So installation is allowed, but we cant expect the users to go to a Chrome/Firefox store and install it from there. It would need to be off the disc.
Likewise, altering of the browsers start-up flags would be unreasonable to expect of users.
Ideally, it would be nice if they just clicked a HTML file for the start page and it opened in their browsers of choice.
We successfully got it working this way in Firefox by adding;
"<add-linker name='xsiframe' />"
To our gwt.xml settings. This seems to solve any security issues FF has with local file access.
However, this does not solve the problem for Chrome.
The main game starts up, but various file requests are blocked due to security issues like these;
XMLHttpRequest cannot load file:///E:/Game%20projects/[Thorn]%20Game/ThornGame/text/messages_en.properties. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.MyApplication-0.js:34053 com_google_gwt_http_client_RequestBuilder_$doSend__Lcom_google_gwt_http_client_RequestBuilder_2Ljava_lang_String_2Lcom_google_gwt_http_client_RequestCallback_2Lcom_google_gwt_http_client_Request_2 MyApplication-0.js:34053
Now I was aware same origin policy issues might popup as during development we often tested locally using flags in chrome to bi-pass them.
Thing is...now I dont know how to get around them when we cant use startup flags.
Obviously in the example given its just the .properties file GWT uses to get some language related text. I could dump that inline in one way or another.
However, its only one of many,many,many files being blocked.
The whole game was made to run off *.txt game scripts on the sever - to allow easy updating by non-coders. Really the actual GWT code is just an "engine" and all the XMLHttpRequested files supply the actual "game".
These files are of various types; csv, txt, ntlist, jam.
The last two being custom extensions for what are really just txt files.
All these files are blocked by chromes security. It seems from what I can make out only images are allowed to be accessed locally.
Having all these files compiled in would just be impossible, as they are not fixed in number (ie, one central .txt file determains various scene .txt files which in turn determain various object files and directory's...).
Putting all this into a bundle would be nightmare to create and maintain.
So in essence I need some way to supply a offline version of a GWT project that can access a large number of various files in its subdirectories without security issues.
So far all I can think of is;
A) Theres something I can tell chrome via html or gwt that allows these files to be read in Chrome like FF can. (I suspect this isn't possible).
An alternative to XMLHttpRequest maybe?
B) I need to somehow package a game+a webbrowser in a executable package that has permission to access files in its directory's. (http://www.appcelerator.com/titanium ? ?? ).
C) I need to package and have the user run a full webserver that can then deliver all these files in a XMLHttp accessible way.
D) Bit of a funny one...we cant tell the user to add flags to browser start up...but Maybe I could write a game installer which just detects if they have Chrome or Firefox. It then opens up the games html in their browser with the correct flags for them? This would open up security issues if they browse elsewhere with that instance though, so Id presumably need other flags to disable the url bar if that's possible.
I am happy to make various changes to our code to achieve any of this - but as mentioned above theres no way to determain all the files needing to be accessed at compile time.
And finally, of course, it all has to be as easy as possible for the end user.
Ideally just clicking a html file, or installing something no more complex then a standard windows program.
Thanks for reading this rather long explanation, any pointers and ideas would be very welcome. I especially will appreciate multiple different options or feedback from anyone that's done this.
========================================
I accepted the suggestion to use Chromiumembedded below.
This works and does what I need (and much much more)
To help others that might want to use it, I specifically made two critical changes to the example project;
Because CEF needs a absolute path to the web apps local html, I wrote a c++ function to get the directory the .exe was launched from. This was a platform specific implementation, so if supporting a few OS's (which CEF does) be sure to write dedicated code for each.
Because my webapp will make use of local files, I enabled the Chrome flag for this by changing the browser settings;
browser_settings.file_access_from_file_urls = STATE_ENABLED;
These two changes were enough to get my app working, but it is obviously the bare minimum to make a application. Hopefully my finding will help others.
I'd suggest going the wrapper route. That is, provide a minimal browser implementation that opens your files directly. Options are Chromium Embedded[1]. If the nature of the application absolutely requires the files to be served as non-file urls then bundle a minimal webserver, have the on-disk executable start the server and open the bundled browser with whatever startup arguments you want.
[1] https://bitbucket.org/chromiumembedded/cef

How to remove codes generated by plugins from Chrome browser developers tool?

I'm using Google Chrome Developers tool and console while developing and debugging my web applications.
I've some Chrome plugins/extensions installed. These plugins/extensions add extra markups and scripts in the pages while rendering them in the browser, and when I view my codes in the developers tool, makes it a lot messy.
I want a clean way to view my codes without those extra markups.
So is there a way to toggle (disable/enable) the plugins quickly, or in the best way, to disable them in a particular tab? I've several plugins/extensions installed and I don't think it's a good idea to disable and then re-enable them manually.
Besides, I may want to use a plugin/extension while I'm browsing other websites on other tabs simultaneously.
There's no mechanism to disable an extension for a specific tab, or specific host. You could hack something together via the management API that would disable extensions when you hit a specific URL, but that disabled state would be global, not local.
Extensions don't, however, run in Incognito mode (unless you explicitly whitelist them via a checkbox at chrome://extensions): that might be a decent workaround for you. Load your in-development site in Incognito, work with it there in a clean environment, and pop back into your regular window for normal browsing.
You could, of course, accomplish the same thing by setting up a specific profile for development in which you simply didn't install extensions.
These are workarounds, of course. You should feel free to file a feature request for more granular user-side control over when extensions are loaded: http://new.crbug.com/
Would running 2 separate instances of Chrome be of help for you?
(You can start 2 unrelated Chrome browser instances from a command line specifying different user directories: chrome --user-data-dir=userdata1 & chrome --user-data-dir=userdata2 )
I haven't tried it for your usecase, but it sounds reasonable.

Auto-upload on save

I'm delveloping a PHP web application on my local PC. Whenever I save a file it would be handy if Eclipse could upload the file to my web server via FTP. Is Eclipse able to do that?? I think Netbeans offers such an option. At the moment I do the upload manually which is very annoying...
Take a look at Eclipse Target Management (RSE). You can find a tutorial on getting started page.
A big downside is that the quality of RSE's error messages range from okay-if-ambiguous to downright horrible (IBM-style 3 chars + 4 digits with no text message) so it's best if you know whatever protocol you're using well enough to guess what the error is without really needing the message to explain it to you.
So, after a whole lot of tries, I finally found something that works!
What you need to install is Eclipse WebDAV and FTP Support. I have not found the eclipse update site, but this site has n archived version of it. This allows you to sychronize your code with an FTP site.
http://eclipse.jcraft.com/
Then, to Automatically Upload On Save, you can use my Auto Hot Keys Script at:
Eclipse Synchronize Hotkeys