title: Firefox page-mod - "contentScript":null
body: <p>I'm doing the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/page-mod" rel="nofollow"><code>page-mod</code> tutorial</a>.</p>
  
  <p>Here's my code:
  <code>main.js</code></p>
  
  <pre><code>var tag = 'p'
  var data = require('sdk/self').data
  var pageMod = require('sdk/page-mod')
  
  pageMod.PageMod({
      include: '*',
      contentScriptFile: data.url('element-getter.js'),
      onAttach: attachHandler
  })
  
  function attachHandler(worker) {
      console.log('worker ', worker)
      worker.port.emit('getElements', tag)
      worker.port.on('gotContent', function(content) {
          console.log('received content ', content)
      })
  }
  </code></pre>
  
  <p><code>element-getter.js</code>:</p>
  
  <pre><code>self.port.on('getElements', function(tag) {
      console.log('received tag ', tag)
      var elements = document.getElementsByTagName(tag)
      console.log('found elements ', elements)
      for (var i=0; i&lt; elements.length; i++) {
          self.port.emit('gotContent', elements[i].innerHTML)
      })
  })
  </code></pre>
  
  <p>(Also available in <a href="https://github.com/findjashua/pgmod" rel="nofollow">github.com/findjashua/pgmod</a>)</p>
  
  <p>It only logs the first message on the terminal, and none on the browser console. From the message, you can see that it thinks the <code>contentScript</code> is null. What am I doing wrong here? </p>
  
  <p>Here is what gets logged on the terminal:</p>
  
  <pre><code>console.error: pgmod:
    Message: SyntaxError: syntax error
  console.log: pgmod: worker  constructor {"contentScriptFile":"resource://jid1-kkjpd9s1yzxe9g-at-jetpack/pgmod/data/element-getter.js","contentScript":null,"port":{}}
  </code></pre>