Page tree
Skip to end of metadata
Go to start of metadata


This page is dedicated to things that we haven't found a better place for, but nonetheless people may need to know how to do =]

Getting the URL of the current page

This value is considered safe to rely upon but keep in mind that the browser can be tricked by DNS Spoofing, and XSS attacks can inject script from other domains.

Getting the value of GET variables from the query string

Getting the path and filename of the plugin (DLL, .so, or .dylib)

Using printf(.)-style debugging

Get Firebug for Firefox or use Chrome's built-in Console. The function you need is:
void FB::BrowserHost::htmlLog (const std::string& str)[virtual]


The message will appear in the JavaScript console. Please note that htmlLog(.) is really slow and should not be used in release builds and has been reported to not work on IE.

Storing and using JSAPI pointers

See FireBreath Tips: Dealing with JSAPI objects

Keeping your projects outside of the FireBreath directory

See FireBreath Tips: Working with Source Control (it's covered as part of this short article)

Keeping your FireBreath project in Source Control

See FireBreath Tips: Working with Source Control

Building your plugin on multiple systems

The main issue here that seems to confuse people is that the build/ directory should not be copied between systems!

See FireBreath Tips: Working with Source Control

Drawing and handling WINPROC events on Windows

See FireBreath Tips: Drawing on Windows

MacOSX: Check if event/draw model is available:

Using threads and javascript callbacks to make blocking system calls safe

See FireBreath Tips: Asynchronous Javascript Calls

Building a plugin without drawing support on Linux (removes gtk-dev dependency)

Starting with version v1.4 you can build your plugin without drawing support by adding the following to your PluginConfig.cmake:

Building a plugin without drawing support on Mac OSX

Starting with version v1.4 you can build your plugin without drawing support by adding the following to your PluginConfig.cmake:

Building FireBreath on Windows using Visual Studio Express edition

See Building with Visual Studio Express

Firefox 4 unpack option when bundling a plugin in an xpi

New in Firefox 4 A true or false value that tells the application whether the extension requires its files be unpacked into a directory in order to work or whether the extension can be loaded direct from the XPI. In versions before Gecko 2.0 all extensions were unpacked, in Gecko 2.0 and later the default is to not unpack. If an extension includes the following then it must request unpacking:

  • Binary XPCOM components
  • DLLs loaded with ctypes
  • Search plugins
  • Dictionaries
  • Window icons

See install manifest unpack option

MAC OS X: Disabling indexing in XCode 4

If you haven't big amount of RAM (< 8 GB), probably you will get lags during indexing your Firebreath project. Currently we don't know exactly why it's happening, but probably it's due to indexing templates in boost library by clang. One day this bug will be fixed by clang developers. If you can't upgrade your RAM and want to disable indexing, you may just type this in your Terminal:

chmod -R +w ~/Library/Developer/Xcode/DerivedData/

It will remove write permissions of your indexing directory and Xcode 4 will not be able to write there and indexing will stop automatically. This has not been tested on XCode 4.3 and later!

Blitting an pixel buffer to your plugin window in a platform agnostic way

There is an example of how GradeCam does this that can be found in this gist.

Modal Dialogs

Modal dialogs should never been used on the main thread. The following is a code example of using modal dialogs on windows and mac on an alternate thread. Note that there is some question as to whether doing this on Mac is actually a good idea or not.

Finding a safe place for file-based logging

On windows vista and 7 IE launches all plugins in protected mode when UAC is on, which prevents you from writing to most places on the drive. You can get access to LocalLow (or similar places on other systems). The following code sample works on Windows and Mac and is a great example of setting up a logfile for log4cplus.

Rendering a block of pixel data to the screen

Rendering raw pixel data to the screen is a pretty common use-case. Here are simple (non-accelerated) examples for both Mac and Windows:

Using HTTPService to create an embedded web server in the plugin

Not many need this, but for those who need it here is a code sample of setting up a simple embedded web server on your plugin. Note that you need to add the HTTPService firebreath library to use this.

MacOS X: CMake arguments to support 10.4

To deploy your plugin on MacOS X 10.4, add the following arguments to the end of your "" command line:


CMAKE_OSX_ARCHITECTURES tells Xcode to compile for 32-bit ppc and i386, and not for 64-bit x86-64.  CMAKE_OSX_DEPLOYMENT_TARGET tells Xcode to compile for 10.4 as the minimum acceptable OS version. 

If you also want to change the SDK that you use to 10.4, you'll need to add the following:


CMAKE_OSX_SYSROOT tells Xcode to change SDKs.  CMAKE_XCODE_ATTRIBUTE_GCC_VERSION tells Xcode to use gcc-4.0 instead of the default compiler; newer versions of the compiler are not compatible with the 10.4u SDK.  Note that the CMake documentation says to change the compiler version using "-D CMAKE_C_COMPILER=gcc-4.0 -D CMAKE_CXX_COMPILER=g++-4.0", but this doesn't work.

You'll need to be careful not to use operating system features not supported on 10.4.

Note that there is a space after the "-D".

MacOS X: CMake code to install plugin during build

The documentation discusses linking the plugin to the build location.  Xcode can also be configured to install (copy) the binary automatically after each build via the following CMake code, which should be added to the end of your <Project>/Mac/projectDef.cmake file.  Select the appropriate "releasePlugin" call to install either per-user or globally.

Visual Studio 2010: How to use pre-compiled headers for the plugin project

While some of the core modules of FireBreath already use pre-compiled headers ("PCH"), the generated plugin project does not do so. Here's a way how to setup a plugin project to use PCH:

  • Create a header file that includes often used modules (Windows API, FireBreath core etc.), that provides generally used macros, typedef's etc. VS2010 defaults to the name "stdafx.h", so that's a good choice for your project (but you can use any other name if you have other preferences).
  • Create a corresponding source file named "stdaxf.cpp" (or use the name that matches your choice) which consists of exactly one line of code:
  • Make sure that each source file of your plugin project starts with "#include stdafx.h" as first line of code (one exception s.below).
  • Now the file "CMakeLists.txt" and "Win/projectDef.cmake" of your plugin project must be modified. Here are examples that work as expected (allthough there may be other ways to achieve the same result - working PCH):
CMakeLists.txt  Expand source

Note: You can change or omit the "SOURCE_GROUP" definitions as you want.

Win/projectDef.cmake  Expand source


  • The use of "SOURCE_GROUP" definitions can be modified or omitted as you want.
  • The macro "ADD_MSVC_PRECOMPILED_HEADER" was taken from a cmake-file of the FireBreath core and was slightly modified.
  • The compiler option "/FI\"${__PrecompiledBinary}\"" forces the PCH file to be included in each source file during the compilation process. This way, one could omit "#include "stdafx.h", but this could confuse Visual Studio if it scans dependencies and builds the IntelleSense database (allthough IntelliSense seems to be unable to deal with FireBreath projects...). 

IID Instantiation

If your plugin uses any COM objects, then you'll need all required interface IDs (IIDs) to be instantiated in your plugin code, otherwise you'll get strange linker errors about unresolved references to objects like "_IID_IUnknown", "_IID_IDispatch", "_IID_YourOwnComInterface" etc. All you have to do is to create a simple source file (an appropriate name could be "iid.cpp"), that has two main properties: it defines "INITGUID" in the first line of code and it includes (explicitely or implicitely) all header files that provide the required interfaces IDs (windows.h, objbase.h, shlobj.h, ....). Because you need this specific "#define INITGUID" only here, the file "iid.cpp" cannot be compiled using PCH. This is what the macro "SET_IID_INSTANTIATION" in the above example does.

Fix build error with cmake 2.8.7 and Xcode 4.3

** If you're using XCode 4.3 or later and it isn't working, just update to the latest cmake. If you're using 4.5 or later you need cmake 2.8.10 or later.

Add custom build steps

CMake provides the ADD_CUSTOM_COMMAND and ADD_CUSTOM_TARGET to allow attaching pre-build or post-build steps to your build. They can be placed at the end of the platform's ProjectDef.cmake to accommodate the differences between implementations

For Visual Studio, the steps will be placed in the build events properties for the individual project inside the solution.

For Xcode, the command is put inside target_preBuildCommands.make or target_postBuildCommands and shows up in the Build Phases tab.

For Makefiles the ADD_CUSTOM_COMMAND must be paired with a ADD_CUSTOM_TARGET to work.

In most cases the ${MY_TARGET} would be replaced with ${PROJECT_NAME}. It refers to the target (in this case your plugin) that the dependencies are being added to.

This example runs a C program that generates a c++ header. The only difference between Windows and Mac was the requirement of the file extension ".exe". If the call runs a python script, Windows and Mac can be identical. In this example the executable is in a common tools folder by platform. ie MyTools/Win, MyTools/Mac, MyTools/Lin

Pre Build command added to ProjectDef.cmake

C code for this example.

VersionTagger.cpp  Expand source


Issues With Internet Explorer Enhanced Protected Mode

Some considerations to get your Add On to wotk within IE E.P.M. in Windows 8:


  1. Provide (and register) both: 32 and 64 bit DLLs;
  2. List AppContainer as Implemented Category [1] of your ActiveX;
    1. A simple way of doing so is by editing firebreath\gen_templates\FBControl.rgs, adding after the line containing "'Version' = s " the following
  3. Be ready to a very restrictive environment, with access denied to many paths;
    1. Remember you are running within AppContainter, at very low Integrity, with all UIPI implications;
  4. If you keep your DLL outside Program Files, you must add "All Application packages" group to the file's security permissions;
  5. Have a look at IE Protected Mode API:


  1. 64bit explorer bar issue with IE10 in desktop mode with Enhanced Protected Mode enabled -
  2. MSDN Blogs > IEBlog > Enhanced Protected Mode -
  3. Understanding and Working in Protected Mode Internet Explorer -
  4. A Developer's Survival Guide to IE Protected Mode By Michael Dunn, 20 May 2007 -
  5. Introduction to the Protected Mode API -
  6. Protected Mode Windows Internet Explorer Reference -
  7. Protected Mode Broker Functions -
  8. MSDN Blogs > IEBlog > Enhanced Protected Mode -
  9. MSDN Blogs > IEBlog > Enhanced Memory Protections in IE10 -
  10. MSDN Blogs > IEInternals > Understanding Enhanced Protected Mode -
  11. Microsoft KB 279459 :: BUG: Component Category Registry Entries Not Removed in ATL Component -
  12. Component Categories and How they Work -
  • No labels


  1. For 'Add custom build steps', the example uses 'MY_TARGET' a lot, but I'm uncertain what the target is intended to be within the FireBreath project. That should be clarified. Doing some minor editing on the C++ because of the deprecation of putenv as well.

    1. In most cases the ${MY_TARGET} would be replaced with ${PROJECT_NAME}. It refers to the target (in this case your plugin) that the dependencies are being added to.

  2. To disable XCode Indexing for version 4.6 enter the following in the terminal:
    defaults write IDEIndexDisable 1 

    Please notice that this affects all your XCode projects, but it can be undone entering the following command:
    defaults write IDEIndexDisable 0 

  3. Unknown User (msbuilder)

    Hi all

    I have a different problem with ver 1.4 , we register our dll in windows 8.1 64bit

    its register successfully but its didn`t work at all with the PBcontrol in (IE & Mozilla & Chorm)

    Pls guide me ,


    thank you

    1. This is not the place to ask support questions.  Try or the google group