Offering a context menu for form controls

Firefox 3 changed the behavior of right-click on form controls to no longer display a context menu by default. This article describes how an extension can override this change in a particular window, enabling context menus to work on form controls.

This code, which is run when the window is opened up, works by replacing the setTarget() routine for the prototype of nsContextMenu with one that forces the context menu to display if the target of the menu is a form control.

As a result, all controls in the window will support a context menu when right-clicked, since we've changed the core behavior of context menus to override their default behavior of doing nothing on form controls.