Snippet testing with Firefox on Docker

Mozilla's Snippets Service feeds Firefox for Desktop and Android with small HTML or JSON blobs with content to display about:home page. That's the page users get when they open up Firefox.

Desktop snippets are usually a line of text and an icon but the service supports much more complicated snippets. Multiple choice forms for our end of year fund raising campaigns, videos about our mission, interactions with the browser Chrome and others. We even had a HTML5 game going once!

As the snippets increase more and more in complexity we need better ways to test them. Unfortunately we have limited automation for this but we made a big step towards a better snippet testing strategy:

Welcome Dockerized Firefox!

I created a Dockerfile that installs everything needed to run Firefox on Debian. Then I setup some basic prefs to prevent the browser from warning when closing multiple tabs, or asking to become the default browser. Finally I made it easy to setup a custom snippet server URL so you can point to your snippets server. Run docker build and voila! You can now run Firefox within Docker that instantly fetches snippets from your server. No need to reset the cache or open the DevTools to clear gSnippetsMap anymore. Restart the browser can you start fresh. ¡Viva Docker!

The GitHub repo is connected with Docker Registry and automatically builds Firefox images for all major releases starting from version 4.0. A bunch of convenience scripts make branch generation and update easier.

Fast testing

  1. Clone the fx-docker repository
  2. Copy ./bin/local_variables.sh-dist to ./bin/local_variables.sh and update SNIPPET_HOST to your host.
  3. Run ./bin/test.sh

The final step will sequentially start Firefox browsers from version 15.0 to the latest version. The browser gets auto-configured to fetch snippets from your server thus you only have to check that the snippet is OK and then close the browser window. In a moment the next Firefox version will appear.

You can avoid setting SNIPPET_HOST and test the production snippets against multiple versions of Firefox.

Using this you can test almost 30 different Firefox versions in ten minutes.

Links:

Go Top