IDL file: mozilla-central/source/dom/base/nsIMessageManager.idl

Inherits from: nsISupports

This interface is used by parent process message managers to load scripts into a child process. The scripts run only once per process. The global object for process scripts is a ContentProcessMessageManager.

Methods

void loadProcessScript(in AString aURL,
                       in boolean aAllowDelayedLoad)

void removeDelayedProcessScript(in AString aURL);
jsval getDelayedProcessScripts();

loadProcessScript()

Load a script in the child process. Process scripts are loaded as soon as loadProcessScript() is called.

If this function is called on a ChromeMessageBroadcaster, :

If this function is called on a ChromeMessageSender:

For example:

let ppmm = Services.ppmm.getChildAt(1);
ppmm.loadProcessScript('data:,dump("foo\n");', true);

Parameters

Name Type Description
aURL String URL for the script to load. aURL must be the absolute URL. data: URLs are also supported. For example data:,dump("foo\n");
aAllowDelayedLoad Boolean

If this flag is false, the process script will only be loaded into child processes that are already running at the time of the call.

If this flag is true, the process script will be loaded into any new child processes created after the loadProcessScript() call, until removeDelayedProcessScript() is called for that script.

If you are calling loadProcessScript() on a ChromeMessageSender, you should always pass true here.

removeDelayedProcessScript()

Removes aURL from the list of scripts which support delayed load.

This cancels the effect of the aAllowDelayedLoad flag, meaning that the loader will no longer load the script into new child processes. If you used aAllowDelayedLoad, you should call this as part of your cleanup (for example, when your add-on is disabled or uninstalled).

Parameters

Name Type Description
aURL String URL for the script to remove.

getDelayedProcessScripts()

Returns all delayed scripts that will be loaded once a child process becomes available. The return value is a list of pairs [<URL>, false].

Returns

List of the delayed scripts. Each script is returned as a pair: [<URL>, false].