mozilla

Revision 77379 of bootstrap.js

  • Revision slug: Extensions/bootstrap.js
  • Revision title: bootstrap.js
  • Revision id: 77379
  • Created:
  • Creator: BrunoLM
  • Is current revision? No
  • Comment 473 words added

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.

{{ syntax.javascript{code: "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> }"} }}

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>
<p>{{ syntax.javascript{code: "function startup(data, reason) {
    /// &lt;summary&gt;
    /// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &amp;#10;  string id
    /// &amp;#10;  string version
    /// &amp;#10;  nsIFile installPath
    /// &amp;#10;  nsIURI resourceURI
    /// &amp;#10;
    /// Reason types:
    /// &amp;#10;  APP_STARTUP
    /// &amp;#10;  ADDON_ENABLE
    /// &amp;#10;  ADDON_INSTALL
    /// &amp;#10;  ADDON_UPGRADE
    /// &amp;#10;  ADDON_DOWNGRADE
    /// &lt;/summary&gt;
}
function shutdown(data, reason) {
    /// &lt;summary&gt;
    /// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &amp;#10;  string id
    /// &amp;#10;  string version
    /// &amp;#10;  nsIFile installPath
    /// &amp;#10;  nsIURI resourceURI
    /// &amp;#10;
    /// Reason types:
    /// &amp;#10;  APP_SHUTDOWN
    /// &amp;#10;  ADDON_DISABLE
    /// &amp;#10;  ADDON_UNINSTALL
    /// &amp;#10;  ADDON_UPGRADE
    /// &amp;#10;  ADDON_DOWNGRADE
    /// &lt;/summary&gt;
}
function install(data, reason) {
    /// &lt;summary&gt;
    /// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &amp;#10;  string id
    /// &amp;#10;  string version
    /// &amp;#10;  nsIFile installPath
    /// &amp;#10;  nsIURI resourceURI
    /// &amp;#10;
    /// Reason types:
    /// &amp;#10;  ADDON_INSTALL
    /// &amp;#10;  ADDON_UPGRADE
    /// &amp;#10;  ADDON_DOWNGRADE
    /// &lt;/summary&gt;
}
function uninstall(data, reason) {
    /// &lt;summary&gt;
    /// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &amp;#10;  string id
    /// &amp;#10;  string version
    /// &amp;#10;  nsIFile installPath
    /// &amp;#10;  nsIURI resourceURI
    /// &amp;#10;
    /// Reason types:
    /// &amp;#10;  ADDON_UNINSTALL
    /// &amp;#10;  ADDON_UPGRADE
    /// &amp;#10;  ADDON_DOWNGRADE
    /// &lt;/summary&gt;
}"} }}</p>
<pre>function startup(data, reason) {
    /// &lt;summary&gt;
    /// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &amp;#10;  string id
    /// &amp;#10;  string version
    /// &amp;#10;  nsIFile installPath
    /// &amp;#10;  nsIURI resourceURI
    /// &amp;#10;
    /// Reason types:
    /// &amp;#10;  APP_STARTUP
    /// &amp;#10;  ADDON_ENABLE
    /// &amp;#10;  ADDON_INSTALL
    /// &amp;#10;  ADDON_UPGRADE
    /// &amp;#10;  ADDON_DOWNGRADE
    /// &lt;/summary&gt;
}
function shutdown(data, reason) {
    /// &lt;summary&gt;
    /// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &amp;#10;  string id
    /// &amp;#10;  string version
    /// &amp;#10;  nsIFile installPath
    /// &amp;#10;  nsIURI resourceURI
    /// &amp;#10;
    /// Reason types:
    /// &amp;#10;  APP_SHUTDOWN
    /// &amp;#10;  ADDON_DISABLE
    /// &amp;#10;  ADDON_UNINSTALL
    /// &amp;#10;  ADDON_UPGRADE
    /// &amp;#10;  ADDON_DOWNGRADE
    /// &lt;/summary&gt;
}
function install(data, reason) {
    /// &lt;summary&gt;
    /// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &amp;#10;  string id
    /// &amp;#10;  string version
    /// &amp;#10;  nsIFile installPath
    /// &amp;#10;  nsIURI resourceURI
    /// &amp;#10;
    /// Reason types:
    /// &amp;#10;  ADDON_INSTALL
    /// &amp;#10;  ADDON_UPGRADE
    /// &amp;#10;  ADDON_DOWNGRADE
    /// &lt;/summary&gt;
}
function uninstall(data, reason) {
    /// &lt;summary&gt;
    /// Bootstrap data structure @see https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Bootstrap_data
    /// &amp;#10;  string id
    /// &amp;#10;  string version
    /// &amp;#10;  nsIFile installPath
    /// &amp;#10;  nsIURI resourceURI
    /// &amp;#10;
    /// Reason types:
    /// &amp;#10;  ADDON_UNINSTALL
    /// &amp;#10;  ADDON_UPGRADE
    /// &amp;#10;  ADDON_DOWNGRADE
    /// &lt;/summary&gt;
}
</pre>
Revert to this revision