Default Profile Directory Doesn’t Work in Firefox 46

NOTE: I updated this code on April 18, 2017 in an attempt to be more robust and not depend on Firefox preference. If you are using remote autoconfig, make sure this code is in your local autoconfig, not in the remote version. And the correct directory for the default profile is defaults/profile, not defaults/browser/profile.

It was recently discovered that support for using the defaults/profile directory to prepopulate a Firefox profile was removed in Firefox 46.

Here’s an AutoConfig file that adds back the functionality:

const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

var profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
var certDBFile = profileDir.clone();
// If cert8.db isn't there, it's a new profile
if (!certDBFile.exists()) {
  var defaultProfileDir = Services.dirsvc.get("GreD", Ci.nsIFile);
  try {
    copyDir(defaultProfileDir, profileDir);
  } catch (e) {
function copyDir(aOriginal, aDestination) {
  var enumerator = aOriginal.directoryEntries;
  while (enumerator.hasMoreElements()) {
    var file = enumerator.getNext().QueryInterface(Components.interfaces.nsIFile);
    if (file.isDirectory()) {
      var subdir = aDestination.clone();
      try {
        subdir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
        copyDir(file, subdir);
      } catch (e) {
    } else {
      try {
        file.copyTo(aDestination, null);
      } catch (e) {

This should work for most file types, although it probably won’t work for bookmarks.html

I’ll also be adding this functionality to the next version of the CCK2 which will be released later today.

Broken Add-ons in Firefox 46

A lot of add-ons are being broken by a subtle change in Firefox 46, in particular the removal of legacy array/generator comprehension.

Most of these add-ons (including mine) did not use array comprehension intentionally, but they copied some code from this page on for doing an md5 hash of a string. It looked like this:

var s = [toHexString(hash.charCodeAt(i)) for (i in hash)].join("");

You should search through your source code for toHexString and make sure you aren’t using this. MDN was updated in January to fix this. Here’s what the new code looks like:

var s = Array.from(hash, (c, i) => toHexString(hash.charCodeAt(i))).join("");

The new code will only work in Firefox 32 and beyond. If for some reason you need an older version, you can go through the history of the page to find the array based version.

Using this old code will cause a syntax error, so it will cause much more breakage than you realize. You’ll want to get it fixed sooner than later because Firefox 46 started rolling out yesterday.

As a side note, Giorgio Maone caught this in January, but unfortunately all that was updated was the MDN page.

CCK2 Source on GitHub (and a new release)

I had put the original CCK Wizard on, but since I did the development of the CCK2 on my private SVN, I had never gone through the trouble of making the source available. It is technically open source, but I wasn’t doing enough to allow other people to contribute to the code. That changes today.

The CCK2 source is now available on GitHub under the MPL.

Nothing else about how I manage the CCK2 will change – I will still be using Freshdesk for support requests and I will still have premium support subscriptions. I will be using GitHub issues only for actual bugs in the CCK2.

When I do new releases of the CCK2, you’ll be able to get information about those releases on the releases page.

And speaking of new releases, I’ve just updated the CCK2 to fix a bug related to adding bookmarks with international characters. You can download it here.

Time For a (Job) Change

I’ve always been passionate about Firefox in the enterprise. When I started Kaply Consulting eight years ago, I had always hoped that my primary work would be around enterprise Firefox. Unfortunately, that never really happened; enterprise work is less than 5% of what I do. So I do a lot of other work to support the things that I’m most passionate about. As those obligations have become bigger and bigger, I’ve found less and less time to work on the CCK2 and other enterprise related projects which I believe are important to the future of Firefox.

At the same time, with the changes coming to the way extensions are done in Mozilla, I even wondered if I wanted to continue doing what I do. After watching a video of myself (skip to 6:30) speaking about Mozilla 11 years ago, I came to the conclusion that Mozilla is in my blood. Heck, I’ve been doing this stuff since before Mozilla even existed (can you say Netscape 2.0.2?)

Combined with the increasing costs of being self employed and the increasing needs of my family, I’ve decided the best way forward for me and my family is to become a company man again.

And what better company to work for then…


Yes, after years of working ON Mozilla, I’m finally working FOR Mozilla.

And I’m quite excited about the opportunity. I’ll be working on the partner distribution team at Mozilla.

I will continue to do enterprise work on the side as long as it doesn’t conflict with any of my Mozilla work, so there’s no need to worry about that. And since I won’t have to juggle as many things, I should have more free time to work on the CCK2.

TL;DR – I’m going to work for Mozilla. Kaply Consulting will still do CCK2 and enterprise.

My Best Year Ever

As 2015 comes to an end, it’s time to reflect back on the accomplishments of the previous year. For me personally and for Kaply Consulting, it was my best year ever.

  • I contributed more patches to Mozilla than I have in many years.
  • I grew my email list substantially.
  • I grew my business revenue by 10%.
  • I finally planned well enough to be able to take the last two weeks of the year off.

The major contributor to my success this year, was Michael Hyatt’s Five Days to Your Best Year Ever. If you’ve struggled in the past with goal setting, I highly recommend checking out his program. You can start with this free video.

Thank you to everyone who helped me have such a great year. Happy holidays and happy new year!

Disclaimer: I’m an affiliate partner, so if you click and purchase the program, I will receive an affiliate commission.

Identifying Preferences Names in Firefox

One question I get a lot is how to associate a preference option that you see in the Firefox preferences with the name of a preference to set or lock.

To make getting that information easier, I’ve made a very simple extension called Pref Helper that when installed highlights any item that has a corresponding preference in blue and shows that preference when you right click on the item. This should make it easy to find the preference name you are looking for.

Then you can set or lock it with the CCK2.

You can download it here.

Windows 10, Permission Manager and more

There are some changes coming to Firefox that might impact enterprise users, so i wanted to make folks aware of them.

Firefox 42 has a change to the permission manager so that permissions are based on the origin not just the host. This means that code like this in your AutoConfig file:

Services.perms.add(NetUtil.newURI("http://" + hostname), ...

will only apply to http. You need to be explicit with both:

Services.perms.add(NetUtil.newURI("http://" + hostname), ...
Services.perms.add(NetUtil.newURI("https://" + hostname), ...

Existing permissions will be migrated to both http and https. I’ve updated the CCK2 to account for this, but you’ll need to rebuild your distribution.

Firefox 44 has some major changes coming to JavaScript let/const behavior that could impact your AutoConfig file. I’ll be making sure the CCK2 is compatible, but you should make sure you’re testing with the latest Firefox 44. Obviously this will impact the Firefox 45 ESR as well, so you’ll want to do lots of testing there.

Finally, I got a question about the Firefox/Windows 10 page appearing even when you have upgrade pages turned off. Unfortunately this page bypasses the existing upgrade code. To make sure it doesn’t appear, set the preference browser.usedOnWindows10 to true.

Using Hidden UI in the CCK2

One of the questions I get asked the most is how to hide certain UI elements of Firefox. I implemented the Hidden UI feature of the CCK2 specifically to address this problem. Using it can be a little daunting, though, so I wanted to take some time to give folks the basics.

The Hidden UI feature relies on CSS selectors. We can use CSS Selectors to specify any element in the Firefox user interface and then that element will be hidden. The trick is figuring out the selectors. To accomplish this, my primary tool is the DOM Inspector. With the DOM Inspector, I can look at any element in the Firefox user interface and determine it’s ID. Once I have it’s ID, I can usually specify the CSS selector as #ID and I can hide that element. Let’s walk through using the DOM Inspector to figure out the ID of the home button.

  • Install the DOM Inspector
  • Go to Developer Tools and select DOM Inspector
  • From the DOM Inspector Window, select File->Inspect Chrome Document and select the first window
  • In the DOM Inspector Window, click on the Node Finder.
  • Click on the Home button in the Firefox Window.
  • You’ll see results in the DOM Inspector that look like this:

  • This gives us something unique we can use – an ID. So #home-button in Hidden UI will hide the home button.

    You can use this method for just about every aspect of the Firefox UI except for menus and the Australis panel. For these items, I turn to the Firefox source code.

    If you want to hide anything on the Australis panel, you can look for IDs here. If you want to hide anything on the Firefox context menu, you can look here. If you want to hide anything in the menu bar, you can look here.

    As a last resort, you can simply hide menuitems based on their text. For instance, if you wanted to hide the Customize menu that appears when you right click on a toolbar, you could specify a selector of menuitem[label^='Customize]. This says “Hide any menu item that begins with the word Customize.” Don’t try to include the ellipsis in your selector because in most cases it’s not …, it’s the unicode ellipsis (…). (Incidentally, that menu is defined here, along with the rest of the toolbar popup menu. Because it doesn’t have an ID, you’ll have to use menuitem.viewCustomizeToolbar.)

    Hopefully this should get everyone started. If there’s something you can’t figure out how to hide, let me know. And if you’re trying to hide everything, you should probably be looking at a kiosk solution, not the CCK2…

My Take on WebExtensions

Let me start out by saying that I understand the need for something like WebExtensions. A cross browser extension API will be a great thing for the future of browsers. I understand why Mozilla is doing it. What I take issue with is the belief that existing Firefox only add-on developers will jump at the opportunity to use this new API. As far as I’m concerned, the only add-on developers that will benefit from this new API are Chrome developers who will find it much easier to port their extensions to Firefox.

Most Firefox extension developers do it as a hobby. Typically they have an itch about something in Firefox and that write an extension to scratch it. Then they make that extension available to everyone. Over time we all build up a set of extensions that make Firefox behave the way we (and clearly other people) want it to. (Chris Finke is a great example of this.) Every so often something changes in Firefox that breaks one of our extensions. At that point we have to make a decision; it it worth the time and energy to keep this extension going. Sometimes we keep it going, sometimes we give up (hence the ton of dead extensions on AMO). Luckily most of the time Firefox changes don’t break all our extensions, so we usually can keep going. With e10s coming up though, lots of developers have had to make decisions as to whether or not it is worth it to rewrite and some developers have gone through that pain (and it is pain – a lot of pain).

Now developers are being told in the next one to two years they will have to completely rewrite ALL of their add-ons. What are the odds that these hobby add-on developers are going to do that?

Let’s be honest. Availability of APIs isn’t the difficult part of the discussion. Availability of time and energy to even attempt to rewrite all of our add-ons is the problem. And when you add in the fact that Mozilla hasn’t given add-on developers the marketplace we’ve been promised for years (which Chrome has had since day one), you’ll end up with a lot of developers deciding that it’s simply not worth it.

But let’s talk availability of APIs. I’ll use two of my extensions as examples. Keyword Search accesses the wrappedJSObject of search submissions in order to manipulate the submission. Will there really be an API for that? Or what about the CCK2? Will there really be APIs that allow me to modify the built-in preferences pages including removing pages or controls? Or what about disabling private browsing? Or removing sync? Or removing access to about:config? I doubt it. There are just too many things that extensions do (most of them pretty obscure) to be able to provide an complete API.

I’ll watch what goes on and hope that I’m wrong, but I’m not very optimistic.

I will say this, though. It’s a great day to be a Chrome developer.