bootstrap.js

  • Revision slug: Extensions/bootstrap.js
  • Revision title: bootstrap.js
  • Revision id: 77380
  • Created:
  • Creator: BrunoLM
  • Is current revision? No
  • Comment 8 words added, 481 words removed

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 bellow contains the required methods in vsdoc format.

function startup(data, reason) {
    /// <summary>
    /// Bootstrap data structure @see https://developer.mozilla.org/en/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/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/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/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 <a href="/en/Extensions/Bootstrapped_extensions" title="https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions">see Bootstrapped extensions</a>.</p>
<p>The example bellow 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> startup(data, reason) {
    <span style="color:darkgreen;">/// &lt;summary&gt;</span>
    <span style="color:darkgreen;">/// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data</span>
    <span style="color:darkgreen;">/// &amp;#10;  string id</span>
    <span style="color:darkgreen;">/// &amp;#10;  string version</span>
    <span style="color:darkgreen;">/// &amp;#10;  nsIFile installPath</span>
    <span style="color:darkgreen;">/// &amp;#10;  nsIURI resourceURI</span>
    <span style="color:darkgreen;">/// &amp;#10;</span>
    <span style="color:darkgreen;">/// Reason types:</span>
    <span style="color:darkgreen;">/// &amp;#10;  APP_STARTUP</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_ENABLE</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_INSTALL</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_UPGRADE</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_DOWNGRADE</span>
    <span style="color:darkgreen;">/// &lt;/summary&gt;</span>
}
<span style="color:blue;">function</span> shutdown(data, reason) {
    <span style="color:darkgreen;">/// &lt;summary&gt;</span>
    <span style="color:darkgreen;">/// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data</span>
    <span style="color:darkgreen;">/// &amp;#10;  string id</span>
    <span style="color:darkgreen;">/// &amp;#10;  string version</span>
    <span style="color:darkgreen;">/// &amp;#10;  nsIFile installPath</span>
    <span style="color:darkgreen;">/// &amp;#10;  nsIURI resourceURI</span>
    <span style="color:darkgreen;">/// &amp;#10;</span>
    <span style="color:darkgreen;">/// Reason types:</span>
    <span style="color:darkgreen;">/// &amp;#10;  APP_SHUTDOWN</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_DISABLE</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_UNINSTALL</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_UPGRADE</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_DOWNGRADE</span>
    <span style="color:darkgreen;">/// &lt;/summary&gt;</span>
}
<span style="color:blue;">function</span> install(data, reason) {
    <span style="color:darkgreen;">/// &lt;summary&gt;</span>
    <span style="color:darkgreen;">/// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data</span>
    <span style="color:darkgreen;">/// &amp;#10;  string id</span>
    <span style="color:darkgreen;">/// &amp;#10;  string version</span>
    <span style="color:darkgreen;">/// &amp;#10;  nsIFile installPath</span>
    <span style="color:darkgreen;">/// &amp;#10;  nsIURI resourceURI</span>
    <span style="color:darkgreen;">/// &amp;#10;</span>
    <span style="color:darkgreen;">/// Reason types:</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_INSTALL</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_UPGRADE</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_DOWNGRADE</span>
    <span style="color:darkgreen;">/// &lt;/summary&gt;</span>
}
<span style="color:blue;">function</span> uninstall(data, reason) {
    <span style="color:darkgreen;">/// &lt;summary&gt;</span>
    <span style="color:darkgreen;">/// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data</span>
    <span style="color:darkgreen;">/// &amp;#10;  string id</span>
    <span style="color:darkgreen;">/// &amp;#10;  string version</span>
    <span style="color:darkgreen;">/// &amp;#10;  nsIFile installPath</span>
    <span style="color:darkgreen;">/// &amp;#10;  nsIURI resourceURI</span>
    <span style="color:darkgreen;">/// &amp;#10;</span>
    <span style="color:darkgreen;">/// Reason types:</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_UNINSTALL</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_UPGRADE</span>
    <span style="color:darkgreen;">/// &amp;#10;  ADDON_DOWNGRADE</span>
    <span style="color:darkgreen;">/// &lt;/summary&gt;</span>
}</pre>
Revert to this revision