How to debug Firefox add-on update - firefox-addon

I'm developing a migration update from XUL to Jetpack. I want to simulate the process on my local machine, make sure that everything works as expected when the versions change.
I followed all the steps of this tutorial:
http://www.borngeek.com/firefox/automatic-firefox-extension-updates/ in order to make a self hosted update version. But the extension won't update and I'm not getting any errors.
How can I debug, or at least initiate the update process for an add-on?

First of all, you should toggle on the extensions.logging.enabled preference. This will dump a lot of information about the update process and states into the Browser Console.
After enabling the preference, just open the Add-ons Manager UI and search for updates again.
But to test that stuff still works from going from one version to another, I would just install the old version (in a new profile) and then drop the new version XPI. This will trigger the same code paths as would have been triggered if the update XPI was retrieved over the network.

Related

Firefox add-on development: automatically reload add-on after code is changed

I'm developing Firefox add-on and problem is:
When I change code in add-on I must manually reload add-on folder in browser:
1. Go to about:debugging
2. Click on "Load temporary add-on" find add-on folder and open it
Question: Is there any way how to force Firefox to reload add-on folder on every code change? Somehow automatically?
Mozilla provides a command line tool called web-ext that allows you to run your extension in Firefox and reload automatically your code when the source files are modified.
The tool has many useful options that you can use to suit your needs, so I would recommend checking out the documentation page on MDN.
To get started quickly:
npm install --global web-ext
cd /path/to/your/webextension
web-ext run
Sadly, it is no possible. I develop the same way and had brought up the issue long time ago.
Files are Cached and not refreshed on Disable/Enable/Restart
Add Reload to installed addons in about:debugging
I have heard that it is possible with development scripts/environment but I don't use them.
Note: The background scripts (and anything that loads at start like _locales) are cached so they require restart but content scripts are not cached (well, cached per tab, you need to open a new tab).
Note that some content scripts are not cached, like addon's internal page such as pop-ups, option page etc so refreshing them will get the new version.

Service Worker: files are updated on the server but old version showing in browser

I am building a static app with PouchDB on Google AppEngine.
When I open the site in a browser window, it is showing a version I uploaded several hours ago.
If I open the site in an incognito window, the updated version is displayed (therefore I don't think it is actually an error in the console).
I put a new version number in app.yaml
I have migrated all traffic to the new version.
I have cleared my cache, deleted cookies, checked my application data, everything. I even reinstalled Chrome and Firefox.
I updated my Python version and my Google AppEngine Launcher yesterday; the problem pre-dated that update.
Also: just discovered that if I go to the URL of the updated version
http://4.[app-id].appspot.com, it displays the correct, updated version.
This is happening in Chrome, Firefox, and Edge.
Edit: probably should have mentioned that my site uses Service Workers and IndexedDB. I assume my service workers are caching the previous version, but I would have thought that Ctrl + F5 would clear the cache and show the new version.
I think it must be the Service Workers caching the pages (which is, after all, what they are supposed to do). This is actually really annoying when you are developing though.
A guy called Rich Harris has documented this behaviour and some workarounds on a Github Gist.
Reloading the page doesn't behave as you'd expect
If you make a change to your service worker, then reloading the page
won't kill the old one and activate the new one (it detects the change
by requesting the service worker file each time and comparing the old
and the new byte-for-byte), leaving you somewhat confused as to why
your changes haven't taken effect. This is because the old window is
never actually closed, meaning there's never a time to swap them out –
you need to kill the tab completely then reopen it.
Or you can have the browser do that for you by going to the
Application tab in devtools (in Canary, not stable Chrome yet), going
to the Service Workers section, and checking 'Update on reload'.
UPDATE (13 Nov 2017): This functionality is now available in Chrome, so you don't even need to download Canary.
And here's which bits of the application cache to clear:

Testing with JPM Run is Extremely Slow

I just recently switched from using the outdated cfx to jpm for developing my Firefox add-ons. Every time I make a change to my code and want to test it again, I have to use the "jpm run" command it literally takes 3 to 5 minutes to launch the browser with the new code inside. This makes it pretty much impossible to develop my add-on because, every time I want to test a new line of code, I have to wait several minutes.
This kind of problem doesn't occur in Chrome so I'm not sure what the people at Mozilla are thinking. Do they want to make it nearly impossible to develop add-ons for their browser?
What are other Firefox add-on developers doing to test their code? Do they just spend hours launching and relaunching the browser very very slowly? Or is there a workaround?
You can use jpm watchpost together with the extension auto-installer instead to auto-reload the extension in a running firefox session.
But even without that it should not not take minutes, only seconds.
As the8472 has mentioned, you can test Add-on SDK extensions without the need to restart the browser using jpm by using jpm watchpost. Using this appears to take a bit of configuring. I have not used this, as I would find having the add-on automatically updated upon every write to a file a bit annoying. I often change multiple files, or make multiple writes to the same file between the times I run the add-on to test. Basically, I want to maintain more control as to when the add-on is reloaded than to have it automatically done each time a file is changed.
There is a way to load temporary add-ons which works for both unpacked add-ons and .xpi files. The problem is that prior to running jpm, your add-on is not actually a complete Firefox add-on. jpm adds wrappers around the contents of your add-on to make it a normal bootstrapped add-on. Without those wrappers, your add-on will not function. One possibility would be to run jpm xpi each time you want to test a new version: Once you have initially loaded the add-on as a temporary add-on, you would run jpm xpi, then click on the "Reload" button for your add-on in about:debugging.
[This method will have issues which you will need to work through]: Alternately, you could unpack the .xpi file and continue your development from the files contained in the resulting directories while using the temporary add-on method of installing your add-on (click on any file in the directory where you unpacked the files to install as a temporary add-on). However, this method may prevent you from using jpm at all with your add-on. In addition, jpm performs somewhat different actions when packaging your add-on into an .xpi file depending on the contents of your add-on. If so, things may start to break if you significantly change your add-on's functionality (e.g. changes in package.json won't propagate to install.rdf). With this method, you would, probably, need to use a "normal", non-jpm method of creating an .xpi file when you want to publish your add-on.

Is Start (Dart framework) autoreload on the server side?

Is start (Dart server side framework) auto-refresh when one of our source code changed (just like PHP)?
Is bulls_eye, bloodless and express too?
or if they are not, is there any Dart server side framework that able to do that (edit code, then test on the browser, without needing to restart the dart/server program)?
Currently this is not yet possible in Dart. If you change the code you have to restart the app.
I wouldn't expect this to work anytime soon.
A main feature to make this possible is to manipulate the code at runtime. This is planned but as far as I know not yet started.
EDIT
The above mentioned feature is necessary when you want code to be updated without loosing the current state of the application but that is usually not so important on the server because it should be (mostly) stateless anyway.
In Dart there's no need to restart the server app when only the client part changes.
If you really just want to restart the entire server when the code changes you should be able to do that by yourself. Create a console app that loads the server app into an isolate (spawnUri) and watch the source directory for file changes. In the case of a file change shutdown the server-app-isolate and create a new one.

Testing multiple concurrent browser sessions

I'm developing a card-game in Ruby on Rails, and trying to work out how best to test it.
When a player joins a game, their Player object is stored in the session. Obviously, in order for the game to work, I need more than one Player in a game at once. Since sessions are the same for different tabs in one browser, I'm currently testing a 2-player game by having the app open in FireFox and Internet Explorer at the same time.
Before I go off and download Chrome in order to test a third player... is there an easier way of doing this?
Edit: To clarify, I'm not yet at the stage where I want to run automated tests to see if it breaks. I'm at the stage where I want to be able to hack the back-end db, then refresh the page and see how it looks now, or click a button to see the (usually) failure response, or whether the behaviour is looking right.
You can run Firefox with multiple profiles. From a command line go to the directory Firefox is installed in and run firefox -P. Create a profile for every instance that you want to run. Close the profile manager, then for each profile run firefox -no-remote -P "profile name". You can run as many instances of Firefox as you want, and each one runs with an independent profile and thus independent session.
Automate it!
You really don't want to be manually testing this. You could use a Ruby script with the curl libs to generate the 'moves' and manage the response including the session cookie.
As a teaser, see this snippet from the API docs, sounds like it would help you..
easy.cookiejar = "cookiejar.file" => "pwd string"
Set a cookiejar file to use for this Curl::Easy instance.
This file will be used to persist cookies.
Use http://watir.com/ to create ruby scripts exercising your game.
Use multiple Watir::Browser instances to run multiple browsers.
Use firefox' profiles and -no-remote switch to keep them separated. See also this question.
Rather than opening a new tab, create a new window in your Web browser. The new window will have its own session. This works for Internet Explorer, but not for Firefox. I haven't tested it in the WebKit based browsers.

Resources