bootstrap.js

  • Revision slug: Extensions/bootstrap.js
  • Revision title: bootstrap.js
  • Revision id: 334811
  • Created:
  • Creator: Yoshino
  • Is current revision? No
  • Comment Updated links

Revision Content

The bootstrap.js script should contain several specific functions, which are called by the browser to manage the extension. The script gets executed in a privileged sandbox, which is cached until the extension is shut down. For more information, see Bootstrapped extensions.

The example below contains the required methods in vsdoc format.

function startup(data, reason) {
    /// <summary>
    /// Bootstrap data structure @see https://developer.mozilla.org/en-US/docs/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &#10;  string id
    /// &#10;  string version
    /// &#10;  nsIFile installPath
    /// &#10;  nsIURI resourceURI
    /// &#10;
    /// Reason types:
    /// &#10;  APP_STARTUP
    /// &#10;  ADDON_ENABLE
    /// &#10;  ADDON_INSTALL
    /// &#10;  ADDON_UPGRADE
    /// &#10;  ADDON_DOWNGRADE
    /// </summary>
}
function shutdown(data, reason) {
    /// <summary>
    /// Bootstrap data structure @see https://developer.mozilla.org/en-US/docs/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &#10;  string id
    /// &#10;  string version
    /// &#10;  nsIFile installPath
    /// &#10;  nsIURI resourceURI
    /// &#10;
    /// Reason types:
    /// &#10;  APP_SHUTDOWN
    /// &#10;  ADDON_DISABLE
    /// &#10;  ADDON_UNINSTALL
    /// &#10;  ADDON_UPGRADE
    /// &#10;  ADDON_DOWNGRADE
    /// </summary>
}
function install(data, reason) {
    /// <summary>
    /// Bootstrap data structure @see https://developer.mozilla.org/en-US/docs/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &#10;  string id
    /// &#10;  string version
    /// &#10;  nsIFile installPath
    /// &#10;  nsIURI resourceURI
    /// &#10;
    /// Reason types:
    /// &#10;  ADDON_INSTALL
    /// &#10;  ADDON_UPGRADE
    /// &#10;  ADDON_DOWNGRADE
    /// </summary>
}
function uninstall(data, reason) {
    /// <summary>
    /// Bootstrap data structure @see https://developer.mozilla.org/en-US/docs/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &#10;  string id
    /// &#10;  string version
    /// &#10;  nsIFile installPath
    /// &#10;  nsIURI resourceURI
    /// &#10;
    /// Reason types:
    /// &#10;  ADDON_UNINSTALL
    /// &#10;  ADDON_UPGRADE
    /// &#10;  ADDON_DOWNGRADE
    /// </summary>
}

Revision Source

<p>The <code>bootstrap.js</code> script should contain several specific functions, which are called by the browser to manage the extension. The script gets executed in a privileged sandbox, which is cached until the extension is shut down. For more information, see <a href="/en-US/docs/Extensions/Bootstrapped_extensions">Bootstrapped extensions</a>.</p>
<p>The example below contains the required methods in vsdoc format.</p>
<pre style="font-family:Consolas;font-size:13;color:black;background:white;">
<span style="color:blue;">function</span>&nbsp;startup(data,&nbsp;reason)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&lt;summary&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;Bootstrap&nbsp;data&nbsp;structure&nbsp;@see&nbsp;https://developer.mozilla.org/en-US/docs/Extensions/Bootstrapped_extensions#Bootstrap_data</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;string&nbsp;id</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;string&nbsp;version</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;nsIFile&nbsp;installPath</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;nsIURI&nbsp;resourceURI</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;Reason&nbsp;types:</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;APP_STARTUP</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_ENABLE</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_INSTALL</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_UPGRADE</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_DOWNGRADE</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&lt;/summary&gt;</span>
}
<span style="color:blue;">function</span>&nbsp;shutdown(data,&nbsp;reason)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&lt;summary&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;Bootstrap&nbsp;data&nbsp;structure&nbsp;@see&nbsp;https://developer.mozilla.org/en-US/docs/Extensions/Bootstrapped_extensions#Bootstrap_data</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;string&nbsp;id</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;string&nbsp;version</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;nsIFile&nbsp;installPath</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;nsIURI&nbsp;resourceURI</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;Reason&nbsp;types:</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;APP_SHUTDOWN</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_DISABLE</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_UNINSTALL</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_UPGRADE</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_DOWNGRADE</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&lt;/summary&gt;</span>
}
<span style="color:blue;">function</span>&nbsp;install(data,&nbsp;reason)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&lt;summary&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;Bootstrap&nbsp;data&nbsp;structure&nbsp;@see&nbsp;https://developer.mozilla.org/en-US/docs/Extensions/Bootstrapped_extensions#Bootstrap_data</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;string&nbsp;id</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;string&nbsp;version</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;nsIFile&nbsp;installPath</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;nsIURI&nbsp;resourceURI</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;Reason&nbsp;types:</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_INSTALL</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_UPGRADE</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_DOWNGRADE</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&lt;/summary&gt;</span>
}
<span style="color:blue;">function</span>&nbsp;uninstall(data,&nbsp;reason)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&lt;summary&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;Bootstrap&nbsp;data&nbsp;structure&nbsp;@see&nbsp;https://developer.mozilla.org/en-US/docs/Extensions/Bootstrapped_extensions#Bootstrap_data</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;string&nbsp;id</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;string&nbsp;version</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;nsIFile&nbsp;installPath</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;nsIURI&nbsp;resourceURI</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;Reason&nbsp;types:</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_UNINSTALL</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_UPGRADE</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&amp;#10;&nbsp;&nbsp;ADDON_DOWNGRADE</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:darkgreen;">///&nbsp;&lt;/summary&gt;</span>
}</pre>
Revert to this revision