Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

nsIProcessScriptLoader

This article needs a technical review. How you can help.

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, :

  • it will load the process script into all child processes.
  • if aAllowDelayedLoad is true, then the script will also be loaded into any new child processes created after the loadProcessScript() call. Otherwise it will only be loaded into child processes that exist at the time of the call.

If this function is called on a ChromeMessageSender:

  • it will load the process script only into this ChromeMessageSender's child process
  • aAllowDelayedLoad should always be true. It's possible that the child process for this ChromeMessageSender is not yet available at the time of the loadProcessScript() call, and if you pass false in this situation, your process script won't be loaded.

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].

Document Tags and Contributors

 Contributors to this page: wbamberg
 Last updated by: wbamberg,