title: Importing Javascript module in Firefox extension
body: <p>I am developing a simple Firefox extension but am having trouble importing my custom Javascript module file. The <code>bootstrap.js</code> file is at the root and <code>test.jsm</code> is inside the <code>content</code> folder.
  <code>test.jsm</code> exports 2 symbols <code>foo</code> and <code>bar</code> as:</p>
  
  <pre><code>this.EXPORTED_SYMBOLS = ["foo", "bar"];
  </code></pre>
  
  <p>As per the <a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Using" rel="nofollow" title="Using JavaScript code modules">Using JavaScript code modules</a> article, I already have a <code>content</code> instruction in the <code>chrome.manifest</code> file:</p>
  
  <pre><code>content     myaddon   content/
  </code></pre>
  
  <p>So, I should be able to import <code>test.jsm</code> into <code>bootstrap.js</code> as:</p>
  
  <pre><code> Components.utils.import("chrome://myaddon/content/test.jsm");
  </code></pre>
  
  <p>But I see the following 2 warnings in the Browser Console:</p>
  
  <pre><code>addons.xpi
  WARN
  Error loading bootstrap.js for myaddon@oyenamit: [Exception... "Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIXPCComponents_Utils.import]"
  nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)"
  location: "JS frame :: resource://gre/modules/addons/XPIProvider.jsm -&gt;
  jar:file:///Users/oyenamit/Library/Application%20Support/Firefox/Profiles/profilename/extensions/myaddon@oyenamit.xpi!/bootstrap.js :: &lt;TOP_LEVEL&gt; :: line 1"
  data: no] Stack trace: resource://gre/modules/addons/XPIProvider.jsm -&gt;
  jar:file:///Users/oyenamit/Library/Application%20Support/Firefox/Profiles/profilename/extensions/myaddon@oyenamit.xpi!/bootstrap.js:1
  &lt; resource://gre/modules/addons/XPIProvider.jsm:4348
  &lt; XPI_loadBootstrapScope()@resource://gre/modules/addons/XPIProvider.jsm:4348
  &lt; XPI_callBootstrapMethod()@resource://gre/modules/addons/XPIProvider.jsm:4423
  &lt; AI_startInstall/&lt;()@resource://gre/modules/addons/XPIProvider.jsm:5849
  &lt; next()@self-hosted:675 &lt; TaskImpl_run()@resource://gre/modules/Task.jsm:330
  &lt; Handler.prototype.process()@resource://gre/modules/Promise.jsm -&gt;
  resource://gre/modules/Promise-backend.js:867 &lt;
  this.PromiseWalker.walkerLoop()@resource://gre/modules/Promise.jsm -&gt;
  resource://gre/modules/Promise-backend.js:746 &lt;
  this.PromiseWalker.scheduleWalkerLoop/&lt;()@resource://gre/modules/Promise.jsm -&gt;
  resource://gre/modules/Promise-backend.js:688 &lt; &lt;file:unknown&gt;
  
  
  
  
  addons.xpi
  WARN
  Exception running bootstrap method startup on myaddon@oyenamit: ReferenceError: foo is not defined (resource://gre/modules/addons/XPIProvider.jsm -&gt;
  jar:file:///Users/oyenamit/Library/Application%20Support/Firefox/Profiles/profilename/extensions/myaddon@oyenamit.xpi!/bootstrap.js:16:4) JS Stack trace:
  startup@resource://gre/modules/addons/XPIProvider.jsm -&gt;
  jar:file:///Users/oyenamit/Library/Application%20Support/Firefox/Profiles/profilename/extensions/myaddon@bootstrap.js:16:5 &lt;
  XPI_callBootstrapMethod@XPIProvider.jsm:4451:9 &lt;
  AI_startInstall/&lt;@XPIProvider.jsm:5864:13
  </code></pre>
  
  <p>What am I doing wrong? I am using Firefox 39.0.</p>
  
  <p>A sample XPI file can be downloaded from <a href="http://d.pr/f/9tX1" rel="nofollow" title="here">here</a>.</p>